Python object_detection.utils.label_map_util.create_category_index() Examples
The following are 30
code examples of object_detection.utils.label_map_util.create_category_index().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
object_detection.utils.label_map_util
, or try the search function
.
Example #1
Source File: detector.py From ros_people_object_detection_tensorflow with Apache License 2.0 | 6 votes |
def load_model(self): """ Loads the detection model Args: Returns: """ with self._detection_graph.as_default(): od_graph_def = tf.GraphDef() with tf.gfile.GFile(self._path_to_ckpt, 'rb') as fid: serialized_graph = fid.read() od_graph_def.ParseFromString(serialized_graph) tf.import_graph_def(od_graph_def, name='') label_map = label_map_util.load_labelmap(self._path_to_labels) categories = label_map_util.convert_label_map_to_categories(\ label_map, max_num_classes=self._num_classes, use_display_name=True) self.category_index = label_map_util.create_category_index(categories)
Example #2
Source File: inference.py From Accident-Detection-on-Indian-Roads with GNU Affero General Public License v3.0 | 6 votes |
def load_details(args): PATH_TO_CKPT = args.frozen_graph PATH_TO_LABELS = args.label_map NUM_CLASSES = args.num_output_classes PATH_TO_TEST_IMAGES_DIR = args.input_dir PATH_TO_RESULT_IMAGES_DIR = args.output_dir if not os.path.exists(args.output_dir): os.mkdir(args.output_dir) TEST_IMAGE_PATHS = sorted(glob.glob(os.path.join(PATH_TO_TEST_IMAGES_DIR, '*.jpg'))) JPG_PATHS = [ os.path.basename(path) for path in TEST_IMAGE_PATHS ] RESULT_IMAGE_PATHS = [ os.path.join(PATH_TO_RESULT_IMAGES_DIR, jpg_path) for jpg_path in JPG_PATHS ] 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) return TEST_IMAGE_PATHS, RESULT_IMAGE_PATHS, category_index
Example #3
Source File: object_detection_tf_multiprocessing.py From object_detection_with_tensorflow with MIT License | 5 votes |
def load_label_map(label_map_name, num_class): # List of the strings that is used to add correct label for each box. PATH_TO_LABELS = os.path.join('data', label_map_name) # load 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_class, use_display_name=True) category_index = label_map_util.create_category_index(categories) return category_index
Example #4
Source File: object_detection_evaluation.py From object_detection_with_tensorflow with MIT License | 5 votes |
def evaluate(self): """Compute evaluation result. Returns: A dictionary of metrics with the following fields - 1. summary_metrics: 'Precision/mAP@<matching_iou_threshold>IOU': mean average precision at the specified IOU threshold. 2. per_category_ap: category specific results with keys of the form 'PerformanceByCategory/mAP@<matching_iou_threshold>IOU/category'. """ (per_class_ap, mean_ap, _, _, per_class_corloc, mean_corloc) = ( self._evaluation.evaluate()) pascal_metrics = { self._metric_prefix + 'Precision/mAP@{}IOU'.format(self._matching_iou_threshold): mean_ap } if self._evaluate_corlocs: pascal_metrics[self._metric_prefix + 'Precision/meanCorLoc@{}IOU'.format( self._matching_iou_threshold)] = mean_corloc category_index = label_map_util.create_category_index(self._categories) for idx in range(per_class_ap.size): if idx + self._label_id_offset in category_index: display_name = ( self._metric_prefix + 'PerformanceByCategory/AP@{}IOU/{}'.format( self._matching_iou_threshold, category_index[idx + self._label_id_offset]['name'])) pascal_metrics[display_name] = per_class_ap[idx] # Optionally add CorLoc metrics.classes if self._evaluate_corlocs: display_name = ( self._metric_prefix + 'PerformanceByCategory/CorLoc@{}IOU/{}' .format(self._matching_iou_threshold, category_index[idx + self._label_id_offset]['name'])) pascal_metrics[display_name] = per_class_corloc[idx] return pascal_metrics
Example #5
Source File: label_map_util_test.py From MAX-Object-Detector with Apache License 2.0 | 5 votes |
def test_create_category_index(self): categories = [{'name': u'1', 'id': 1}, {'name': u'2', 'id': 2}] category_index = label_map_util.create_category_index(categories) self.assertDictEqual({ 1: { 'name': u'1', 'id': 1 }, 2: { 'name': u'2', 'id': 2 } }, category_index)
Example #6
Source File: object_detection_evaluation.py From AniSeg with Apache License 2.0 | 5 votes |
def evaluate(self): """Compute evaluation result. Returns: A dictionary of metrics with the following fields - 1. summary_metrics: 'Precision/mAP@<matching_iou_threshold>IOU': mean average precision at the specified IOU threshold. 2. per_category_ap: category specific results with keys of the form 'PerformanceByCategory/mAP@<matching_iou_threshold>IOU/category'. """ (per_class_ap, mean_ap, _, _, per_class_corloc, mean_corloc) = ( self._evaluation.evaluate()) pascal_metrics = { self._metric_prefix + 'Precision/mAP@{}IOU'.format(self._matching_iou_threshold): mean_ap } if self._evaluate_corlocs: pascal_metrics[self._metric_prefix + 'Precision/meanCorLoc@{}IOU'.format( self._matching_iou_threshold)] = mean_corloc category_index = label_map_util.create_category_index(self._categories) for idx in range(per_class_ap.size): if idx + self._label_id_offset in category_index: display_name = ( self._metric_prefix + 'PerformanceByCategory/AP@{}IOU/{}'.format( self._matching_iou_threshold, category_index[idx + self._label_id_offset]['name'])) pascal_metrics[display_name] = per_class_ap[idx] # Optionally add CorLoc metrics.classes if self._evaluate_corlocs: display_name = ( self._metric_prefix + 'PerformanceByCategory/CorLoc@{}IOU/{}' .format(self._matching_iou_threshold, category_index[idx + self._label_id_offset]['name'])) pascal_metrics[display_name] = per_class_corloc[idx] return pascal_metrics
Example #7
Source File: label_map_util_test.py From vehicle_counting_tensorflow with MIT License | 5 votes |
def test_create_category_index(self): categories = [{'name': u'1', 'id': 1}, {'name': u'2', 'id': 2}] category_index = label_map_util.create_category_index(categories) self.assertDictEqual({ 1: { 'name': u'1', 'id': 1 }, 2: { 'name': u'2', 'id': 2 } }, category_index)
Example #8
Source File: object_detection_evaluation.py From MAX-Object-Detector with Apache License 2.0 | 5 votes |
def _build_metric_names(self): """Builds a list with metric names.""" self._metric_names = [ self._metric_prefix + 'Precision/mAP@{}IOU'.format( self._matching_iou_threshold) ] if self._evaluate_corlocs: self._metric_names.append( self._metric_prefix + 'Precision/meanCorLoc@{}IOU'.format(self._matching_iou_threshold)) category_index = label_map_util.create_category_index(self._categories) for idx in range(self._num_classes): if idx + self._label_id_offset in category_index: category_name = category_index[idx + self._label_id_offset]['name'] try: category_name = unicode(category_name, 'utf-8') except TypeError: pass category_name = unicodedata.normalize('NFKD', category_name).encode( 'ascii', 'ignore') self._metric_names.append( self._metric_prefix + 'PerformanceByCategory/AP@{}IOU/{}'.format( self._matching_iou_threshold, category_name)) if self._evaluate_corlocs: self._metric_names.append( self._metric_prefix + 'PerformanceByCategory/CorLoc@{}IOU/{}' .format(self._matching_iou_threshold, category_name))
Example #9
Source File: object_detection_evaluation.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def _build_metric_names(self): """Builds a list with metric names.""" self._metric_names = [ self._metric_prefix + 'Precision/mAP@{}IOU'.format( self._matching_iou_threshold) ] if self._evaluate_corlocs: self._metric_names.append( self._metric_prefix + 'Precision/meanCorLoc@{}IOU'.format(self._matching_iou_threshold)) category_index = label_map_util.create_category_index(self._categories) for idx in range(self._num_classes): if idx + self._label_id_offset in category_index: category_name = category_index[idx + self._label_id_offset]['name'] try: category_name = unicode(category_name, 'utf-8') except TypeError: pass category_name = unicodedata.normalize('NFKD', category_name).encode( 'ascii', 'ignore') self._metric_names.append( self._metric_prefix + 'PerformanceByCategory/AP@{}IOU/{}'.format( self._matching_iou_threshold, category_name)) if self._evaluate_corlocs: self._metric_names.append( self._metric_prefix + 'PerformanceByCategory/CorLoc@{}IOU/{}' .format(self._matching_iou_threshold, category_name))
Example #10
Source File: label_map_util_test.py From models with Apache License 2.0 | 5 votes |
def test_create_category_index(self): categories = [{'name': u'1', 'id': 1}, {'name': u'2', 'id': 2}] category_index = label_map_util.create_category_index(categories) self.assertDictEqual({ 1: { 'name': u'1', 'id': 1 }, 2: { 'name': u'2', 'id': 2 } }, category_index)
Example #11
Source File: object_detection_evaluation.py From models with Apache License 2.0 | 5 votes |
def _build_metric_names(self): """Builds a list with metric names.""" if self._recall_lower_bound > 0.0 or self._recall_upper_bound < 1.0: self._metric_names = [ self._metric_prefix + 'Precision/mAP@{}IOU@[{:.1f},{:.1f}]Recall'.format( self._matching_iou_threshold, self._recall_lower_bound, self._recall_upper_bound) ] else: self._metric_names = [ self._metric_prefix + 'Precision/mAP@{}IOU'.format(self._matching_iou_threshold) ] if self._evaluate_corlocs: self._metric_names.append( self._metric_prefix + 'Precision/meanCorLoc@{}IOU'.format(self._matching_iou_threshold)) category_index = label_map_util.create_category_index(self._categories) for idx in range(self._num_classes): if idx + self._label_id_offset in category_index: category_name = category_index[idx + self._label_id_offset]['name'] try: category_name = six.text_type(category_name, 'utf-8') except TypeError: pass category_name = unicodedata.normalize('NFKD', category_name) if six.PY2: category_name = category_name.encode('ascii', 'ignore') self._metric_names.append( self._metric_prefix + 'PerformanceByCategory/AP@{}IOU/{}'.format( self._matching_iou_threshold, category_name)) if self._evaluate_corlocs: self._metric_names.append( self._metric_prefix + 'PerformanceByCategory/CorLoc@{}IOU/{}'.format( self._matching_iou_threshold, category_name))
Example #12
Source File: tensorflow_detection.py From BMW-TensorFlow-Inference-API-GPU with Apache License 2.0 | 5 votes |
def load(self): with open(os.path.join(self.model_path, 'config.json')) as f: data = json.load(f) try: self.validate_json_configuration(data) self.set_model_configuration(data) except ApplicationError as e: raise e self.label_path = os.path.join(self.model_path, 'object-detection.pbtxt') self.label_map = label_map_util.load_labelmap(self.label_path) self.categories = label_map_util.convert_label_map_to_categories(self.label_map, max_num_classes=self.NUM_CLASSES, use_display_name=True) for dict in self.categories: self.labels.append(dict['name']) self.category_index = label_map_util.create_category_index(self.categories) self.detection_graph = tf.Graph() with self.detection_graph.as_default(): od_graph_def = tf.GraphDef() with tf.gfile.GFile(os.path.join(self.model_path, 'frozen_inference_graph.pb'), 'rb') as fid: serialized_graph = fid.read() od_graph_def.ParseFromString(serialized_graph) tf.import_graph_def(od_graph_def, name='') self.image_tensor = self.detection_graph.get_tensor_by_name('image_tensor:0') self.d_boxes = self.detection_graph.get_tensor_by_name('detection_boxes:0') self.d_scores = self.detection_graph.get_tensor_by_name('detection_scores:0') self.d_classes = self.detection_graph.get_tensor_by_name('detection_classes:0') self.num_d = self.detection_graph.get_tensor_by_name('num_detections:0') self.sess = tf.Session(graph=self.detection_graph) img = Image.open("object_detection/image1.jpg") img_expanded = np.expand_dims(img, axis=0) self.sess.run( [self.d_boxes, self.d_scores, self.d_classes, self.num_d], feed_dict={self.image_tensor: img_expanded})
Example #13
Source File: label_map_util_test.py From motion-rcnn with MIT License | 5 votes |
def test_create_category_index(self): categories = [{'name': u'1', 'id': 1}, {'name': u'2', 'id': 2}] category_index = label_map_util.create_category_index(categories) self.assertDictEqual({ 1: { 'name': u'1', 'id': 1 }, 2: { 'name': u'2', 'id': 2 } }, category_index)
Example #14
Source File: label_map_util_test.py From mtl-ssl with Apache License 2.0 | 5 votes |
def test_create_category_index(self): categories = [{'name': u'1', 'id': 1}, {'name': u'2', 'id': 2}] category_index = label_map_util.create_category_index(categories) self.assertDictEqual({ 1: { 'name': u'1', 'id': 1 }, 2: { 'name': u'2', 'id': 2 } }, category_index)
Example #15
Source File: label_map_util_test.py From multilabel-image-classification-tensorflow with MIT License | 5 votes |
def test_create_category_index(self): categories = [{'name': u'1', 'id': 1}, {'name': u'2', 'id': 2}] category_index = label_map_util.create_category_index(categories) self.assertDictEqual({ 1: { 'name': u'1', 'id': 1 }, 2: { 'name': u'2', 'id': 2 } }, category_index)
Example #16
Source File: label_map_util_test.py From g-tensorflow-models with Apache License 2.0 | 5 votes |
def test_create_category_index(self): categories = [{'name': u'1', 'id': 1}, {'name': u'2', 'id': 2}] category_index = label_map_util.create_category_index(categories) self.assertDictEqual({ 1: { 'name': u'1', 'id': 1 }, 2: { 'name': u'2', 'id': 2 } }, category_index)
Example #17
Source File: object_detection_tf_vectorization_thread.py From object_detection_with_tensorflow with MIT License | 5 votes |
def load_label_map(label_map_name, num_class): # List of the strings that is used to add correct label for each box. PATH_TO_LABELS = os.path.join('data', label_map_name) # load 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_class, use_display_name=True) category_index = label_map_util.create_category_index(categories) return category_index
Example #18
Source File: label_map_util_test.py From AniSeg with Apache License 2.0 | 5 votes |
def test_create_category_index(self): categories = [{'name': u'1', 'id': 1}, {'name': u'2', 'id': 2}] category_index = label_map_util.create_category_index(categories) self.assertDictEqual({ 1: { 'name': u'1', 'id': 1 }, 2: { 'name': u'2', 'id': 2 } }, category_index)
Example #19
Source File: object_detection_evaluation.py From object_detection_with_tensorflow with MIT License | 5 votes |
def evaluate(self): """Compute evaluation result. Returns: A dictionary of metrics with the following fields - 1. summary_metrics: 'Precision/mAP@<matching_iou_threshold>IOU': mean average precision at the specified IOU threshold. 2. per_category_ap: category specific results with keys of the form 'PerformanceByCategory/mAP@<matching_iou_threshold>IOU/category'. """ (per_class_ap, mean_ap, _, _, per_class_corloc, mean_corloc) = ( self._evaluation.evaluate()) pascal_metrics = { self._metric_prefix + 'Precision/mAP@{}IOU'.format(self._matching_iou_threshold): mean_ap } if self._evaluate_corlocs: pascal_metrics[self._metric_prefix + 'Precision/meanCorLoc@{}IOU'.format( self._matching_iou_threshold)] = mean_corloc category_index = label_map_util.create_category_index(self._categories) for idx in range(per_class_ap.size): if idx + self._label_id_offset in category_index: display_name = ( self._metric_prefix + 'PerformanceByCategory/AP@{}IOU/{}'.format( self._matching_iou_threshold, category_index[idx + self._label_id_offset]['name'])) pascal_metrics[display_name] = per_class_ap[idx] # Optionally add CorLoc metrics.classes if self._evaluate_corlocs: display_name = ( self._metric_prefix + 'PerformanceByCategory/CorLoc@{}IOU/{}' .format(self._matching_iou_threshold, category_index[idx + self._label_id_offset]['name'])) pascal_metrics[display_name] = per_class_corloc[idx] return pascal_metrics
Example #20
Source File: label_map_util_test.py From object_detection_with_tensorflow with MIT License | 5 votes |
def test_create_category_index(self): categories = [{'name': u'1', 'id': 1}, {'name': u'2', 'id': 2}] category_index = label_map_util.create_category_index(categories) self.assertDictEqual({ 1: { 'name': u'1', 'id': 1 }, 2: { 'name': u'2', 'id': 2 } }, category_index)
Example #21
Source File: object_detection_tf_vectorization_process.py From object_detection_with_tensorflow with MIT License | 5 votes |
def load_label_map(label_map_name, num_class): # List of the strings that is used to add correct label for each box. PATH_TO_LABELS = os.path.join('data', label_map_name) # load 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_class, use_display_name=True) category_index = label_map_util.create_category_index(categories) return category_index
Example #22
Source File: object_detection_evaluation.py From Elphas with Apache License 2.0 | 5 votes |
def evaluate(self): """Compute evaluation result. Returns: A dictionary of metrics with the following fields - 1. summary_metrics: 'Precision/mAP@<matching_iou_threshold>IOU': mean average precision at the specified IOU threshold. 2. per_category_ap: category specific results with keys of the form 'PerformanceByCategory/mAP@<matching_iou_threshold>IOU/category'. """ (per_class_ap, mean_ap, _, _, per_class_corloc, mean_corloc) = ( self._evaluation.evaluate()) pascal_metrics = { self._metric_prefix + 'Precision/mAP@{}IOU'.format(self._matching_iou_threshold): mean_ap } if self._evaluate_corlocs: pascal_metrics[self._metric_prefix + 'Precision/meanCorLoc@{}IOU'.format( self._matching_iou_threshold)] = mean_corloc category_index = label_map_util.create_category_index(self._categories) for idx in range(per_class_ap.size): if idx + self._label_id_offset in category_index: display_name = ( self._metric_prefix + 'PerformanceByCategory/AP@{}IOU/{}'.format( self._matching_iou_threshold, category_index[idx + self._label_id_offset]['name'])) pascal_metrics[display_name] = per_class_ap[idx] # Optionally add CorLoc metrics.classes if self._evaluate_corlocs: display_name = ( self._metric_prefix + 'PerformanceByCategory/CorLoc@{}IOU/{}' .format(self._matching_iou_threshold, category_index[idx + self._label_id_offset]['name'])) pascal_metrics[display_name] = per_class_corloc[idx] return pascal_metrics
Example #23
Source File: label_map_util_test.py From Elphas with Apache License 2.0 | 5 votes |
def test_create_category_index(self): categories = [{'name': u'1', 'id': 1}, {'name': u'2', 'id': 2}] category_index = label_map_util.create_category_index(categories) self.assertDictEqual({ 1: { 'name': u'1', 'id': 1 }, 2: { 'name': u'2', 'id': 2 } }, category_index)
Example #24
Source File: label_map_util_test.py From MBMD with MIT License | 5 votes |
def test_create_category_index(self): categories = [{'name': u'1', 'id': 1}, {'name': u'2', 'id': 2}] category_index = label_map_util.create_category_index(categories) self.assertDictEqual({ 1: { 'name': u'1', 'id': 1 }, 2: { 'name': u'2', 'id': 2 } }, category_index)
Example #25
Source File: models.py From pretrained.ml with MIT License | 5 votes |
def __init__(self): logger.info('Loading Tensorflow Detection API') weights_path = get_file(config.SSD_INCEPTION_FILENAME, config.SSD_INCEPTION_URL, cache_dir=os.path.abspath(config.WEIGHT_PATH), cache_subdir='models') extract_path = weights_path.replace('.tar.gz', '') if not os.path.exists(extract_path): tar = tarfile.open(weights_path, "r:gz") tar.extractall(path=os.path.join(config.WEIGHT_PATH, 'models')) tar.close() pb_path = os.path.join(extract_path, self.PB_NAME) self.graph = tf.Graph() with self.graph.as_default(): od_graph_def = tf.GraphDef() with tf.gfile.GFile(pb_path, 'rb') as fid: serialized_graph = fid.read() od_graph_def.ParseFromString(serialized_graph) tf.import_graph_def(od_graph_def, name='') self.label_map = label_map_util.load_labelmap(self.PATH_TO_LABELS) self.categories = label_map_util.convert_label_map_to_categories(self.label_map, max_num_classes=self.NUM_CLASSES, use_display_name=True) self.category_index = label_map_util.create_category_index(self.categories)
Example #26
Source File: label_map_util_test.py From object_detection_kitti with Apache License 2.0 | 5 votes |
def test_create_category_index(self): categories = [{'name': u'1', 'id': 1}, {'name': u'2', 'id': 2}] category_index = label_map_util.create_category_index(categories) self.assertDictEqual({ 1: { 'name': u'1', 'id': 1 }, 2: { 'name': u'2', 'id': 2 } }, category_index)
Example #27
Source File: object_detection_evaluation.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
def _build_metric_names(self): """Builds a list with metric names.""" if self._recall_lower_bound > 0.0 or self._recall_upper_bound < 1.0: self._metric_names = [ self._metric_prefix + 'Precision/mAP@{}IOU@[{:.1f},{:.1f}]Recall'.format( self._matching_iou_threshold, self._recall_lower_bound, self._recall_upper_bound) ] else: self._metric_names = [ self._metric_prefix + 'Precision/mAP@{}IOU'.format(self._matching_iou_threshold) ] if self._evaluate_corlocs: self._metric_names.append( self._metric_prefix + 'Precision/meanCorLoc@{}IOU'.format(self._matching_iou_threshold)) category_index = label_map_util.create_category_index(self._categories) for idx in range(self._num_classes): if idx + self._label_id_offset in category_index: category_name = category_index[idx + self._label_id_offset]['name'] try: category_name = six.text_type(category_name, 'utf-8') except TypeError: pass category_name = unicodedata.normalize('NFKD', category_name) if six.PY2: category_name = category_name.encode('ascii', 'ignore') self._metric_names.append( self._metric_prefix + 'PerformanceByCategory/AP@{}IOU/{}'.format( self._matching_iou_threshold, category_name)) if self._evaluate_corlocs: self._metric_names.append( self._metric_prefix + 'PerformanceByCategory/CorLoc@{}IOU/{}'.format( self._matching_iou_threshold, category_name))
Example #28
Source File: label_map_util_test.py From Live-feed-object-device-identification-using-Tensorflow-and-OpenCV with Apache License 2.0 | 5 votes |
def test_create_category_index(self): categories = [{'name': u'1', 'id': 1}, {'name': u'2', 'id': 2}] category_index = label_map_util.create_category_index(categories) self.assertDictEqual({ 1: { 'name': u'1', 'id': 1 }, 2: { 'name': u'2', 'id': 2 } }, category_index)
Example #29
Source File: label_map_util_test.py From moveo_ros with MIT License | 5 votes |
def test_create_category_index(self): categories = [{'name': u'1', 'id': 1}, {'name': u'2', 'id': 2}] category_index = label_map_util.create_category_index(categories) self.assertDictEqual({ 1: { 'name': u'1', 'id': 1 }, 2: { 'name': u'2', 'id': 2 } }, category_index)
Example #30
Source File: object_detection_evaluation.py From TPU-MobilenetSSD with MIT License | 5 votes |
def _build_metric_names(self): """Builds a list with metric names.""" self._metric_names = [ self._metric_prefix + 'Precision/mAP@{}IOU'.format( self._matching_iou_threshold) ] if self._evaluate_corlocs: self._metric_names.append( self._metric_prefix + 'Precision/meanCorLoc@{}IOU'.format(self._matching_iou_threshold)) category_index = label_map_util.create_category_index(self._categories) for idx in range(self._num_classes): if idx + self._label_id_offset in category_index: category_name = category_index[idx + self._label_id_offset]['name'] try: #category_name = unicode(category_name, 'utf-8') category_name = str(category_name, 'utf-8') except TypeError: pass category_name = unicodedata.normalize('NFKD', category_name).encode( 'ascii', 'ignore') self._metric_names.append( self._metric_prefix + 'PerformanceByCategory/AP@{}IOU/{}'.format( self._matching_iou_threshold, category_name)) if self._evaluate_corlocs: self._metric_names.append( self._metric_prefix + 'PerformanceByCategory/CorLoc@{}IOU/{}' .format(self._matching_iou_threshold, category_name))