Почему поле «имя» в метках обнаружения объектов десятка потоков не закодировано для fast_rcnn_inception_resnet_v2_atrous_oidv2 и как я могу их прочитать? - PullRequest
0 голосов
/ 01 февраля 2019

Я пытаюсь выполнить логический вывод для API обнаружения объектов TensorFlow для faster_rcnn_inception_resnet_v2_atrous_oidv2, обученного на наборе данных OpenImages.Я следую руководству по обнаружению объектов из здесь и в блоке кода 4 в блокноте Jupyter, где мы указываем PATH_TO_LABELS , я не могу прочитать oid_object_detection_challenge_500_label_map.pbtxt как я получаю следующую ошибку:

a bytes-like object is required, not 'str'.

Я могу без проблем выполнить код для модели ssd с pascal_label .

Вот мой код ноутбука Jupyter:

# Import all dependencies
import os
import cv2
import time
import argparse
import numpy as np
import tensorflow as tf
import matplotlib
matplotlib.use('Agg')
from matplotlib import pyplot as plt
from distutils.version import StrictVersion

if StrictVersion(tf.__version__) < StrictVersion('1.9.0'):
    raise ImportError('Please upgrade your TensorFlow installation to v1.9.* or later!')
%matplotlib inline

#Import helper utilities
from object_detection.utils import label_map_util
from object_detection.utils import visualization_utils as vis_util
# from object_detection.utils import download_data_from_gdrive

# Path to frozen detection graph. This is the actual model that is used for the object detection.
PATH_TO_CKPT = os.path.join('../../xyz_case/open_images_trained_models/faster_rcnn_inception_resnet_v2_atrous_oid_2018_01_28/saved_model/','saved_model.pb')

# List of the strings that is used to add correct label for each box.
PATH_TO_LABELS = os.path.join('../../xyz_case/labels/','oid_bbox_trainable_label_map.pbtxt')

NUM_CLASSES = 545

# Loading label map
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)

Мой стек ошибок:

ParseError                                Traceback (most recent call last)
~/obj_detection/models/research/object_detection/utils/label_map_util.py in load_labelmap(path)
    135     try:
--> 136       text_format.Merge(label_map_string, label_map)
    137     except text_format.ParseError:

~/miniconda3/lib/python3.6/site-packages/google/protobuf/text_format.py in Merge(text, message, allow_unknown_extension, allow_field_number, descriptor_pool)
    535       allow_field_number,
--> 536       descriptor_pool=descriptor_pool)
    537 

~/miniconda3/lib/python3.6/site-packages/google/protobuf/text_format.py in MergeLines(lines, message, allow_unknown_extension, allow_field_number, descriptor_pool)
    589                    descriptor_pool=descriptor_pool)
--> 590   return parser.MergeLines(lines, message)
    591 

~/miniconda3/lib/python3.6/site-packages/google/protobuf/text_format.py in MergeLines(self, lines, message)
    622     self._allow_multiple_scalars = True
--> 623     self._ParseOrMerge(lines, message)
    624     return message

~/miniconda3/lib/python3.6/site-packages/google/protobuf/text_format.py in _ParseOrMerge(self, lines, message)
    637     while not tokenizer.AtEnd():
--> 638       self._MergeField(tokenizer, message)
    639 

~/miniconda3/lib/python3.6/site-packages/google/protobuf/text_format.py in _MergeField(self, tokenizer, message)
    705     else:
--> 706       name = tokenizer.ConsumeIdentifierOrNumber()
    707       if self.allow_field_number and name.isdigit():

~/miniconda3/lib/python3.6/site-packages/google/protobuf/text_format.py in ConsumeIdentifierOrNumber(self)
   1165     if not self._IDENTIFIER_OR_NUMBER.match(result):
-> 1166       raise self.ParseError('Expected identifier or number, got %s.' % result)
   1167     self.NextToken()

ParseError: 7:1 : Expected identifier or number, got <.

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-7-4d68834281eb> in <module>
      2 
      3 # Loading label map
----> 4 label_map = label_map_util.load_labelmap(PATH_TO_LABELS)
      5 categories = label_map_util.convert_label_map_to_categories(label_map, max_num_classes=NUM_CLASSES,
      6                                                             use_display_name=True)

~/obj_detection/models/research/object_detection/utils/label_map_util.py in load_labelmap(path)
    136       text_format.Merge(label_map_string, label_map)
    137     except text_format.ParseError:
--> 138       label_map.ParseFromString(label_map_string)
    139   _validate_label_map(label_map)
    140   return label_map

TypeError: a bytes-like object is required, not 'str'

Я уже вижу эту проблему с github, которая похожа на мою проблему, но не предлагает достаточно хорошего решения, так какЯ уже использую TF> 1,9

...