I'm trying to classify rooftop sky images orientations, whether it is horizontal or vertical. Knowing that the most obvious feature here is known: orientation. I can simply augment each class by rotating it 90° so it belongs to the other class. It is like dynamic augmentation to different classes.

Using keras image classification capabilities, obviously defeats the purpose:

datagen = ImageDataGenerator(
        zoom_range=0.2, # randomly zoom into images
#       rotation_range=90,  # mistaken the model
        horizontal_flip=True,  # randomly flip images
        vertical_flip=False)  # randomly flip images

I am using keras for classification but open to other libraries, and techniques other than deep learning.

  • $\begingroup$ So, basically, you can use any other augmentation provided in keras ImageDataGenerator instead of rotation? You could use rotation_range with a small value, like up to 10 degrees ... $\endgroup$ Dec 17, 2018 at 13:05
  • $\begingroup$ Other data augmentation techniques provided in ImageDataGenerator should not result in a class change. $\endgroup$ Dec 17, 2018 at 13:08
  • $\begingroup$ that's what I'm emphasizing. I want to augment data in an aware way to other classes. In my case, augmenting each class (horizontal and vertical) by rotation of 90° to the other opposite labeled class. how could I achieve this ? $\endgroup$
    – bacloud14
    Dec 17, 2018 at 21:09

1 Answer 1


You could rotate images manually (without using ImageDataGenerator) and save it to disk. That way you would know which images you have rotated - so you would know which images have changed the class.

After it, when using ImageDataGenerator, you need to set rotation_range to small value in order to be sure that it won't change the classes of images.

Examples how to rotate image manually can be found here: https://stackoverflow.com/a/43864937/5997950


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.