问题描述
我正在使用 https://github.com/tensorflow/models并且我正在尝试使用带有tensorflow的开放式cv制作对象检测程序.当代码到达第30行时(请参见下面的代码),程序将出现错误并打印:
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. When the code reaches at line 30 (see code below), the program will get an error and will print:
文件"C:\ Users \ xxx \ Documents \ models \ research \ object_detection \ object_detection.py",第31行,在 从object_detection.utils中将ops导入为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行,在 从object_detection.utils中将ops导入为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
ImportError:没有名为'object_detection.utils'的模块; 'object_detection'不是一个包
ImportError: No module named 'object_detection.utils'; 'object_detection' is not a package
我尝试了此链接中的解决方案( Windows上的Tensorflow对象检测API-逐步出现错误"ModuleNotFoundError:没有名为"utils"的模块" ),但仍然无法正常工作.我不知道要解决此问题的目标是什么.另外,我对机器学习,tensorflow和opencv不太熟悉,我现在就开始学习它.谁能帮我这个忙吗?预先感谢.
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. 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. 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
推荐答案
我已按照以下步骤操作:对于每个新终端,请按如下所示附加PYTHONPATH:
I have followed below steps:For every new terminal, append PYTHONPATH as follows:
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim
来自目录C:\Users\xxx\Documents\models\research
否则,请将该特定行添加到~/.bashrc
文件中,以避免为每个新终端运行.
Else, add that particular line to ~/.bashrc
file in order to avoid running for every new terminal.
这篇关于Windows上的Tensorflow对象检测API-ImportError:没有名为"object_detection.utils"的模块; "object_detection";不是包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!