!1806 Add crop size check to python RandomCrop op

Merge pull request !1806 from Tinazhang/random-crop-error-msg
pull/1806/MERGE
mindspore-ci-bot 5 years ago committed by Gitee
commit bc7a3a1bef

@ -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

@ -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():
"""

Loading…
Cancel
Save