英文:
Why I can't import this module?
问题
I'm trying to import img_to_array
even though all packages are there. This error still appears:
Traceback (most recent call last):
File "c:\Users\Usuario\Downloads\keras-api\keras-main.py", line 11, in <module> from keras.preprocessing.image import img_to_array
ImportError: cannot import name 'img_to_array' from 'keras.preprocessing.image'
This is how I am calling the packages from the keras
package.
from keras.preprocessing.image import img_to_array
On the other hand, this is what I'm trying to do with the code.
image = img_to_array(image)
However, I cannot even continue because I'm not able to import img_to_array
英文:
I'm trying to import img_to_array
even though all packages are there. This error still appears:
Traceback (most recent call last):
File "c:\Users\Usuario\Downloads\keras-api\keras-main.py", line 11, in <module> from keras.preprocessing.image import img_to_array
ImportError: cannot import name 'img_to_array' from 'keras.preprocessing.image'
This is how I am calling the packages from the keras
package.
from keras.preprocessing.image import img_to_array
On the other hand, this is what I'm trying to do with the code.
image = img_to_array(image)
However, I cannot even continue because I'm not able to import img_to_array
答案1
得分: 1
以下是翻译好的部分:
但是如果你已经通过pip install keras
等方式安装了keras
包,这是如何导入img_to_array
的方法:
from keras.utils import img_to_array
img_to_array
检查keras
的版本是否正确:
Keras安装指南
英文:
but this is how you import img_to_array
if you have installed the keras
package via e.g. pip install keras
from keras.utils import img_to_array
img_to_array
check if the keras
version is the correct one:
Keras Installation Guide
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论