Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 531
SamAtWork Avatar asked Sep 08 '26 13:09

SamAtWork


1 Answers

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)

like image 122
today Avatar answered Sep 11 '26 02:09

today



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!