python - 如何只增加每个图像一次并将其保存在目录中?
问题描述
我只想将每个图像增强一次并将其保存在目录中但是当我使用此代码时,生成和保存的图像的数量每次都会改变,我不知道为什么。你能帮忙吗?
datagen = ImageDataGenerator(
rotation_range=10,
shear_range=0.2,
zoom_range=0.2,
horizontal_flip=True,
fill_mode='nearest',
width_shift_range=0.1,
height_shift_range=0.1)
from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img
for f in aug_create_df['image_name']:
img = load_img(merged_datapath + f)
x = img_to_array(img)
x = x.reshape((1, ) + x.shape)
i = 0
for batch in train_datagen.flow(x, batch_size = 1,
save_to_dir = augmented_pics_path,
save_prefix='aug',
save_format ='jpg'):
i += 1
if i > 0:
break
解决方案
推荐阅读
- sql - Postgresql 按数组重叠排序
- datatable - antd Table在datasource数据发生变化时不会自动重新渲染
- python-3.x - wsgi 在 weblate + apache2 + wsgi 设置中找不到 virtualenv 中的模块
- java - 这两种创建 TreeMap(或任何地图)的方式有什么区别?
- java - 从 JavaFX 1.8 迁移到 Java 11 + JavaFX 和 Maven
- mailchimp - 名称:'MissingSchemaError'
- html - CSS - 如何获得可变宽度
- 在我的垂直导航菜单中
- 在我的垂直导航菜单中
- python - 删除字符串中重复的字符集 - Python
- javascript - Sequelize ORM - 使用多键更新多对多表
- linux - sed 在一行中更改未知字符串,其余部分保持不变