提交 bc7a3a1b 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!1806 Add crop size check to python RandomCrop op

Merge pull request !1806 from Tinazhang/random-crop-error-msg
......@@ -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():
"""
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册