keras picture enhancement batch builder ImageDataGenerator

keras picture enhancement batch builder ImageDataGenerator

Batches of image rotation is increased, reduction or the like operation to generate a new image
assumes that the directory is as follows:
├── train_gen
└── train_org
└── sheep
└── 0.jpg
train_org raw data, as sheep tab subdirectories (Note that the source directory must have a subdirectory as a label, namely y), 0.jpg input data (ie train_x). Volume generated images to train_gen / under
Here Insert Picture Description
python code

from keras.preprocessing import image

srcPath='/home/zm/download/jpg/test_gen/train_org/'
dstPath='/home/zm/download/jpg/test_gen/train_gen/'

dataGen = image.ImageDataGenerator(rescale=1. / 255, rotation_range = 45, zoom_range = 0.5)
genData = dataGen.flow_from_directory(srcPath, batch_size=1, shuffle=False, save_to_dir=dstPath,
                                       save_prefix='gen', target_size=(224, 224))

for i in range(5):
    genData.next()

Execution
python3 ./img_gen.py
output
the Using TensorFlow backend.
Found 1 ImagesRF Royalty Free Belonging to 1 classes.

Change file into the following
├── train_gen
│ ├── gen_0_1566435.png
│ ├── gen_0_2240910.png
│ ├── gen_0_4362670.png
│ ├── gen_0_6886943.png
│ └── gen_0_9432471.png
└── train_org
└── Sheep
└── 0.jpg
Here Insert Picture Description
author: handsome too afraid to go c ++ Haha Church: 31,843,264

Guess you like

Origin blog.csdn.net/zmlovelx/article/details/93916043