我尝试用imageAI识别图像中的对象。我使用pycharm,windows 10 64位,python 3.6.8。当我尝试运行程序时出现错误:
ModuleNotFoundError:没有名为'tensorflow'的模块
它与这个字符串连接:import tensorflow as tf
我也可以发一张照片
from imageai.Detection import ObjectDetection
import os
exec_path = os.getcwd()
detector = ObjectDetection()
detector.setModelTypeAsRetinaNet()
detector.setModelPath(os.path.join(
exec_path, 'resnet50_coco_best_v2.0.1.h5')
)
detector.loadModel()
list = detector.detectObjectsFromImage(
input_image=os.path.join(exec_path, 'objects.jpg'),
output_image_path=os.os.path.join(exec_path, 'new_objects.jpg')
)
I have installed with pip tensorflow, pillow, numpy, matplotlib, h5py, keras, image ai, open_cv and scipy.
按Ctrl + Alt + S,然后检查是否已将tensorflow添加到项目中。只需单击项目:左侧的yourprojectname,然后您将看到活动模块列表。要添加新的,请单击右侧的加号按钮,找到tensorflow包。选择这一个只有名称,但张量流量。单击安装包并稍等片刻。
我对selenium包有同样的问题。我用pip安装它,但对于pycharm,使用它的经理是一个更好的主意。
当你使用pycharm时,它默认生成venv(virtual environment
),所以无论你是否在计算机上设置或安装张量流都没关系,你必须再次在你的VENV
上安装它。
您可以在IDE(Pycharm)底部使用Pycharm终端来确保激活VNEV
,然后填充张量流。
第二种方法是将它设置在pycharm Setting(qazxsw poi)上,然后在设置菜单中单击qazxsw poi,然后单击Project Interpreter。你可以在这里添加包