raise IOError(message + " when reading image file");
IOError: broken data stream when reading image file;
raise IOError(message + " when reading image file"); IOError: broken data stream when reading image file;
解决办法
> 我换成别的数据集,图片可以正常读取,因此数据集图片本身受损,更换数据集图片。可以挑出受损的图片,前提损坏的图片不多。
还可以添加一行代码解决:
from PIL import Image, ImageFile ImageFile.LOAD_TRUNCATED_IMAGES = True
放在读取数据集的相关代码前面。这样在遇到受损图片时,程序就会跳过去,读取另一张图片,太智能了!



