Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Fix a bug in scale #279

Merged
merged 2 commits into from
Jun 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions chainercv/transforms/image/scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ def scale(img, size, fit_short=True):
_, H, W = img.shape

# If resizing is not necessary, return the input as is.
if fit_short and (H <= W and H == size) or (W <= H and W == size):
if fit_short and ((H <= W and H == size) or (W <= H and W == size)):
return img
if not fit_short and (H >= W and H == size) or (W >= H and W == size):
if not fit_short and ((H >= W and H == size) or (W >= H and W == size)):
return img

if fit_short:
Expand Down
4 changes: 4 additions & 0 deletions tests/transforms_tests/image_tests/test_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,14 @@
'fit_short': True, 'out_shape': (3, 12, 8)},
{'in_shape': (3, 16, 24), 'size': 8,
'fit_short': True, 'out_shape': (3, 8, 12)},
{'in_shape': (3, 16, 24), 'size': 24,
'fit_short': True, 'out_shape': (3, 24, 36)},
{'in_shape': (3, 24, 16), 'size': 36,
'fit_short': False, 'out_shape': (3, 36, 24)},
{'in_shape': (3, 16, 24), 'size': 36,
'fit_short': False, 'out_shape': (3, 24, 36)},
{'in_shape': (3, 24, 12), 'size': 12,
'fit_short': False, 'out_shape': (3, 12, 6)},
# grayscale
{'in_shape': (1, 16, 24), 'size': 8,
'fit_short': True, 'out_shape': (1, 8, 12)},
Expand Down