load images for Auto-enncoder with keras ImageDataGenerator questions

Viewed 20

dear community. I have a dataset folder split into X and Y that are meant to be fed to an Auto-encoder The X is the modified version of the Y, which means that the model should learn to turn X into Y I loaded X and Y with the following code

X = []
for i in tqdm(glob.glob("data/X/*.jpg")):
    im = cv2.imread(i)
    im = img_to_array(im)
    X.append(im)
    #X.append(cv2.flip(im, 0))
    #X.append(cv2.flip(im, 1))
    #X.append(cv2.flip(im, -1))
    
print(len(X))
X = np.array(X, dtype="float32")/255
Y = []
for i in tqdm(glob.glob("data/Y/*.jpg")):
    im = cv2.imread(i)
    im = img_to_array(im)
    Y.append(im)
    #Y.append(cv2.flip(im, 0))
    #Y.append(cv2.flip(im, 1))
    #Y.append(cv2.flip(im, -1))
print(len(Y))
Y = np.array(Y, dtype="float32")/255

then I wanted to make some augmentations because I did not have a lot of images so I used Keras ImageDataGenerator

from tensorflow.keras.preprocessing.image import ImageDataGenerator

trainGen = ImageDataGenerator(
    vertical_flip=True
)
train = trainGen.flow(X, Y, batch_size=8)

my wonders are if the augmentations are also applied top the Y not only the X, if no how to do so please?

1 Answers

I think that it doesn't do augmentation for the Y only X try to do it manually in the for loop

cv2.flip(im, 0)

if there are more augmentations do them so check the OpenCV docs

Related