From 390a0cf923cee683e5be300390c736a2ab9b7fd5 Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Sat, 11 Apr 2015 08:24:07 +0000
Subject: [PATCH] not much changed...
---
src/crop_layer.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/crop_layer.c b/src/crop_layer.c
index df6eb41..819b754 100644
--- a/src/crop_layer.c
+++ b/src/crop_layer.c
@@ -7,7 +7,7 @@
int h = layer.crop_height;
int w = layer.crop_width;
int c = layer.c;
- return float_to_image(h,w,c,layer.output);
+ 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)
@@ -28,14 +28,19 @@
return layer;
}
-void forward_crop_layer(const crop_layer layer, float *input)
+void forward_crop_layer(const crop_layer layer, network_state state)
{
int i,j,c,b,row,col;
int index;
int count = 0;
int flip = (layer.flip && rand()%2);
- int dh = rand()%(layer.h - layer.crop_height);
- int dw = rand()%(layer.w - layer.crop_width);
+ int dh = rand()%(layer.h - layer.crop_height + 1);
+ int dw = rand()%(layer.w - layer.crop_width + 1);
+ if(!state.train){
+ flip = 0;
+ dh = (layer.h - layer.crop_height)/2;
+ dw = (layer.w - layer.crop_width)/2;
+ }
for(b = 0; b < layer.batch; ++b){
for(c = 0; c < layer.c; ++c){
for(i = 0; i < layer.crop_height; ++i){
@@ -47,7 +52,7 @@
}
row = i + dh;
index = col+layer.w*(row+layer.h*(c + layer.c*b));
- layer.output[count++] = input[index];
+ layer.output[count++] = state.input[index];
}
}
}
--
Gitblit v1.10.0