From 60f415832d5491c65b7d5c18623c633217b232ed Mon Sep 17 00:00:00 2001 From: cjliux Date: Tue, 4 Jul 2017 17:39:57 +0800 Subject: [PATCH] fix bug in python/caffe/detector.py: unrounded index value will cause error. --- python/caffe/detector.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/python/caffe/detector.py b/python/caffe/detector.py index 489213e76..d30b1d1f1 100755 --- a/python/caffe/detector.py +++ b/python/caffe/detector.py @@ -173,6 +173,7 @@ def crop(self, im, window): crop: cropped window. """ # Crop window from the image. + window = np.round(window).astype(np.int) crop = im[window[0]:window[2], window[1]:window[3]] if self.context_pad: @@ -207,10 +208,11 @@ def crop(self, im, window): # collect with context padding and place in input # with mean padding + box = np.round(box).astype(np.int) context_crop = im[box[0]:box[2], box[1]:box[3]] context_crop = caffe.io.resize_image(context_crop, (crop_h, crop_w)) crop = np.ones(self.crop_dims, dtype=np.float32) * self.crop_mean - crop[pad_y:(pad_y + crop_h), pad_x:(pad_x + crop_w)] = context_crop + crop[int(pad_y):int(pad_y + crop_h), int(pad_x):int(pad_x + crop_w)] = context_crop return crop