1
votes

I am facing error in loading label map after running following command:

List of the strings that is used to add correct label for each box.

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)

error:

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
1

1 Answers

0
votes

Set the python path and give the full path for the file from home directory.

For more information about python path see the below link -
https://github.com/tensorflow/models/blob/master/research/object_detection/g3doc/installation.md#add-libraries-to-pythonpath