ModuleNotFoundError:没有名为' utils'

时间:2018-03-28 22:24:33

标签: python opencv tensorflow

我尝试使用网络摄像头作为输入在Tensorflow中运行object_detection API。

错误说:"来自utils import label_map_util ModuleNotFoundError:没有名为' utils'"

的模块

与线路有关:

from utils import label_map_util
from utils import visualization_utils as vis_util

我已经尝试过" pip install util"似乎有效,但没有解决问题。我还重新安装了多个版本的protobuf,因为在线的其他问题似乎将此作为解决方案。我安装protoc时没有任何错误,所以我不认为这是问题所在。

我在带有tensorflow-gpu的Windows 10上使用python 3.6。

5 个答案:

答案 0 :(得分:1)

你从哪个文件夹运行python脚本?

为了能够直接访问'utils'模块,您需要在<models-master>\research\object_detection文件夹中运行脚本。

答案 1 :(得分:1)

  • 不是在对象检测文件夹中运行脚本,而是添加 通过编写

    在脚本中检测tensorflow对象的路径
    import sys
    
    sys.path.append('PATH_TO_TENSORFLOW_OBJECT_DETECTION_FOLDER')
    
  • 例如我的ubuntu系统中的“ PATH_TO_TENSORFLOW_OBJECT_DETECTION_FOLDER”是

    / home / dc-335 / Documents / Softwares / tensorflow / models / research / object_detection

  • 干杯,您做到了!

答案 2 :(得分:1)

我用一种更快的方法来解决它。

我从 models \ research \ object_detection 复制了 utils 文件夹,并将其粘贴到与需要 utils < / p>

答案 3 :(得分:0)

将object_detection添加到utils的前面:

# from utils import label_map_util
# from utils import visualization_utils as vis_util

from object_detection.utils import label_map_util
from object_detection.utils import visualization_utils as vis_util

答案 4 :(得分:0)

安装没有通过,你会注意到你的项目文件夹中没有名为 model_utils 的模块。 卸载它 pip uninstall django-model-utils 然后再次安装它 pip install django-model-utils 在您的项目文件夹中名为 model_utils 的新应用。

相关问题