张量流对象检测:加载标签图

时间:2019-12-07 16:39:46

标签: python tensorflow object-detection object-detection-api

运行以下命令后,加载标签图时遇到错误:

用于为每个框添加正确标签的字符串列表。

PATH_TO_LABELS ='模型/研究/对象检测/数据/mscoco_label_map.pbtxt' category_index = label_map_util.create_category_index_from_labelmap(PATH_TO_LABELS,use_display_name = True)

错误: NotFoundError Traceback(最近一次通话)  在       1#用于为每个框添加正确标签的字符串列表。

  2 PATH_TO_LABELS = 'models/research/object_detection/data/mscoco_label_map.pbtxt'

----> 3 category_index = label_map_util.create_category_index_from_labelmap(PATH_TO_LABELS,use_display_name = True)

E:\ TensorFlow \ models \ research \ object_detection \ utils \ label_map_util.py in create_category_index_from_labelmap(label_map_path,use_display_name)     241 {1:{'id':1,'name':'dog'},2:{'id':2,'name':'cat'},...}

242   """

-> 243个类别= create_categories_from_labelmap(label_map_path,use_display_name)

244   return create_category_index(categories)

245 

E:\ TensorFlow \ models \ research \ object_detection \ utils \ label_map_util.py in create_categories_from_labelmap(label_map_path,use_display_name)     221个类别:代表所有可能类别的词典列表。

222   """

-> 223 label_map = load_labelmap(label_map_path)

224   max_num_classes = max(item.id for item in label_map.item)

225   return convert_label_map_to_categories(label_map, max_num_classes,

E:\ TensorFlow \ models \ research \ object_detection \ utils \ label_map_util.py在load_labelmap(path)中     137“”“

138   with tf.gfile.GFile(path, 'r') as fid:

-> 139 label_map_string = fid.read()

140     label_map = string_int_label_map_pb2.StringIntLabelMap()

141     try:

〜\ Anaconda3 \ lib \ site-packages \ tensorflow_core \ python \ lib \ io \ file_io.py以read(self,n)     如果为字符串(常规)模式,则为120字符串。

121     """

-> 122 self._preread_check()

123     if n == -1:

124       length = self.size() - self.tell()
_preread_check中的

〜\ Anaconda3 \ lib \ site-packages \ tensorflow_core \ python \ lib \ io \ file_io.py      82““文件未打开以供读取”)

 83       self._read_buf = pywrap_tensorflow.CreateBufferedInputStream(

---> 84个compas.as_bytes(自己的__名称),1024 * 512)

 85 

 86   def _prewrite_check(self):

NotFoundError:NewRandomAccessFile创建/打开失败:models / research / object_detection / data / mscoco_label_map.pbtxt:系统无法enter code here找到指定的路径。 ;没有这样的过程

有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

设置python路径,并提供主目录中文件的完整路径。

有关python路径的更多信息,请参见以下链接-
https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md#add-libraries-to-pythonpath