From fa42eb2fa2de36e98f67a6b66fd81c732bddbb43 Mon Sep 17 00:00:00 2001 From: Evan Shelhamer Date: Sun, 28 Feb 2016 11:51:52 -0800 Subject: [PATCH] [pycaffe] align coord_map and #3570 Crop layer - crop -> offset - adjust crop axis by 1 --- python/caffe/coord_map.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/python/caffe/coord_map.py b/python/caffe/coord_map.py index 884d9070576..a3413cfa855 100644 --- a/python/caffe/coord_map.py +++ b/python/caffe/coord_map.py @@ -73,6 +73,7 @@ def coord_map(fn): return None, 1, 0 elif fn.type_name == 'Crop': axis, offset = crop_params(fn) + axis -= 1 # -1 for last non-coordinate dim. return axis, 1, - offset else: raise UndefinedMapException @@ -176,9 +177,9 @@ def crop(top_from, top_to): """ ax, a, b = coord_map_from_to(top_from, top_to) assert (a == 1).all(), 'scale mismatch on crop (a = {})'.format(a) - assert (b <= 0).all(), 'cannot crop negative width (b = {})'.format(b) - assert (np.round(b) == b).all(), 'cannot crop noninteger width ' \ + assert (b <= 0).all(), 'cannot crop negative offset (b = {})'.format(b) + assert (np.round(b) == b).all(), 'cannot crop noninteger offset ' \ '(b = {})'.format(b) return L.Crop(top_from, top_to, - crop_param=dict(axis=ax, - crop=list(-np.round(b).astype(int)))) + crop_param=dict(axis=ax + 1, # +1 for first cropping dim. + offset=list(-np.round(b).astype(int))))