【发布时间】:2022-01-13 23:45:10
【问题描述】:
我正在理解使用 Keras 进行图像分类。 有一个函数叫做图像数据生成器,用于准备要处理的图像。
train_batches = ImageDataGenerator(preprocessing_function=tf.keras.applications.vgg16.preprocess_input) \
.flow_from_directory(directory=train_path, target_size=(224,224), classes=['cat', 'dog'], batch_size=10)
imgs, labels = next(train_batches)
然后我调用这个函数来检查图像
plt.imshow(imgs[0])
它给了我原始图像的脱色和调整大小的版本。
但是,当我尝试这个时:-
train_batches = ImageDataGenerator(preprocessing_function=None) \
.flow_from_directory(directory=train_path, target_size=(224,224), classes=['cat', 'dog'], batch_size=10)
或
train_batches = ImageDataGenerator() \
.flow_from_directory(directory=train_path, target_size=(224,224), classes=['cat', 'dog'], batch_size=10)
然后它给了空白。
对于某些图像,我可以看到模糊的轮廓,但看不到图像本身。
理想情况下,它应该给出原始图像(调整大小)对吗?因为不涉及预处理?
谁能告诉我如何从目录迭代器中获取原始图像?
【问题讨论】:
标签: python tensorflow image-processing keras