python - ImageDataGenerator 没有将实际输出保存到磁盘
问题描述
我有一组结构如下的图像训练:
path = /aug-dir/img_dir
1.jpg
2.jpg
...jpg
我正在尝试扩充图像并将它们保存到磁盘以供将来使用。我想实现以下代码:
## I want to do only mobilenet.preprocess_input and no other data augmentation
datagen = ImageDataGenerator(preprocessing_function=tensorflow.keras.applications.mobilenet.preprocess_input)
aug_datagen_test = datagen.flow_from_directory(path,
save_to_dir=save_path, ### want to save the images to save_path
save_format='jpg',
target_size=(image_size,image_size),
batch_size=1,
shuffle = False)
当我生成图像时,preprocessing_function(即mobilenet.preprocess_input)被正确应用并且我得到了正确的结果。
for i in range(11):
imgs, labels = next(aug_datagen_test)
plt.figure(figsize=(10,5))
plt.subplot(1,2,1)
plt.imshow(orginal_image)
plt.title('Original_image')
plt.subplot(1,2,2)
plt.imshow(imgs[0])
plt.title('output from ImageDataGenerator')
plt.show()
但是“ImageDataGenerator 的输出”(实际输出)图像未保存在 save_path 中。这就是数据增强后图像在 save_path 中的保存方式。
难道我做错了什么?为什么正确的输出没有保存到磁盘?
如果需要任何进一步的细节,请告诉我。
注意:我从 datagen.flow 得到相同的输出,即图像未正确保存。
任何帮助或建议表示赞赏。
非常感谢
解决方案
推荐阅读
- r - 为 r 中的生存分析生成数据
- rest - POST、PUT 和 DELETE 请求出现 CORS 错误,但 GET 工作正常
- apache-kafka - 如何将kafka主题数据存储到cassandra中
- reactjs - ReactJS - Internet Explorer 在每次刷新时提示停留/离开页面
- json - 如何在 Flutter 内部的 url 中包含变量
- python - 正则表达式 - 从列表中搜索没有尾随的连续元素并开始空格
- seaborn - Seaborn kdeplot 颜色条
- java - 盈透证券 java api,Eclient::reqOpenOrders 不工作
- discord.js - discord.js 在尝试踢自己时显示特定消息
- java - 使用弹簧管理线程创建弹簧线程池