Skip to content

Commit

Permalink
[imgaug] check xrange==yrange only when using ratio (fix #628)
Browse files Browse the repository at this point in the history
  • Loading branch information
ppwwyyxx committed Feb 5, 2018
1 parent fe04987 commit 0e5299b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tensorpack/dataflow/imgaug/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,17 @@ def __init__(self, xrange, yrange, minimum=(0, 0), aspect_ratio_thres=0.15,
"""
super(RandomResize, self).__init__()
assert aspect_ratio_thres >= 0
if aspect_ratio_thres == 0:
assert xrange == yrange
self._init(locals())

def is_float(tp):
return isinstance(tp[0], float) or isinstance(tp[1], float)

assert is_float(xrange) == is_float(yrange), "xrange and yrange has different type!"
self._is_scale = is_float(xrange)

if self._is_scale and aspect_ratio_thres == 0:
assert xrange == yrange

def _get_augment_params(self, img):
cnt = 0
h, w = img.shape[:2]
Expand Down

2 comments on commit 0e5299b

@eyaler
Copy link
Contributor

@eyaler eyaler commented on 0e5299b Feb 5, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so now if aspect_ratio_thres == 0, yrange is completely ignored?

@ppwwyyxx
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When aspect_ratio_thres==0, you shouldn't be using yrange at all. I can add assert to that.

Please sign in to comment.