| | |
| | | LDFLAGS+= -L/usr/local/cuda/lib64 -lcuda -lcudart -lcublas -lcurand |
| | | endif |
| | | |
| | | OBJ=gemm.o utils.o cuda.o deconvolutional_layer.o convolutional_layer.o list.o image.o activations.o im2col.o col2im.o blas.o crop_layer.o dropout_layer.o maxpool_layer.o softmax_layer.o data.o matrix.o network.o connected_layer.o cost_layer.o parser.o option_list.o darknet.o detection_layer.o imagenet.o captcha.o detection.o route_layer.o |
| | | OBJ=gemm.o utils.o cuda.o deconvolutional_layer.o convolutional_layer.o list.o image.o activations.o im2col.o col2im.o blas.o crop_layer.o dropout_layer.o maxpool_layer.o softmax_layer.o data.o matrix.o network.o connected_layer.o cost_layer.o parser.o option_list.o darknet.o detection_layer.o imagenet.o captcha.o detection.o route_layer.o writing.o |
| | | ifeq ($(GPU), 1) |
| | | OBJ+=convolutional_kernels.o deconvolutional_kernels.o activation_kernels.o im2col_kernels.o col2im_kernels.o blas_kernels.o crop_layer_kernels.o dropout_layer_kernels.o maxpool_layer_kernels.o softmax_layer_kernels.o network_kernels.o |
| | | endif |
| | |
| | | |
| | | extern void run_imagenet(int argc, char **argv); |
| | | extern void run_detection(int argc, char **argv); |
| | | extern void run_writing(int argc, char **argv); |
| | | extern void run_captcha(int argc, char **argv); |
| | | |
| | | void del_arg(int argc, char **argv, int index) |
| | |
| | | run_imagenet(argc, argv); |
| | | } else if (0 == strcmp(argv[1], "detection")){ |
| | | run_detection(argc, argv); |
| | | } else if (0 == strcmp(argv[1], "writing")){ |
| | | run_writing(argc, argv); |
| | | } else if (0 == strcmp(argv[1], "test")){ |
| | | test_resize(argv[2]); |
| | | } else if (0 == strcmp(argv[1], "captcha")){ |
| | |
| | | return random_paths; |
| | | } |
| | | |
| | | char **find_replace_paths(char **paths, int n, char *find, char *replace) |
| | | { |
| | | char **replace_paths = calloc(n, sizeof(char*)); |
| | | int i; |
| | | for(i = 0; i < n; ++i){ |
| | | char *replaced = find_replace(paths[i], find, replace); |
| | | replace_paths[i] = copy_string(replaced); |
| | | } |
| | | return replace_paths; |
| | | } |
| | | |
| | | matrix load_image_paths_gray(char **paths, int n, int w, int h) |
| | | { |
| | | int i; |
| | | matrix X; |
| | | X.rows = n; |
| | | X.vals = calloc(X.rows, sizeof(float*)); |
| | | X.cols = 0; |
| | | |
| | | for(i = 0; i < n; ++i){ |
| | | image im = load_image(paths[i], w, h); |
| | | X.vals[i] = im.data; |
| | | X.cols = im.h*im.w*im.c; |
| | | } |
| | | return X; |
| | | } |
| | | |
| | | matrix load_image_paths(char **paths, int n, int w, int h) |
| | | { |
| | | int i; |
| | |
| | | return thread; |
| | | } |
| | | |
| | | data load_data_writing(char **paths, int n, int m, int w, int h) |
| | | { |
| | | if(m) paths = get_random_paths(paths, n, m); |
| | | char **replace_paths = find_replace_paths(paths, n, ".png", "label.png"); |
| | | data d; |
| | | d.shallow = 0; |
| | | d.X = load_image_paths(paths, n, w, h); |
| | | d.y = load_image_paths_gray(replace_paths, n, w/4, h/4); |
| | | if(m) free(paths); |
| | | int i; |
| | | for(i = 0; i < n; ++i) free(replace_paths[i]); |
| | | free(replace_paths); |
| | | return d; |
| | | } |
| | | |
| | | data load_data(char **paths, int n, int m, char **labels, int k, int w, int h) |
| | | { |
| | | if(m) paths = get_random_paths(paths, n, m); |
| | |
| | | data load_cifar10_data(char *filename); |
| | | data load_all_cifar10(); |
| | | |
| | | data load_data_writing(char **paths, int n, int m, int w, int h); |
| | | |
| | | list *get_paths(char *filename); |
| | | char **get_labels(char *filename); |
| | | void get_random_batch(data d, int n, float *X, float *y); |
| | |
| | | |
| | | |
| | | *(l.cost) += pow((1-iou), 2); |
| | | if(0){ |
| | | l.delta[j+0] = (state.truth[j+0] - l.output[j+0]); |
| | | l.delta[j+1] = (state.truth[j+1] - l.output[j+1]); |
| | | l.delta[j+2] = (state.truth[j+2] - l.output[j+2]); |
| | | l.delta[j+3] = (state.truth[j+3] - l.output[j+3]); |
| | | }else{ |
| | | l.delta[j+0] = 4 * (state.truth[j+0] - l.output[j+0]) / 7; |
| | | l.delta[j+1] = 4 * (state.truth[j+1] - l.output[j+1]) / 7; |
| | | l.delta[j+0] = 4 * (state.truth[j+0] - l.output[j+0]); |
| | | l.delta[j+1] = 4 * (state.truth[j+1] - l.output[j+1]); |
| | | l.delta[j+2] = 4 * (state.truth[j+2] - l.output[j+2]); |
| | | l.delta[j+3] = 4 * (state.truth[j+3] - l.output[j+3]); |
| | | } |
| | | if(0){ |
| | | if(1){ |
| | | for (j = offset; j < offset+classes; ++j) { |
| | | if(state.truth[j]) state.truth[j] = iou; |
| | | l.delta[j] = state.truth[j] - l.output[j]; |
| | |
| | | avg_loss = avg_loss*.9 + loss*.1; |
| | | printf("%d: %f, %f avg, %lf seconds, %d images\n", i, loss, avg_loss, sec(clock()-time), net.seen); |
| | | free_data(train); |
| | | if((i % 20000) == 0) net.learning_rate *= .1; |
| | | if((i % 15000) == 0) net.learning_rate *= .1; |
| | | //if(i%100 == 0 && net.learning_rate > .00001) net.learning_rate *= .97; |
| | | if(i%1000==0){ |
| | | char buff[256]; |