解决 AttributeError: 'keras.preprocessing.image' has no attribute 'load_img' 错误
这个错误是因为 'keras.preprocessing.image' 模块中没有 'load_img' 这个属性。这可能是因为你使用的是较老版本的 Keras,'load_img' 在较新的版本中已经被移除了。
解决方法是更新 Keras 到最新版本,可以通过以下命令来更新 Keras:
!pip install --upgrade keras
如果你正在使用 TensorFlow 2.0 或更高版本,可以使用 'tf.keras' 模块代替 'keras' 模块,这样就可以使用 'load_img' 函数了。
更新 Keras 后,重新运行代码应该就不会出现这个错误了。
原文地址: https://www.cveoy.top/t/topic/ph8t 著作权归作者所有。请勿转载和采集!