【发布时间】:2019-05-30 05:59:22
【问题描述】:
我想运行 tensorflow 进行图像识别。我已经按照它的所有步骤进行操作,并且 keras 和 tensorflow 都安装在我的计算机上。 这篇文章中的步骤:https://github.com/OlafenwaMoses/ImageAI/ 但是当我尝试时: 从 imageai.Prediction 导入 ImagePrediction
我不断收到错误消息: 从 tensorflow.python.keras.preprocessing 导入图像 ModuleNotFoundError:没有名为“tensorflow.python.keras”的模块
我认为错误来自我安装的“tensorflow”。当我尝试该方法时: pip3 install --upgrade tensorflow 我得到了错误: 找不到满足要求 tensorflow 的版本(来自版本:) 没有找到 tensorflow 的匹配分布
所以我改用: python3 -m pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.12.0-py3-none-any.whl
我从这个帖子中得到它:TensorFlow not found using pip
我的猜测是第一个错误将我推到第二个错误,但我不知道如何修复它们中的任何一个。
有什么建议吗?
我的代码直到问题是:
导入张量流
从 imageai.Prediction 导入 ImagePrediction
【问题讨论】:
-
那个版本的TensorFlow没有Keras,太旧了,至少要安装TensorFlow 1.0
-
你能不能试试pip3 install tensorflow==2.1,如果安装成功再试试“import tensorflow as tf”。然后将图像导入为“从 tensorflow.keras.preprocessing 导入图像:”。一个建议是请不要使用“from tensorflow.python.*”,因为它是 tensorflow 私有的,可能会更改或影响其他导入的模块。
标签: python tensorflow keras