From c53e03348c65462bcba33f6352087dd6b9268e8f Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Wed, 16 Sep 2015 21:12:10 +0000
Subject: [PATCH] yolo working w/ regions

---
 src/parser.c |   41 +++++++++++++++++++++++++++++++++++++----
 1 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/src/parser.c b/src/parser.c
index b9f6cb6..53e8461 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -169,7 +169,7 @@
     int rescore = option_find_int(options, "rescore", 0);
     int joint = option_find_int(options, "joint", 0);
     int objectness = option_find_int(options, "objectness", 0);
-    int background = 0;
+    int background = option_find_int(options, "background", 0);
     detection_layer layer = make_detection_layer(params.batch, params.inputs, classes, coords, joint, rescore, background, objectness);
     return layer;
 }
@@ -182,6 +182,10 @@
     int num = option_find_int(options, "num", 1);
     int side = option_find_int(options, "side", 7);
     region_layer layer = make_region_layer(params.batch, params.inputs, num, side, classes, coords, rescore);
+    int softmax = option_find_int(options, "softmax", 0);
+    int sqrt = option_find_int(options, "sqrt", 0);
+    layer.softmax = softmax;
+    layer.sqrt = sqrt;
     return layer;
 }
 
@@ -312,6 +316,8 @@
     if (strcmp(s, "constant")==0) return CONSTANT;
     if (strcmp(s, "step")==0) return STEP;
     if (strcmp(s, "exp")==0) return EXP;
+    if (strcmp(s, "sigmoid")==0) return SIG;
+    if (strcmp(s, "steps")==0) return STEPS;
     fprintf(stderr, "Couldn't find policy %s, going with constant\n", s);
     return CONSTANT;
 }
@@ -337,9 +343,36 @@
     net->policy = get_policy(policy_s);
     if(net->policy == STEP){
         net->step = option_find_int(options, "step", 1);
-        net->gamma = option_find_float(options, "gamma", 1);
+        net->scale = option_find_float(options, "scale", 1);
+    } else if (net->policy == STEPS){
+        char *l = option_find(options, "steps");   
+        char *p = option_find(options, "scales");   
+        if(!l || !p) error("STEPS policy must have steps and scales in cfg file");
+
+        int len = strlen(l);
+        int n = 1;
+        int i;
+        for(i = 0; i < len; ++i){
+            if (l[i] == ',') ++n;
+        }
+        int *steps = calloc(n, sizeof(int));
+        float *scales = calloc(n, sizeof(float));
+        for(i = 0; i < n; ++i){
+            int step    = atoi(l);
+            float scale = atof(p);
+            l = strchr(l, ',')+1;
+            p = strchr(p, ',')+1;
+            steps[i] = step;
+            scales[i] = scale;
+        }
+        net->scales = scales;
+        net->steps = steps;
+        net->num_steps = n;
     } else if (net->policy == EXP){
         net->gamma = option_find_float(options, "gamma", 1);
+    } else if (net->policy == SIG){
+        net->gamma = option_find_float(options, "gamma", 1);
+        net->step = option_find_int(options, "step", 1);
     } else if (net->policy == POLY){
         net->power = option_find_float(options, "power", 1);
     }
@@ -401,10 +434,10 @@
             l = parse_dropout(options, params);
             l.output = net.layers[count-1].output;
             l.delta = net.layers[count-1].delta;
-            #ifdef GPU
+#ifdef GPU
             l.output_gpu = net.layers[count-1].output_gpu;
             l.delta_gpu = net.layers[count-1].delta_gpu;
-            #endif
+#endif
         }else{
             fprintf(stderr, "Type not recognized: %s\n", s->type);
         }

--
Gitblit v1.10.0