fix error handling for bigger crop size case

This commit is contained in:
Tinazhang 2020-06-02 10:08:22 -04:00 committed by tinazhang
parent 5cba231ba9
commit 33fe66fd1e
2 changed files with 4 additions and 0 deletions

View File

@ -455,6 +455,9 @@ def random_crop(img, size, padding, pad_if_needed, fill_value, padding_mode):
def _input_to_factor(img, size):
img_width, img_height = img.size
height, width = size
if height > img_height or width > img_width:
raise ValueError("Crop size {} is larger than input image size {}".format(size, (img_height, img_width)))
if width == img_width and height == img_height:
return 0, 0, img_height, img_width

View File

@ -280,6 +280,7 @@ def test_random_crop_04_py():
data.create_dict_iterator().get_next()
except RuntimeError as e:
logger.info("Got an exception in DE: {}".format(str(e)))
assert "Crop size" in str(e)
def test_random_crop_05_c():
"""