Joseph Redmon
2015-05-20 ff7e03325a2f36bf4eb13e1f538b78e1549305cc
src/detection.c
@@ -47,6 +47,8 @@
                int top   = (y-h/2)*im.h;
                int bot   = (y+h/2)*im.h;
                draw_box(im, left, top, right, bot, red, green, blue);
                draw_box(im, left+1, top+1, right+1, bot+1, red, green, blue);
                draw_box(im, left-1, top-1, right-1, bot-1, red, green, blue);
            }
        }
    }
@@ -115,7 +117,12 @@
        time=clock();
        float loss = train_network(net, train);
        //TODO
        #ifdef GPU
        float *out = get_network_output_gpu(net);
        #else
        float *out = get_network_output(net);
        #endif
        image im = float_to_image(net.w, net.h, 3, train.X.vals[127]);
        image copy = copy_image(im);
        draw_localization(copy, &(out[63*80]));
@@ -149,7 +156,7 @@
    if(weightfile){
        load_weights(&net, weightfile);
    }
    detection_layer *layer = get_network_detection_layer(net);
    detection_layer layer = get_network_detection_layer(net);
    net.learning_rate = 0;
    net.decay = 0;
    printf("Learning Rate: %g, Momentum: %g, Decay: %g\n", net.learning_rate, net.momentum, net.decay);
@@ -157,9 +164,9 @@
    int i = net.seen/imgs;
    data train, buffer;
    int classes = layer->classes;
    int background = layer->background;
    int side = sqrt(get_detection_layer_locations(*layer));
    int classes = layer.classes;
    int background = layer.background;
    int side = sqrt(get_detection_layer_locations(layer));
    char **paths;
    list *plist;
@@ -174,7 +181,7 @@
    paths = (char **)list_to_array(plist);
    pthread_t load_thread = load_data_detection_thread(imgs, paths, plist->size, classes, net.w, net.h, side, side, background, &buffer);
    clock_t time;
    cost_layer clayer = *((cost_layer *)net.layers[net.n-1]);
    cost_layer clayer = net.layers[net.n-1];
    while(1){
        i += 1;
        time=clock();
@@ -212,7 +219,7 @@
        avg_loss = avg_loss*.9 + loss*.1;
        printf("%d: %f, %f avg, %lf seconds, %d images\n", i, loss, avg_loss, sec(clock()-time), i*imgs);
        if(i == 100){
            net.learning_rate *= 10;
            //net.learning_rate *= 10;
        }
        if(i%100==0){
            char buff[256];
@@ -235,15 +242,15 @@
    if(weightfile){
        load_weights(&net, weightfile);
    }
    detection_layer *layer = get_network_detection_layer(net);
    detection_layer layer = get_network_detection_layer(net);
    printf("Learning Rate: %g, Momentum: %g, Decay: %g\n", net.learning_rate, net.momentum, net.decay);
    int imgs = 128;
    int i = net.seen/imgs;
    data train, buffer;
    int classes = layer->classes;
    int background = layer->background;
    int side = sqrt(get_detection_layer_locations(*layer));
    int classes = layer.classes;
    int background = layer.background;
    int side = sqrt(get_detection_layer_locations(layer));
    char **paths;
    list *plist;
@@ -308,8 +315,8 @@
                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);
@@ -325,7 +332,7 @@
    if(weightfile){
        load_weights(&net, weightfile);
    }
    detection_layer *layer = get_network_detection_layer(net);
    detection_layer layer = get_network_detection_layer(net);
    fprintf(stderr, "Learning Rate: %g, Momentum: %g, Decay: %g\n", net.learning_rate, net.momentum, net.decay);
    srand(time(0));
@@ -336,10 +343,10 @@
    //list *plist = get_paths("/home/pjreddie/data/voc/train.txt");
    char **paths = (char **)list_to_array(plist);
    int classes = layer->classes;
    int nuisance = layer->nuisance;
    int background = (layer->background && !nuisance);
    int num_boxes = sqrt(get_detection_layer_locations(*layer));
    int classes = layer.classes;
    int nuisance = layer.nuisance;
    int background = (layer.background && !nuisance);
    int num_boxes = sqrt(get_detection_layer_locations(layer));
    int per_box = 4+classes+background+nuisance;
    int num_output = num_boxes*num_boxes*per_box;
@@ -393,7 +400,7 @@
    load_weights(&post, "/home/pjreddie/imagenet_backup/localize_1000.weights");
    set_batch_network(&post, 1);
    detection_layer *layer = get_network_detection_layer(net);
    detection_layer layer = get_network_detection_layer(net);
    fprintf(stderr, "Learning Rate: %g, Momentum: %g, Decay: %g\n", net.learning_rate, net.momentum, net.decay);
    srand(time(0));
@@ -404,10 +411,10 @@
    //list *plist = get_paths("/home/pjreddie/data/voc/train.txt");
    char **paths = (char **)list_to_array(plist);
    int classes = layer->classes;
    int nuisance = layer->nuisance;
    int background = (layer->background && !nuisance);
    int num_boxes = sqrt(get_detection_layer_locations(*layer));
    int classes = layer.classes;
    int nuisance = layer.nuisance;
    int background = (layer.background && !nuisance);
    int num_boxes = sqrt(get_detection_layer_locations(layer));
    int per_box = 4+classes+background+nuisance;