为什么我无法导入这个模块?

huangapple go评论51阅读模式
英文:

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 &quot;c:\Users\Usuario\Downloads\keras-api\keras-main.py&quot;, line 11, in &lt;module&gt; from keras.preprocessing.image import img_to_array 

ImportError: cannot import name &#39;img_to_array&#39; from &#39;keras.preprocessing.image&#39;

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

huangapple
  • 本文由 发表于 2023年2月19日 12:42:07
  • 转载请务必保留本文链接:https://go.coder-hub.com/75498045.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定