Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
3040f522
Commit
3040f522
authored
Jan 20, 2021
by
Yoni Ben-Meshulam
Committed by
TF Object Detection Team
Jan 20, 2021
Browse files
Replace ValueError with warning when image_id has a hash conflict
PiperOrigin-RevId: 352873888
parent
e02da657
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
3 additions
and
74 deletions
+3
-74
research/object_detection/utils/object_detection_evaluation.py
...rch/object_detection/utils/object_detection_evaluation.py
+3
-3
research/object_detection/utils/object_detection_evaluation_test.py
...bject_detection/utils/object_detection_evaluation_test.py
+0
-71
No files found.
research/object_detection/utils/object_detection_evaluation.py
View file @
3040f522
...
...
@@ -254,7 +254,7 @@ class ObjectDetectionEvaluator(DetectionEvaluator):
"""
for
image_id
in
image_ids
:
if
image_id
in
self
.
_image_ids
:
raise
ValueError
(
'Image with id
{}
already added.'
.
format
(
image_id
)
)
logging
.
warning
(
'Image with id
%s
already added.'
,
image_id
)
self
.
_evaluation
.
merge_internal_state
(
state_tuple
)
...
...
@@ -321,7 +321,7 @@ class ObjectDetectionEvaluator(DetectionEvaluator):
raise error if instance masks are not in groundtruth dictionary.
"""
if
image_id
in
self
.
_image_ids
:
raise
ValueError
(
'Image with id
{}
already added.'
.
format
(
image_id
)
)
logging
.
warning
(
'Image with id
%s
already added.'
,
image_id
)
groundtruth_classes
=
(
groundtruth_dict
[
standard_fields
.
InputDataFields
.
groundtruth_classes
]
-
...
...
@@ -729,7 +729,7 @@ class OpenImagesDetectionEvaluator(ObjectDetectionEvaluator):
ValueError: On adding groundtruth for an image more than once.
"""
if
image_id
in
self
.
_image_ids
:
raise
ValueError
(
'Image with id
{}
already added.'
.
format
(
image_id
)
)
logging
.
warning
(
'Image with id
%s
already added.'
,
image_id
)
groundtruth_classes
=
(
groundtruth_dict
[
standard_fields
.
InputDataFields
.
groundtruth_classes
]
-
...
...
research/object_detection/utils/object_detection_evaluation_test.py
View file @
3040f522
...
...
@@ -524,30 +524,6 @@ class PascalEvaluationTest(tf.test.TestCase):
pascal_evaluator
.
clear
()
self
.
assertFalse
(
pascal_evaluator
.
_image_ids
)
def
test_value_error_on_duplicate_images
(
self
):
categories
=
[{
'id'
:
1
,
'name'
:
'cat'
},
{
'id'
:
2
,
'name'
:
'dog'
},
{
'id'
:
3
,
'name'
:
'elephant'
}]
# Add groundtruth
pascal_evaluator
=
object_detection_evaluation
.
PascalDetectionEvaluator
(
categories
)
image_key1
=
'img1'
groundtruth_boxes1
=
np
.
array
([[
0
,
0
,
1
,
1
],
[
0
,
0
,
2
,
2
],
[
0
,
0
,
3
,
3
]],
dtype
=
float
)
groundtruth_class_labels1
=
np
.
array
([
1
,
3
,
1
],
dtype
=
int
)
pascal_evaluator
.
add_single_ground_truth_image_info
(
image_key1
,
{
standard_fields
.
InputDataFields
.
groundtruth_boxes
:
groundtruth_boxes1
,
standard_fields
.
InputDataFields
.
groundtruth_classes
:
groundtruth_class_labels1
})
with
self
.
assertRaises
(
ValueError
):
pascal_evaluator
.
add_single_ground_truth_image_info
(
image_key1
,
{
standard_fields
.
InputDataFields
.
groundtruth_boxes
:
groundtruth_boxes1
,
standard_fields
.
InputDataFields
.
groundtruth_classes
:
groundtruth_class_labels1
})
class
WeightedPascalEvaluationTest
(
tf
.
test
.
TestCase
):
...
...
@@ -659,28 +635,6 @@ class WeightedPascalEvaluationTest(tf.test.TestCase):
self
.
wp_eval
.
clear
()
self
.
assertFalse
(
self
.
wp_eval
.
_image_ids
)
def
test_value_error_on_duplicate_images
(
self
):
# Add groundtruth
self
.
wp_eval
=
(
object_detection_evaluation
.
WeightedPascalDetectionEvaluator
(
self
.
categories
))
image_key1
=
'img1'
groundtruth_boxes1
=
np
.
array
([[
0
,
0
,
1
,
1
],
[
0
,
0
,
2
,
2
],
[
0
,
0
,
3
,
3
]],
dtype
=
float
)
groundtruth_class_labels1
=
np
.
array
([
1
,
3
,
1
],
dtype
=
int
)
self
.
wp_eval
.
add_single_ground_truth_image_info
(
image_key1
,
{
standard_fields
.
InputDataFields
.
groundtruth_boxes
:
groundtruth_boxes1
,
standard_fields
.
InputDataFields
.
groundtruth_classes
:
groundtruth_class_labels1
})
with
self
.
assertRaises
(
ValueError
):
self
.
wp_eval
.
add_single_ground_truth_image_info
(
image_key1
,
{
standard_fields
.
InputDataFields
.
groundtruth_boxes
:
groundtruth_boxes1
,
standard_fields
.
InputDataFields
.
groundtruth_classes
:
groundtruth_class_labels1
})
class
PrecisionAtRecallEvaluationTest
(
tf
.
test
.
TestCase
):
...
...
@@ -807,31 +761,6 @@ class PrecisionAtRecallEvaluationTest(tf.test.TestCase):
self
.
wp_eval
.
clear
()
self
.
assertFalse
(
self
.
wp_eval
.
_image_ids
)
def
test_value_error_on_duplicate_images
(
self
):
# Add groundtruth
self
.
wp_eval
=
(
object_detection_evaluation
.
PrecisionAtRecallDetectionEvaluator
(
self
.
categories
,
recall_lower_bound
=
0.0
,
recall_upper_bound
=
0.5
))
image_key1
=
'img1'
groundtruth_boxes1
=
np
.
array
([[
0
,
0
,
1
,
1
],
[
0
,
0
,
2
,
2
],
[
0
,
0
,
3
,
3
]],
dtype
=
float
)
groundtruth_class_labels1
=
np
.
array
([
1
,
3
,
1
],
dtype
=
int
)
self
.
wp_eval
.
add_single_ground_truth_image_info
(
image_key1
,
{
standard_fields
.
InputDataFields
.
groundtruth_boxes
:
groundtruth_boxes1
,
standard_fields
.
InputDataFields
.
groundtruth_classes
:
groundtruth_class_labels1
})
with
self
.
assertRaises
(
ValueError
):
self
.
wp_eval
.
add_single_ground_truth_image_info
(
image_key1
,
{
standard_fields
.
InputDataFields
.
groundtruth_boxes
:
groundtruth_boxes1
,
standard_fields
.
InputDataFields
.
groundtruth_classes
:
groundtruth_class_labels1
})
class
ObjectDetectionEvaluationTest
(
tf
.
test
.
TestCase
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment