Can't import apply_transform from keras.preprocessing.image

我是研究僧i 提交于 2020-01-14 19:34:15

问题


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.


回答1:


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)



来源:https://stackoverflow.com/questions/51311062/cant-import-apply-transform-from-keras-preprocessing-image

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!