!661 fix imagenet to mindrecord fail when the pic size is 0

Merge pull request !661 from guozhijian/fix_imagenet_to_mindrecord_fail
This commit is contained in:
mindspore-ci-bot 2020-04-24 18:59:55 +08:00 committed by Gitee
commit e8172b3e8f
1 changed files with 3 additions and 0 deletions

View File

@ -111,6 +111,9 @@ class ImageNetToMR:
image_file = open(file_name, "rb") image_file = open(file_name, "rb")
image_bytes = image_file.read() image_bytes = image_file.read()
image_file.close() image_file.close()
if not image_bytes:
logger.warning("The image file: {} is invalid.".format(file_name))
continue
data["data"] = image_bytes data["data"] = image_bytes
yield data yield data