请帮帮我!提前谢谢您。我正在使用Google Colab中的Python创建一个对象检测器。
请告诉我该怎么做?是否有模块版本错误或文件目录缺失?如果目录缺失,请告诉我如何添加。请尽快帮助我,再次非常感谢您。
当我运行这段代码时,它显示了这个错误
label_map = label_map_util.load_labelmap(PATH_TO_LABELS)categories = label_map_util.convert_label_map_to_categories(label_map, max_num_classes=NUM_CLASSES, use_display_name=True)category_index = label_map_util.create_category_index(categories)```.**这是输出内容**WARNING:tensorflow:From /usr/local/lib/python3.6/dist-packages/object_detection/utils/label_map_util.py:132: The name tf.gfile.GFile is deprecated. Please use tf.io.gfile.GFile instead.---------------------------------------------------------------------------NotFoundError Traceback (most recent call last)<ipython-input-9-b47b5c1dba35> in <module>() 1 import os----> 2 label_map = label_map_util.load_labelmap(PATH_TO_LABELS) 3 categories = label_map_util.convert_label_map_to_categories(label_map, max_num_classes=NUM_CLASSES, use_display_name=True) 4 category_index = label_map_util.create_category_index(categories)2 frames/usr/local/lib/python3.6/dist-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: data/mscoco_label_map.pbtxt; No such file or directory
回答:
您定义的PATH_TO_LABELS
是什么?
它应该指向您的pbtxt
文件(最好是完整路径 – 即在Colab中以/content
开头)。