From 989ab8c38a02fa7ea9c25108151736c62e81c972 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Fri, 24 Apr 2015 17:27:50 +0000
Subject: [PATCH] IOU loss function

---
 src/crop_layer.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/src/crop_layer.c b/src/crop_layer.c
index 819b754..7ae4aa5 100644
--- a/src/crop_layer.c
+++ b/src/crop_layer.c
@@ -10,7 +10,7 @@
     return float_to_image(w,h,c,layer.output);
 }
 
-crop_layer *make_crop_layer(int batch, int h, int w, int c, int crop_height, int crop_width, int flip)
+crop_layer *make_crop_layer(int batch, int h, int w, int c, int crop_height, int crop_width, int flip, float angle, float saturation, float exposure)
 {
     fprintf(stderr, "Crop Layer: %d x %d -> %d x %d x %d image\n", h,w,crop_height,crop_width,c);
     crop_layer *layer = calloc(1, sizeof(crop_layer));
@@ -19,11 +19,15 @@
     layer->w = w;
     layer->c = c;
     layer->flip = flip;
+    layer->angle = angle;
+    layer->saturation = saturation;
+    layer->exposure = exposure;
     layer->crop_width = crop_width;
     layer->crop_height = crop_height;
     layer->output = calloc(crop_width*crop_height * c*batch, sizeof(float));
     #ifdef GPU
     layer->output_gpu = cuda_make_array(layer->output, crop_width*crop_height*c*batch);
+    layer->rand_gpu = cuda_make_array(0, layer->batch*8);
     #endif
     return layer;
 }
@@ -36,6 +40,8 @@
     int flip = (layer.flip && rand()%2);
     int dh = rand()%(layer.h - layer.crop_height + 1);
     int dw = rand()%(layer.w - layer.crop_width + 1);
+    float scale = 2;
+    float trans = -1;
     if(!state.train){
         flip = 0;
         dh = (layer.h - layer.crop_height)/2;
@@ -52,7 +58,7 @@
                     }
                     row = i + dh;
                     index = col+layer.w*(row+layer.h*(c + layer.c*b)); 
-                    layer.output[count++] = state.input[index];
+                    layer.output[count++] = state.input[index]*scale + trans;
                 }
             }
         }

--
Gitblit v1.10.0