!1806 Add crop size check to python RandomCrop op

Merge pull request !1806 from Tinazhang/random-crop-error-msg
This commit is contained in:
mindspore-ci-bot 2020-06-03 23:28:22 +08:00 committed by Gitee
commit bc7a3a1bef
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():
"""