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
a2de5799
Commit
a2de5799
authored
Nov 20, 2020
by
Vivek Rathod
Committed by
TF Object Detection Team
Nov 20, 2020
Browse files
Slice groundtruth tensors to remove padding during evaluation.
PiperOrigin-RevId: 343491021
parent
1d38cca0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
24 deletions
+38
-24
research/object_detection/metrics/coco_evaluation.py
research/object_detection/metrics/coco_evaluation.py
+3
-2
research/object_detection/model_lib_v2.py
research/object_detection/model_lib_v2.py
+13
-14
research/object_detection/utils/visualization_utils.py
research/object_detection/utils/visualization_utils.py
+22
-8
No files found.
research/object_detection/metrics/coco_evaluation.py
View file @
a2de5799
...
...
@@ -373,8 +373,9 @@ class CocoDetectionEvaluator(object_detection_evaluation.DetectionEvaluator):
detection_scores
=
eval_dict
[
detection_fields
.
detection_scores
]
detection_classes
=
eval_dict
[
detection_fields
.
detection_classes
]
num_gt_boxes_per_image
=
eval_dict
.
get
(
'num_groundtruth_boxes_per_image'
,
None
)
num_det_boxes_per_image
=
eval_dict
.
get
(
'num_det_boxes_per_image'
,
None
)
input_data_fields
.
num_groundtruth_boxes
,
None
)
num_det_boxes_per_image
=
eval_dict
.
get
(
detection_fields
.
num_detections
,
None
)
is_annotated
=
eval_dict
.
get
(
'is_annotated'
,
None
)
if
groundtruth_is_crowd
is
None
:
...
...
research/object_detection/model_lib_v2.py
View file @
a2de5799
...
...
@@ -890,8 +890,7 @@ def eager_eval_loop(
tf
.
logging
.
info
(
'Finished eval step %d'
,
i
)
use_original_images
=
fields
.
InputDataFields
.
original_image
in
features
if
(
use_original_images
and
i
<
eval_config
.
num_visualizations
and
batch_size
==
1
):
if
(
use_original_images
and
i
<
eval_config
.
num_visualizations
):
sbys_image_list
=
vutils
.
draw_side_by_side_evaluation_image
(
eval_dict
,
category_index
=
category_index
,
...
...
@@ -899,20 +898,20 @@ def eager_eval_loop(
min_score_thresh
=
eval_config
.
min_score_threshold
,
use_normalized_coordinates
=
False
,
keypoint_edges
=
keypoint_edges
or
None
)
sbys_image
s
=
tf
.
conc
at
(
sbys_image_list
,
axis
=
0
)
for
j
,
sbys_image
in
enumer
at
e
(
sbys_image_list
)
:
tf
.
compat
.
v2
.
summary
.
image
(
name
=
'eval_side_by_side_
'
+
str
(
i
),
name
=
'eval_side_by_side_
{}_{}'
.
format
(
i
,
j
),
step
=
global_step
,
data
=
sbys_image
s
,
data
=
sbys_image
,
max_outputs
=
eval_config
.
num_visualizations
)
if
eval_util
.
has_densepose
(
eval_dict
):
dp_image_list
=
vutils
.
draw_densepose_visualizations
(
eval_dict
)
dp_image
s
=
tf
.
conc
at
(
dp_image_list
,
axis
=
0
)
for
j
,
dp_image
in
enumer
at
e
(
dp_image_list
)
:
tf
.
compat
.
v2
.
summary
.
image
(
name
=
'densepose_detections_
'
+
str
(
i
),
name
=
'densepose_detections_
{}_{}'
.
format
(
i
,
j
),
step
=
global_step
,
data
=
dp_image
s
,
data
=
dp_image
,
max_outputs
=
eval_config
.
num_visualizations
)
if
evaluators
is
None
:
...
...
research/object_detection/utils/visualization_utils.py
View file @
a2de5799
...
...
@@ -664,6 +664,10 @@ def draw_side_by_side_evaluation_image(eval_dict,
key
!=
input_data_fields
.
image_additional_channels
):
eval_dict
[
key
]
=
tf
.
expand_dims
(
eval_dict
[
key
],
0
)
num_gt_boxes
=
[
-
1
]
*
eval_dict
[
input_data_fields
.
original_image
].
shape
[
0
]
if
input_data_fields
.
num_groundtruth_boxes
in
eval_dict
:
num_gt_boxes
=
tf
.
cast
(
eval_dict
[
input_data_fields
.
num_groundtruth_boxes
],
tf
.
int32
)
for
indx
in
range
(
eval_dict
[
input_data_fields
.
original_image
].
shape
[
0
]):
instance_masks
=
None
if
detection_fields
.
detection_masks
in
eval_dict
:
...
...
@@ -702,7 +706,6 @@ def draw_side_by_side_evaluation_image(eval_dict,
groundtruth_keypoint_scores
=
tf
.
cast
(
keypoint_ops
.
set_keypoint_visibilities
(
groundtruth_keypoints
),
dtype
=
tf
.
float32
)
images_with_detections
=
draw_bounding_boxes_on_image_tensors
(
tf
.
expand_dims
(
eval_dict
[
input_data_fields
.
original_image
][
indx
],
axis
=
0
),
...
...
@@ -725,16 +728,23 @@ def draw_side_by_side_evaluation_image(eval_dict,
max_boxes_to_draw
=
max_boxes_to_draw
,
min_score_thresh
=
min_score_thresh
,
use_normalized_coordinates
=
use_normalized_coordinates
)
num_gt_boxes_i
=
num_gt_boxes
[
indx
]
images_with_groundtruth
=
draw_bounding_boxes_on_image_tensors
(
tf
.
expand_dims
(
eval_dict
[
input_data_fields
.
original_image
][
indx
],
axis
=
0
),
eval_dict
[
input_data_fields
.
original_image
][
indx
],
axis
=
0
),
tf
.
expand_dims
(
eval_dict
[
input_data_fields
.
groundtruth_boxes
][
indx
],
axis
=
0
),
eval_dict
[
input_data_fields
.
groundtruth_boxes
][
indx
]
[:
num_gt_boxes_i
],
axis
=
0
),
tf
.
expand_dims
(
eval_dict
[
input_data_fields
.
groundtruth_classes
][
indx
],
axis
=
0
),
eval_dict
[
input_data_fields
.
groundtruth_classes
][
indx
]
[:
num_gt_boxes_i
],
axis
=
0
),
tf
.
expand_dims
(
tf
.
ones_like
(
eval_dict
[
input_data_fields
.
groundtruth_classes
][
indx
],
eval_dict
[
input_data_fields
.
groundtruth_classes
][
indx
]
[:
num_gt_boxes_i
],
dtype
=
tf
.
float32
),
axis
=
0
),
category_index
,
...
...
@@ -760,13 +770,17 @@ def draw_side_by_side_evaluation_image(eval_dict,
eval_dict
[
input_data_fields
.
image_additional_channels
][
indx
],
axis
=
0
),
tf
.
expand_dims
(
eval_dict
[
input_data_fields
.
groundtruth_boxes
][
indx
],
axis
=
0
),
eval_dict
[
input_data_fields
.
groundtruth_boxes
][
indx
]
[:
num_gt_boxes_i
],
axis
=
0
),
tf
.
expand_dims
(
eval_dict
[
input_data_fields
.
groundtruth_classes
][
indx
],
eval_dict
[
input_data_fields
.
groundtruth_classes
][
indx
]
[:
num_gt_boxes_i
],
axis
=
0
),
tf
.
expand_dims
(
tf
.
ones_like
(
eval_dict
[
input_data_fields
.
groundtruth_classes
][
indx
],
eval_dict
[
input_data_fields
.
groundtruth_classes
][
indx
]
[
num_gt_boxes_i
],
dtype
=
tf
.
float32
),
axis
=
0
),
category_index
,
...
...
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