我正在使用tensorflow对象检测api从jupyter笔记本的视频文件中检测对象。
目前我的文件在'models/research/object detection‘文件夹中
我取自的代码的链接:https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/camera.html
import numpy as np
import os
import six.moves.urllib as urllib
import sys
import tarfile
import tensorflow as tf
import zipfile
import cv2
from collections import defaultdict
from io import StringIO
from matplotlib import pyplot as plt
from PIL import Image
from utils import label_map_util # getting error right here
from utils import visualization_utils as vis_util---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-c2d31cb1df1e> in <module>
12 from matplotlib import pyplot as plt
13 from PIL import Image
---> 14 from utils import label_map_util
15 from utils import visualization_utils as vis_util
16 import sys
E:\traffic-detector\models\object_detection\utils\label_map_util.py in <module>
24 import tensorflow as tf
25 from google.protobuf import text_format
---> 26 from object_detection.protos import string_int_label_map_pb2
27
28
ModuleNotFoundError: No module named 'object_detection'我不明白为什么要这么说
发布于 2019-07-22 20:10:57
您忘记了正确设置PYTHONPATH。您应该在文件夹model/research/中运行以下命令。
export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim发布于 2020-05-14 02:12:33
您需要添加包含模块的目录的完整路径。可能research文件夹包含object_detection模块,因此路径类似于
import sys
sys.path.append("C:\\Tf_models\\models\\research\\")https://stackoverflow.com/questions/57133989
复制相似问题