【发布时间】:2026-01-26 02:35:01
【问题描述】:
我正在尝试遍历图像以执行数据增强。为此,我使用以下内容:
from keras.preprocessing import image
from keras.preprocessing.image import ImageDataGenerator
from skimage import io
gen = ImageDataGenerator(rotation_range=10, width_shift_range=0.1,
height_shift_range=0.1, shear_range=0.15,
zoom_range=0.1, channel_shift_range=10., horizontal_flip=True,
fill_mode='nearest')
image_path = r'X:\Users\my_path'
os.chdir(image_path)
for img in os.listdir(image_path):
if img.endswith(".jpg"):
image = io.imread(img, plugin='matplotlib')
image = image.reshape((1, ) + image.shape)
i = 0
for batch in gen.flow(image, batch_size=16,
save_to_dir=image_path,
save_prefix='aug',
save_format='jpg'):
i += 1
if i > 5:
break
但由于某种原因,我收到一条错误消息:UnidentifiedImageError: cannot identify image file '36.jpg'
但 36.jpg 存在,具有完全相同的标题和扩展名。
问题的原因是什么?
提前谢谢你。
【问题讨论】:
-
目录中的两个文件存在一些未知问题。不知道他们有什么问题。
标签: python-3.x image io data-augmentation