SamAtWork
SamAtWork

Reputation: 465

Can't import apply_transform from keras.preprocessing.image

I have been having issues importing apply_transform from keras.preprocessing.image. As far as I know the name has not changed according to Keras documentation. Anyone has any idea what might be the issue. I can, from the same library, import ImageDataGenerator for instance.

enter image description here

Upvotes: 3

Views: 6242

Answers (1)

today
today

Reputation: 33470

apply_transform has been removed from image module and has been refactored as one of the methods of ImageDataGenerator class. Instead you can define an instance of ImageDataGenerator class and use it:

from keras.preprocessing.image import ImageDataGenerator

img_gen = ImageDataGenerator()
img_gen.apply_transform(args)

or you can use apply_affine_transform() method from keras.preprocessing.image module if it satisfies your needs.

And I think you are right. The documentation is wrong about this:

keras.preprocessing.image.apply_transform(x, transform_parameters)

whereas it should be:

apply_transform(x, transform_parameters)

Upvotes: 5

Related Questions