"vscode:/vscode.git/clone" did not exist on "ad9b3ebf80d47130fcca9efd8cc5e6404ed5aaa8"
Unverified Commit 205c5e07 authored by Jonathan Huang's avatar Jonathan Huang Committed by GitHub
Browse files

Merge pull request #2725 from tombstone/fix_difficult_list_eval

Fix #2713
parents f88def23 9742585f
...@@ -166,12 +166,26 @@ class ObjectDetectionEvaluator(DetectionEvaluator): ...@@ -166,12 +166,26 @@ class ObjectDetectionEvaluator(DetectionEvaluator):
groundtruth_classes = groundtruth_dict[ groundtruth_classes = groundtruth_dict[
standard_fields.InputDataFields.groundtruth_classes] standard_fields.InputDataFields.groundtruth_classes]
groundtruth_classes -= self._label_id_offset groundtruth_classes -= self._label_id_offset
# If the key is not present in the groundtruth_dict or the array is empty
# (unless there are no annotations for the groundtruth on this image)
# use values from the dictionary or insert None otherwise.
if (standard_fields.InputDataFields.groundtruth_difficult in
groundtruth_dict.keys() and
(groundtruth_dict[standard_fields.InputDataFields.groundtruth_difficult]
.size or not groundtruth_classes.size)):
groundtruth_difficult = groundtruth_dict[
standard_fields.InputDataFields.groundtruth_difficult]
else:
groundtruth_difficult = None
if not len(self._image_ids) % 1000:
logging.warn(
'image %s does not have groundtruth difficult flag specified',
image_id)
self._evaluation.add_single_ground_truth_image_info( self._evaluation.add_single_ground_truth_image_info(
image_id, image_id,
groundtruth_dict[standard_fields.InputDataFields.groundtruth_boxes], groundtruth_dict[standard_fields.InputDataFields.groundtruth_boxes],
groundtruth_classes, groundtruth_classes,
groundtruth_dict.get( groundtruth_is_difficult_list=groundtruth_difficult)
standard_fields.InputDataFields.groundtruth_difficult, None))
self._image_ids.update([image_id]) self._image_ids.update([image_id])
def add_single_detected_image_info(self, image_id, detections_dict): def add_single_detected_image_info(self, image_id, detections_dict):
...@@ -337,14 +351,27 @@ class OpenImagesDetectionEvaluator(ObjectDetectionEvaluator): ...@@ -337,14 +351,27 @@ class OpenImagesDetectionEvaluator(ObjectDetectionEvaluator):
groundtruth_classes = groundtruth_dict[ groundtruth_classes = groundtruth_dict[
standard_fields.InputDataFields.groundtruth_classes] standard_fields.InputDataFields.groundtruth_classes]
groundtruth_classes -= self._label_id_offset groundtruth_classes -= self._label_id_offset
# If the key is not present in the groundtruth_dict or the array is empty
# (unless there are no annotations for the groundtruth on this image)
# use values from the dictionary or insert None otherwise.
if (standard_fields.InputDataFields.groundtruth_group_of in
groundtruth_dict.keys() and
(groundtruth_dict[standard_fields.InputDataFields.groundtruth_group_of]
.size or not groundtruth_classes.size)):
groundtruth_group_of = groundtruth_dict[
standard_fields.InputDataFields.groundtruth_group_of]
else:
groundtruth_group_of = None
if not len(self._image_ids) % 1000:
logging.warn(
'image %s does not have groundtruth group_of flag specified',
image_id)
self._evaluation.add_single_ground_truth_image_info( self._evaluation.add_single_ground_truth_image_info(
image_id, image_id,
groundtruth_dict[standard_fields.InputDataFields.groundtruth_boxes], groundtruth_dict[standard_fields.InputDataFields.groundtruth_boxes],
groundtruth_classes, groundtruth_classes,
groundtruth_is_difficult_list=None, groundtruth_is_difficult_list=None,
groundtruth_is_group_of_list=groundtruth_dict.get( groundtruth_is_group_of_list=groundtruth_group_of)
standard_fields.InputDataFields.groundtruth_group_of, None))
self._image_ids.update([image_id]) self._image_ids.update([image_id])
......
...@@ -46,7 +46,9 @@ class OpenImagesV2EvaluationTest(tf.test.TestCase): ...@@ -46,7 +46,9 @@ class OpenImagesV2EvaluationTest(tf.test.TestCase):
standard_fields.InputDataFields.groundtruth_boxes: standard_fields.InputDataFields.groundtruth_boxes:
groundtruth_boxes1, groundtruth_boxes1,
standard_fields.InputDataFields.groundtruth_classes: standard_fields.InputDataFields.groundtruth_classes:
groundtruth_class_labels1 groundtruth_class_labels1,
standard_fields.InputDataFields.groundtruth_group_of:
np.array([], dtype=bool)
}) })
image_key2 = 'img2' image_key2 = 'img2'
groundtruth_boxes2 = np.array( groundtruth_boxes2 = np.array(
...@@ -115,7 +117,9 @@ class PascalEvaluationTest(tf.test.TestCase): ...@@ -115,7 +117,9 @@ class PascalEvaluationTest(tf.test.TestCase):
image_key1, image_key1,
{standard_fields.InputDataFields.groundtruth_boxes: groundtruth_boxes1, {standard_fields.InputDataFields.groundtruth_boxes: groundtruth_boxes1,
standard_fields.InputDataFields.groundtruth_classes: standard_fields.InputDataFields.groundtruth_classes:
groundtruth_class_labels1}) groundtruth_class_labels1,
standard_fields.InputDataFields.groundtruth_difficult:
np.array([], dtype=bool)})
image_key2 = 'img2' image_key2 = 'img2'
groundtruth_boxes2 = np.array([[10, 10, 11, 11], [500, 500, 510, 510], groundtruth_boxes2 = np.array([[10, 10, 11, 11], [500, 500, 510, 510],
[10, 10, 12, 12]], dtype=float) [10, 10, 12, 12]], dtype=float)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment