| | |
| | | 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 normalization_layer.o parser.o option_list.o darknet.o detection_layer.o imagenet.o captcha.o detection.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 normalization_layer.o parser.o option_list.o darknet.o detection_layer.o imagenet.o captcha.o detection.o route_layer.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 |
| | |
| | | h = constrain(0, 1, h); |
| | | if (w == 0 || h == 0) continue; |
| | | if(1){ |
| | | w = sqrt(w); |
| | | h = sqrt(h); |
| | | //w = sqrt(w); |
| | | //h = sqrt(h); |
| | | w = pow(w, 1./2.); |
| | | h = pow(h, 1./2.); |
| | | } |
| | | |
| | | int index = (i+j*num_boxes)*(4+classes+background); |
| | |
| | | float y = (pred.vals[j][ci + 1] + row)/num_boxes; |
| | | float w = pred.vals[j][ci + 2]; //* distance_from_edge(row, num_boxes); |
| | | float h = pred.vals[j][ci + 3]; //* distance_from_edge(col, num_boxes); |
| | | w = w*w; |
| | | h = h*h; |
| | | w = pow(w, 2); |
| | | h = pow(h, 2); |
| | | float prob = scale*pred.vals[j][k+class+background+nuisance]; |
| | | if(prob < threshold) continue; |
| | | printf("%d %d %f %f %f %f %f\n", offset + j, class, prob, x, y, w, h); |
| | |
| | | #include "image.h" |
| | | #include "data.h" |
| | | #include "utils.h" |
| | | #include "params.h" |
| | | |
| | | #include "crop_layer.h" |
| | | #include "connected_layer.h" |
| | |
| | | #include "normalization_layer.h" |
| | | #include "softmax_layer.h" |
| | | #include "dropout_layer.h" |
| | | #include "route_layer.h" |
| | | |
| | | char *get_layer_string(LAYER_TYPE a) |
| | | { |
| | |
| | | return "crop"; |
| | | case COST: |
| | | return "cost"; |
| | | case ROUTE: |
| | | return "route"; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | else if(net.types[i] == DROPOUT){ |
| | | forward_dropout_layer(*(dropout_layer *)net.layers[i], state); |
| | | } |
| | | else if(net.types[i] == ROUTE){ |
| | | forward_route_layer(*(route_layer *)net.layers[i], net); |
| | | } |
| | | state.input = get_network_output_layer(net, i); |
| | | } |
| | | } |
| | |
| | | return ((crop_layer *)net.layers[i]) -> output; |
| | | } else if(net.types[i] == NORMALIZATION){ |
| | | return ((normalization_layer *)net.layers[i]) -> output; |
| | | } else if(net.types[i] == ROUTE){ |
| | | return ((route_layer *)net.layers[i]) -> output; |
| | | } |
| | | return 0; |
| | | } |
| | |
| | | } else if(net.types[i] == CONNECTED){ |
| | | connected_layer layer = *(connected_layer *)net.layers[i]; |
| | | return layer.delta; |
| | | } else if(net.types[i] == ROUTE){ |
| | | return ((route_layer *)net.layers[i]) -> delta; |
| | | } |
| | | return 0; |
| | | } |
| | |
| | | else if(net.types[i] == CONNECTED){ |
| | | connected_layer layer = *(connected_layer *)net.layers[i]; |
| | | backward_connected_layer(layer, state); |
| | | } |
| | | else if(net.types[i] == COST){ |
| | | } else if(net.types[i] == COST){ |
| | | cost_layer layer = *(cost_layer *)net.layers[i]; |
| | | backward_cost_layer(layer, state); |
| | | } else if(net.types[i] == ROUTE){ |
| | | route_layer layer = *(route_layer *)net.layers[i]; |
| | | backward_route_layer(layer, net); |
| | | } |
| | | } |
| | | } |
| | |
| | | crop_layer *layer = (crop_layer *)net->layers[i]; |
| | | layer->batch = b; |
| | | } |
| | | else if(net->types[i] == ROUTE){ |
| | | route_layer *layer = (route_layer *)net->layers[i]; |
| | | layer->batch = b; |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | softmax_layer layer = *(softmax_layer *)net.layers[i]; |
| | | return layer.inputs; |
| | | } |
| | | else if(net.types[i] == ROUTE){ |
| | | route_layer layer = *(route_layer *)net.layers[i]; |
| | | return layer.outputs; |
| | | } |
| | | fprintf(stderr, "Can't find output size\n"); |
| | | return 0; |
| | | } |
| | | |
| | | int resize_network(network net, int h, int w, int c) |
| | | { |
| | | fprintf(stderr, "Might be broken, careful!!"); |
| | | int i; |
| | | for (i = 0; i < net.n; ++i){ |
| | | if(net.types[i] == CONVOLUTIONAL){ |
| | |
| | | crop_layer layer = *(crop_layer *)net.layers[i]; |
| | | return get_crop_image(layer); |
| | | } |
| | | else if(net.types[i] == ROUTE){ |
| | | route_layer layer = *(route_layer *)net.layers[i]; |
| | | return get_network_image_layer(net, layer.input_layers[0]); |
| | | } |
| | | return make_empty_image(0,0,0); |
| | | } |
| | | |
| | |
| | | |
| | | #include "image.h" |
| | | #include "detection_layer.h" |
| | | #include "params.h" |
| | | #include "data.h" |
| | | |
| | | typedef enum { |
| | |
| | | NORMALIZATION, |
| | | DROPOUT, |
| | | CROP, |
| | | ROUTE, |
| | | COST |
| | | } LAYER_TYPE; |
| | | |
| | |
| | | #include "normalization_layer.h" |
| | | #include "softmax_layer.h" |
| | | #include "dropout_layer.h" |
| | | #include "route_layer.h" |
| | | } |
| | | |
| | | float * get_network_output_gpu_layer(network net, int i); |
| | |
| | | else if(net.types[i] == CROP){ |
| | | forward_crop_layer_gpu(*(crop_layer *)net.layers[i], state); |
| | | } |
| | | else if(net.types[i] == ROUTE){ |
| | | forward_route_layer_gpu(*(route_layer *)net.layers[i], net); |
| | | } |
| | | state.input = get_network_output_gpu_layer(net, i); |
| | | } |
| | | } |
| | |
| | | else if(net.types[i] == SOFTMAX){ |
| | | backward_softmax_layer_gpu(*(softmax_layer *)net.layers[i], state); |
| | | } |
| | | else if(net.types[i] == ROUTE){ |
| | | backward_route_layer_gpu(*(route_layer *)net.layers[i], net); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | else if(net.types[i] == SOFTMAX){ |
| | | return ((softmax_layer *)net.layers[i]) -> output_gpu; |
| | | } |
| | | else if(net.types[i] == ROUTE){ |
| | | return ((route_layer *)net.layers[i]) -> output_gpu; |
| | | } |
| | | else if(net.types[i] == DROPOUT){ |
| | | return get_network_output_gpu_layer(net, i-1); |
| | | } |
| | |
| | | maxpool_layer layer = *(maxpool_layer *)net.layers[i]; |
| | | return layer.delta_gpu; |
| | | } |
| | | else if(net.types[i] == ROUTE){ |
| | | route_layer layer = *(route_layer *)net.layers[i]; |
| | | return layer.delta_gpu; |
| | | } |
| | | else if(net.types[i] == SOFTMAX){ |
| | | softmax_layer layer = *(softmax_layer *)net.layers[i]; |
| | | return layer.delta_gpu; |
| | |
| | | #include "softmax_layer.h" |
| | | #include "dropout_layer.h" |
| | | #include "detection_layer.h" |
| | | #include "route_layer.h" |
| | | #include "list.h" |
| | | #include "option_list.h" |
| | | #include "utils.h" |
| | |
| | | int is_cost(section *s); |
| | | int is_detection(section *s); |
| | | int is_normalization(section *s); |
| | | int is_route(section *s); |
| | | list *read_cfg(char *filename); |
| | | |
| | | void free_section(section *s) |
| | |
| | | return layer; |
| | | } |
| | | |
| | | route_layer *parse_route(list *options, size_params params, network net) |
| | | { |
| | | char *l = option_find(options, "layers"); |
| | | int len = strlen(l); |
| | | if(!l) error("Route Layer must specify input layers"); |
| | | int n = 1; |
| | | int i; |
| | | for(i = 0; i < len; ++i){ |
| | | if (l[i] == ',') ++n; |
| | | } |
| | | |
| | | int *layers = calloc(n, sizeof(int)); |
| | | int *sizes = calloc(n, sizeof(int)); |
| | | for(i = 0; i < n; ++i){ |
| | | int index = atoi(l); |
| | | l = strchr(l, ',')+1; |
| | | layers[i] = index; |
| | | sizes[i] = get_network_output_size_layer(net, index); |
| | | } |
| | | int batch = params.batch; |
| | | |
| | | route_layer *layer = make_route_layer(batch, n, layers, sizes); |
| | | option_unused(options); |
| | | return layer; |
| | | } |
| | | |
| | | void parse_net_options(list *options, network *net) |
| | | { |
| | | net->batch = option_find_int(options, "batch",1); |
| | |
| | | normalization_layer *layer = parse_normalization(options, params); |
| | | net.types[count] = NORMALIZATION; |
| | | net.layers[count] = layer; |
| | | }else if(is_route(s)){ |
| | | route_layer *layer = parse_route(options, params, net); |
| | | net.types[count] = ROUTE; |
| | | net.layers[count] = layer; |
| | | }else if(is_dropout(s)){ |
| | | dropout_layer *layer = parse_dropout(options, params); |
| | | net.types[count] = DROPOUT; |
| | |
| | | return (strcmp(s->type, "[lrnorm]")==0 |
| | | || strcmp(s->type, "[localresponsenormalization]")==0); |
| | | } |
| | | int is_route(section *s) |
| | | { |
| | | return (strcmp(s->type, "[route]")==0); |
| | | } |
| | | |
| | | int read_option(char *s, list *options) |
| | | { |