简体   繁体   English

Windows 上的 Tensorflow 对象检测 API - ImportError:没有名为“object_detection.utils”的模块; “object_detection”不是一个包

[英]Tensorflow Object Detection API on Windows - ImportError: No module named "object_detection.utils"; "object_detection" is not a package

I am using the tensorflow object detection api from https://github.com/tensorflow/models and I am trying to make an object detection program using open cv with tensorflow.我正在使用来自https://github.com/tensorflow/models的 tensorflow 对象检测 api,我正在尝试使用带有 tensorflow 的 open cv 制作对象检测程序。 When the code reaches at line 30 (see code below), the program will get an error and will print:当代码到达第 30 行时(见下面的代码),程序将出错并打印:

Traceback (most recent call last):追溯(最近一次通话):

File "C:\Users\xxx\Documents\models\research\object_detection\object_detection.py", line 31, in from object_detection.utils import ops as utils_ops文件“C:\Users\xxx\Documents\models\research\object_detection\object_detection.py”,第 31 行,在 from object_detection.utils import ops as utils_ops

File "C:\Users\xxx\Documents\models\research\object_detection\object_detection.py", line 31, in from object_detection.utils import ops as utils_ops文件“C:\Users\xxx\Documents\models\research\object_detection\object_detection.py”,第 31 行,在 from object_detection.utils import ops as utils_ops

ImportError: No module named 'object_detection.utils';导入错误:没有名为“object_detection.utils”的模块; 'object_detection' is not a package “object_detection”不是一个包

I tried the solutions that are in this link ( Tensorflow Object Detection API on Windows - error "ModuleNotFoundError: No module named 'utils'" ) step by step, but it still didn't work.我逐步尝试了此链接中的解决方案( Windows 上的 Tensorflow 对象检测 API - 错误“ModuleNotFoundError:没有名为‘utils’的模块” ),但它仍然没有用。 I don't know what should be targeted in order to solve this problem.我不知道应该针对什么来解决这个问题。 Also, I am not that familiar with machine learning, tensorflow, and opencv, I just start learning it now.另外,我对机器学习、tensorflow 和 opencv 不是很熟悉,我现在才开始学习。 Can anyone please help me with this?谁能帮我解决这个问题? Thanks in advance.提前致谢。

Btw, this is the part of the code where I got a problem with.顺便说一句,这是我遇到问题的代码部分。

# This is needed since the notebook is stored in the object_detection folder.
sys.path.append("..")
from object_detection.utils import ops as utils_ops

I tried the 'export path' method on python and the 'Develop' method for Conda but nothing worked.我在 python 上尝试了“导出路径”方法,在 Conda 上尝试了“开发”方法,但没有任何效果。 Finally tried installing this API and the tutorial worked.最后尝试安装此 API 并且教程有效。 Maybe I missed this step during the installation.也许我在安装过程中错过了这一步。 You try this too你也试试这个

pip install tensorflow-object-detection-api

I have followed below steps: For every new terminal, append PYTHONPATH as follows:我已按照以下步骤操作:对于每个新终端,按如下方式附加 PYTHONPATH:

export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim

from directory C:\Users\xxx\Documents\models\research从目录C:\Users\xxx\Documents\models\research

Else, add that particular line to ~/.bashrc file in order to avoid running for every new terminal.否则,将该特定行添加到~/.bashrc文件以避免为每个新终端运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM