tensorflow对象检测:正在加载标签图

问题描述 投票:0回答:1

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

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

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 in 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()

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

 83       self._read_buf = pywrap_tensorflow.CreateBufferedInputStream(

---> 84 compat.as_bytes(self .__ name),1024 * 512)

 85 

 86   def _prewrite_check(self):

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

任何人都可以帮我吗?

python tensorflow object-detection object-detection-api
1个回答
0
投票

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

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

© www.soinside.com 2019 - 2024. All rights reserved.