From 81c23650e1b880279d29e9a6cef18d29e2cec69c Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Wed, 16 Dec 2015 19:46:39 +0000
Subject: [PATCH] missing file

---
 src/yolo.c |   49 +++++++++++--------------------------------------
 1 files changed, 11 insertions(+), 38 deletions(-)

diff --git a/src/yolo.c b/src/yolo.c
index 80d85af..a6c1e78 100644
--- a/src/yolo.c
+++ b/src/yolo.c
@@ -10,40 +10,7 @@
 #endif
 
 char *voc_names[] = {"aeroplane", "bicycle", "bird", "boat", "bottle", "bus", "car", "cat", "chair", "cow", "diningtable", "dog", "horse", "motorbike", "person", "pottedplant", "sheep", "sofa", "train", "tvmonitor"};
-
-void draw_yolo(image im, int num, float thresh, box *boxes, float **probs)
-{
-    int classes = 20;
-    int i;
-
-    for(i = 0; i < num; ++i){
-        int class = max_index(probs[i], classes);
-        float prob = probs[i][class];
-        if(prob > thresh){
-            int width = pow(prob, 1./2.)*10+1;
-            width = 8;
-            printf("%s: %.2f\n", voc_names[class], prob);
-            class = class * 7 % 20;
-            float red = get_color(0,class,classes);
-            float green = get_color(1,class,classes);
-            float blue = get_color(2,class,classes);
-            //red = green = blue = 0;
-            box b = boxes[i];
-
-            int left  = (b.x-b.w/2.)*im.w;
-            int right = (b.x+b.w/2.)*im.w;
-            int top   = (b.y-b.h/2.)*im.h;
-            int bot   = (b.y+b.h/2.)*im.h;
-
-            if(left < 0) left = 0;
-            if(right > im.w-1) right = im.w-1;
-            if(top < 0) top = 0;
-            if(bot > im.h-1) bot = im.h-1;
-
-            draw_box_width(im, left, top, right, bot, width, red, green, blue);
-        }
-    }
-}
+image voc_labels[20];
 
 void train_yolo(char *cfgfile, char *weightfile)
 {
@@ -288,9 +255,8 @@
     int i=0;
 
     float thresh = .001;
-    int nms = 0;
     float iou_thresh = .5;
-    float nms_thresh = .5;
+    float nms = 0;
 
     int total = 0;
     int correct = 0;
@@ -304,7 +270,7 @@
         char *id = basecfg(path);
         float *predictions = network_predict(net, sized.data);
         convert_yolo_detections(predictions, classes, l.n, square, side, 1, 1, thresh, probs, boxes, 1);
-        if (nms) do_nms(boxes, probs, side*side*l.n, 1, nms_thresh);
+        if (nms) do_nms(boxes, probs, side*side*l.n, 1, nms);
 
         char *labelpath = find_replace(path, "images", "labels");
         labelpath = find_replace(labelpath, "JPEGImages", "labels");
@@ -377,7 +343,7 @@
         printf("%s: Predicted in %f seconds.\n", input, sec(clock()-time));
         convert_yolo_detections(predictions, l.classes, l.n, l.sqrt, l.side, 1, 1, thresh, probs, boxes, 0);
         if (nms) do_nms_sort(boxes, probs, l.side*l.side*l.n, l.classes, nms);
-        draw_yolo(im, l.side*l.side*l.n, thresh, boxes, probs);
+        draw_detections(im, l.side*l.side*l.n, thresh, boxes, probs, voc_names, voc_labels, 20);
         show_image(im, "predictions");
 
         show_image(sized, "resized");
@@ -437,6 +403,13 @@
 
 void run_yolo(int argc, char **argv)
 {
+    int i;
+    for(i = 0; i < 20; ++i){
+        char buff[256];
+        sprintf(buff, "data/labels/%s.png", voc_names[i]);
+        voc_labels[i] = load_image_color(buff, 0, 0);
+    }
+
     float thresh = find_float_arg(argc, argv, "-thresh", .2);
     int cam_index = find_int_arg(argc, argv, "-c", 0);
     if(argc < 4){

--
Gitblit v1.10.0