<p dir="auto"><a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/fchollet/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/fchollet">@fchollet</a><br>
We know that ImageDataGenerator provides a way for image data augmentation: <code class="notranslate">ImageDataGenerator.flow(X, Y)</code>. Now consider the image segmentation task where <code class="notranslate">Y</code> is not a categorical label but a image mask which is the same size as input <code class="notranslate">X</code>, e.g. 256x256 pixels. If we would like to use data augmentation, the same transformation should also be adopted to <code class="notranslate">Y</code>. Is there any simple way to handle this?</p>
<p dir="auto">Please make sure that the boxes below are checked before you submit your issue. If your issue is an implementation question, please ask your question on <a href="http://stackoverflow.com/questions/tagged/keras" rel="nofollow">StackOverflow</a> or <a href="https://keras-slack-autojoin.herokuapp.com/" rel="nofollow">join the Keras Slack channel</a> and ask there instead of filing a GitHub issue.</p>
<p dir="auto">Thank you!</p>
<ul class="contains-task-list">
<li>
<p dir="auto">[ x] Check that you are up-to-date with the master branch of Keras. You can update with:<br>
pip install git+git://github.com/fchollet/keras.git --upgrade --no-deps</p>
</li>
<li>
<p dir="auto">[x ] If running on TensorFlow, check that you are up-to-date with the latest version. The installation instructions can be found <a href="https://www.tensorflow.org/get_started/os_setup" rel="nofollow">here</a>.</p>
</li>
<li class="task-list-item">
<p dir="auto"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> If running on Theano, check that you are up-to-date with the master branch of Theano. You can update with:<br>
pip install git+git://github.com/Theano/Theano.git --upgrade --no-deps</p>
</li>
<li class="task-list-item">
<p dir="auto"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> Provide a link to a GitHub Gist of a Python script that can reproduce your issue (or just copy the script here if it is short)</p>
</li>
</ul>
<p dir="auto">Below is my simple code to use ImageDataGenerator to do some data augmentation. Let's say I have 1000 input cat images, I want to use ImageDataGenerator to augment each image 20 times, so totally I should get 1000*20 = 20,000 augmented images. However, the following code only produces &lt; 10,000 files. The output files have a 'cat_0_xxxx.jpeg' pattern in filenames where xxxx goes from  0 to 9999, does that mean ImageDataGenerator won't go beyond 10,000 files? I would expect it will save 'cat_1_xxxx.jpeg" after saving cat_0_9999.jpeg but that did not happen. Is this a bug?</p>
<p dir="auto">BTW, I installed Keras using pip: pip install keras, the installed version is keras-2.0.6.tar.gz.</p>
<p dir="auto">from keras.preprocessing.image import ImageDataGenerator, array_to_img, img_to_array, load_img<br>
import glob<br>
import os, sys</p>
<p dir="auto">datagen = ImageDataGenerator(<br>
rotation_range=40,<br>
width_shift_range=0.2,<br>
height_shift_range=0.2,<br>
shear_range=0.2,<br>
zoom_range=0.2,<br>
horizontal_flip=True,<br>
fill_mode='nearest')</p>
<p dir="auto">path = 'test20170721/train/cats'<br>
outPath = 'test20170721/augmentation/cats'<br>
files = glob.glob(path + '/*.jpg')</p>
<p dir="auto">for file in files:<br>
print file<br>
img = load_img(file)<br>
x = img_to_array(img)<br>
x = x.reshape((1,) + x.shape)</p>
<p dir="auto">i = 0<br>
for batch in datagen.flow(x, save_to_dir=outPath, save_prefix='cat', save_format='jpeg'):<br>
i += 1<br>
if i &gt; 20:<br>
break</p>