【问题标题】:tensorflow object detection: loading label maptensorflow对象检测:加载标签图
【发布时间】:2019-12-07 16:39:46
【问题描述】:

运行以下命令后,我在加载标签映射时遇到错误:

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

PATH_TO_LABELS = 'models/research/object_detection/data/mscoco_label_map.pbtxt'
category_index = label_map_util.create_category_index_from_labelmap(PATH_TO_LABELS, use_display_name=True)

错误:

NotFoundError Traceback (most recent call last)
<ipython-input-8-0c574e0e758d> in <module>
      1 # List of the strings that is used to add correct label for each box.

      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   categories = 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     categories: a list of dictionaries representing all possible categories.

    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 in read(self, n)
    120       string if in string (regular) mode.

    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                                            "File isn't open for reading")

     83       self._read_buf = pywrap_tensorflow.CreateBufferedInputStream(

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

     85 

     86   def _prewrite_check(self):

NotFoundError: NewRandomAccessFile failed to Create/Open: models/research/object_detection/data/mscoco_label_map.pbtxt : The system cannot find the path specified.
; No such process

【问题讨论】:

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


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-22
      • 2020-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-24
      • 1970-01-01
      相关资源
      最近更新 更多