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
ed4e22b8
Unverified
Commit
ed4e22b8
authored
Apr 16, 2018
by
pkulzc
Committed by
GitHub
Apr 16, 2018
Browse files
Merge pull request #3973 from pkulzc/master
Object detection internal changes
parents
cac90a0e
13b89b93
Changes
61
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
0 deletions
+98
-0
research/object_detection/utils/per_image_vrd_evaluation_test.py
...h/object_detection/utils/per_image_vrd_evaluation_test.py
+98
-0
No files found.
research/object_detection/utils/per_image_vrd_evaluation_test.py
0 → 100644
View file @
ed4e22b8
# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Tests for object_detection.utils.per_image_vrd_evaluation."""
import
numpy
as
np
import
tensorflow
as
tf
from
object_detection.utils
import
per_image_vrd_evaluation
class
SingleClassPerImageVrdEvaluationTest
(
tf
.
test
.
TestCase
):
def
setUp
(
self
):
matching_iou_threshold
=
0.5
self
.
eval
=
per_image_vrd_evaluation
.
PerImageVRDEvaluation
(
matching_iou_threshold
)
box_data_type
=
np
.
dtype
([(
'subject'
,
'f4'
,
(
4
,)),
(
'object'
,
'f4'
,
(
4
,))])
self
.
detected_box_tuples
=
np
.
array
(
[([
0
,
0
,
1
,
1
],
[
1
,
1
,
2
,
2
]),
([
0
,
0
,
1.1
,
1
],
[
1
,
1
,
2
,
2
]),
([
1
,
1
,
2
,
2
],
[
0
,
0
,
1.1
,
1
])],
dtype
=
box_data_type
)
self
.
detected_scores
=
np
.
array
([
0.2
,
0.8
,
0.1
],
dtype
=
float
)
self
.
groundtruth_box_tuples
=
np
.
array
(
[([
0
,
0
,
1
,
1
],
[
1
,
1
,
2
,
2
])],
dtype
=
box_data_type
)
def
test_tp_fp_eval
(
self
):
scores
,
tp_fp_labels
=
self
.
eval
.
_compute_tp_fp_for_single_class
(
self
.
detected_box_tuples
,
self
.
detected_scores
,
self
.
groundtruth_box_tuples
)
expected_scores
=
np
.
array
([
0.8
,
0.2
,
0.1
],
dtype
=
float
)
expected_tp_fp_labels
=
np
.
array
([
True
,
False
,
False
],
dtype
=
bool
)
self
.
assertTrue
(
np
.
allclose
(
expected_scores
,
scores
))
self
.
assertTrue
(
np
.
allclose
(
expected_tp_fp_labels
,
tp_fp_labels
))
def
test_tp_fp_eval_empty_gt
(
self
):
box_data_type
=
np
.
dtype
([(
'subject'
,
'f4'
,
(
4
,)),
(
'object'
,
'f4'
,
(
4
,))])
scores
,
tp_fp_labels
=
self
.
eval
.
_compute_tp_fp_for_single_class
(
self
.
detected_box_tuples
,
self
.
detected_scores
,
np
.
array
([],
dtype
=
box_data_type
))
expected_scores
=
np
.
array
([
0.8
,
0.2
,
0.1
],
dtype
=
float
)
expected_tp_fp_labels
=
np
.
array
([
False
,
False
,
False
],
dtype
=
bool
)
self
.
assertTrue
(
np
.
allclose
(
expected_scores
,
scores
))
self
.
assertTrue
(
np
.
allclose
(
expected_tp_fp_labels
,
tp_fp_labels
))
class
MultiClassPerImageVrdEvaluationTest
(
tf
.
test
.
TestCase
):
def
setUp
(
self
):
matching_iou_threshold
=
0.5
self
.
eval
=
per_image_vrd_evaluation
.
PerImageVRDEvaluation
(
matching_iou_threshold
)
box_data_type
=
np
.
dtype
([(
'subject'
,
'f4'
,
(
4
,)),
(
'object'
,
'f4'
,
(
4
,))])
label_data_type
=
np
.
dtype
([(
'subject'
,
'i4'
),
(
'object'
,
'i4'
),
(
'relation'
,
'i4'
)])
self
.
detected_box_tuples
=
np
.
array
(
[([
0
,
0
,
1
,
1
],
[
1
,
1
,
2
,
2
]),
([
0
,
0
,
1.1
,
1
],
[
1
,
1
,
2
,
2
]),
([
1
,
1
,
2
,
2
],
[
0
,
0
,
1.1
,
1
]),
([
0
,
0
,
1
,
1
],
[
3
,
4
,
5
,
6
])],
dtype
=
box_data_type
)
self
.
detected_class_tuples
=
np
.
array
(
[(
1
,
2
,
3
),
(
1
,
2
,
3
),
(
1
,
2
,
3
),
(
1
,
4
,
5
)],
dtype
=
label_data_type
)
self
.
detected_scores
=
np
.
array
([
0.2
,
0.8
,
0.1
,
0.5
],
dtype
=
float
)
self
.
groundtruth_box_tuples
=
np
.
array
(
[([
0
,
0
,
1
,
1
],
[
1
,
1
,
2
,
2
]),
([
1
,
1
,
2
,
2
],
[
0
,
0
,
1.1
,
1
]),
([
0
,
0
,
1
,
1
],
[
3
,
4
,
5
,
5.5
])],
dtype
=
box_data_type
)
self
.
groundtruth_class_tuples
=
np
.
array
(
[(
1
,
2
,
3
),
(
1
,
7
,
3
),
(
1
,
4
,
5
)],
dtype
=
label_data_type
)
def
test_tp_fp_eval
(
self
):
scores
,
tp_fp_labels
=
self
.
eval
.
compute_detection_tp_fp
(
self
.
detected_box_tuples
,
self
.
detected_scores
,
self
.
detected_class_tuples
,
self
.
groundtruth_box_tuples
,
self
.
groundtruth_class_tuples
)
expected_scores
=
np
.
array
([
0.8
,
0.5
,
0.2
,
0.1
],
dtype
=
float
)
expected_tp_fp_labels
=
np
.
array
([
True
,
True
,
False
,
False
],
dtype
=
bool
)
self
.
assertTrue
(
np
.
allclose
(
expected_scores
,
scores
))
self
.
assertTrue
(
np
.
allclose
(
expected_tp_fp_labels
,
tp_fp_labels
))
if
__name__
==
'__main__'
:
tf
.
test
.
main
()
Prev
1
2
3
4
Next
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