From 54d761cf9efa6c77e96855ea80156b0fcd81195d Mon Sep 17 00:00:00 2001
From: Joseph Redmon <pjreddie@gmail.com>
Date: Tue, 22 Sep 2015 22:40:15 +0000
Subject: [PATCH] resize image width 1 ><

---
 src/crop_layer_kernels.cu |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/crop_layer_kernels.cu b/src/crop_layer_kernels.cu
index 98d1ef4..fc7fcbd 100644
--- a/src/crop_layer_kernels.cu
+++ b/src/crop_layer_kernels.cu
@@ -5,8 +5,6 @@
 #include "image.h"
 }
 
-#define BLOCK 256
-
 __device__ float get_pixel_kernel(float *image, int w, int h, int x, int y, int c)
 {
     if(x < 0 || x >= w || y < 0 || y >= h) return 0;
@@ -78,7 +76,7 @@
     return make_float3(r, g, b);
 }
 
-__device__ float billinear_interpolate_kernel(float *image, int w, int h, float x, float y, int c)
+__device__ float bilinear_interpolate_kernel(float *image, int w, int h, float x, float y, int c)
 {
     int ix = (int) floorf(x);
     int iy = (int) floorf(y);
@@ -114,9 +112,9 @@
 
     size_t offset = id * h * w * 3;
     image += offset;
-    float r = image[x + w*(y + h*2)];
+    float r = image[x + w*(y + h*0)];
     float g = image[x + w*(y + h*1)];
-    float b = image[x + w*(y + h*0)];
+    float b = image[x + w*(y + h*2)];
     float3 rgb = make_float3(r,g,b);
     if(train){
         float3 hsv = rgb_to_hsv_kernel(rgb);
@@ -124,9 +122,9 @@
         hsv.z *= exposure;
         rgb = hsv_to_rgb_kernel(hsv);
     }
-    image[x + w*(y + h*2)] = rgb.x*scale + translate;
+    image[x + w*(y + h*0)] = rgb.x*scale + translate;
     image[x + w*(y + h*1)] = rgb.y*scale + translate;
-    image[x + w*(y + h*0)] = rgb.z*scale + translate;
+    image[x + w*(y + h*2)] = rgb.z*scale + translate;
 }
 
 __global__ void forward_crop_layer_kernel(float *input, float *rand, int size, int c, int h, int w, int crop_height, int crop_width, int train, int flip, float angle, float *output)
@@ -170,7 +168,7 @@
     float rx = cos(angle)*(x-cx) - sin(angle)*(y-cy) + cx;
     float ry = sin(angle)*(x-cx) + cos(angle)*(y-cy) + cy;
 
-    output[count] = billinear_interpolate_kernel(input, w, h, rx, ry, k);
+    output[count] = bilinear_interpolate_kernel(input, w, h, rx, ry, k);
 }
 
 extern "C" void forward_crop_layer_gpu(crop_layer layer, network_state state)
@@ -181,6 +179,10 @@
 
     float scale = 2;
     float translate = -1;
+    if(layer.noadjust){
+        scale = 1;
+        translate = 0;
+    }
 
     int size = layer.batch * layer.w * layer.h;
 

--
Gitblit v1.10.0