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
2c685655
Commit
2c685655
authored
Sep 11, 2020
by
Rich Munoz
Committed by
TF Object Detection Team
Sep 11, 2020
Browse files
Support groundtruth_label_confidences in random_scale_crop_and_pad_to_square
PiperOrigin-RevId: 331247077
parent
84feedee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
3 deletions
+34
-3
research/object_detection/core/preprocessor.py
research/object_detection/core/preprocessor.py
+8
-3
research/object_detection/core/preprocessor_test.py
research/object_detection/core/preprocessor_test.py
+26
-0
No files found.
research/object_detection/core/preprocessor.py
View file @
2c685655
...
@@ -4143,6 +4143,7 @@ def random_scale_crop_and_pad_to_square(
...
@@ -4143,6 +4143,7 @@ def random_scale_crop_and_pad_to_square(
label_weights
,
label_weights
,
masks
=
None
,
masks
=
None
,
keypoints
=
None
,
keypoints
=
None
,
label_confidences
=
None
,
scale_min
=
0.1
,
scale_min
=
0.1
,
scale_max
=
2.0
,
scale_max
=
2.0
,
output_size
=
512
,
output_size
=
512
,
...
@@ -4176,6 +4177,8 @@ def random_scale_crop_and_pad_to_square(
...
@@ -4176,6 +4177,8 @@ def random_scale_crop_and_pad_to_square(
as the input `image`.
as the input `image`.
keypoints: (optional) rank 3 float32 tensor with shape [num_instances,
keypoints: (optional) rank 3 float32 tensor with shape [num_instances,
num_keypoints, 2]. The keypoints are in y-x normalized coordinates.
num_keypoints, 2]. The keypoints are in y-x normalized coordinates.
label_confidences: (optional) float32 tensor of shape [num_instance]
representing the confidence for each box.
scale_min: float, the minimum value for the random scale factor.
scale_min: float, the minimum value for the random scale factor.
scale_max: float, the maximum value for the random scale factor.
scale_max: float, the maximum value for the random scale factor.
output_size: int, the desired (square) output image size.
output_size: int, the desired (square) output image size.
...
@@ -4191,9 +4194,8 @@ def random_scale_crop_and_pad_to_square(
...
@@ -4191,9 +4194,8 @@ def random_scale_crop_and_pad_to_square(
label_weights: rank 1 float32 tensor with shape [num_instances].
label_weights: rank 1 float32 tensor with shape [num_instances].
masks: rank 3 float32 tensor with shape [num_instances, height, width]
masks: rank 3 float32 tensor with shape [num_instances, height, width]
containing instance masks.
containing instance masks.
label_confidences: confidences for retained boxes.
"""
"""
img_shape
=
tf
.
shape
(
image
)
img_shape
=
tf
.
shape
(
image
)
input_height
,
input_width
=
img_shape
[
0
],
img_shape
[
1
]
input_height
,
input_width
=
img_shape
[
0
],
img_shape
[
1
]
random_scale
=
tf
.
random_uniform
([],
scale_min
,
scale_max
,
seed
=
seed
)
random_scale
=
tf
.
random_uniform
([],
scale_min
,
scale_max
,
seed
=
seed
)
...
@@ -4258,6 +4260,9 @@ def random_scale_crop_and_pad_to_square(
...
@@ -4258,6 +4260,9 @@ def random_scale_crop_and_pad_to_square(
keypoints
,
[
0.0
,
0.0
,
1.0
,
1.0
])
keypoints
,
[
0.0
,
0.0
,
1.0
,
1.0
])
return_values
.
append
(
keypoints
)
return_values
.
append
(
keypoints
)
if
label_confidences
is
not
None
:
return_values
.
append
(
tf
.
gather
(
label_confidences
,
indices
))
return
return_values
return
return_values
...
@@ -4498,7 +4503,7 @@ def get_default_func_arg_map(include_label_weights=True,
...
@@ -4498,7 +4503,7 @@ def get_default_func_arg_map(include_label_weights=True,
fields
.
InputDataFields
.
groundtruth_boxes
,
fields
.
InputDataFields
.
groundtruth_boxes
,
fields
.
InputDataFields
.
groundtruth_classes
,
fields
.
InputDataFields
.
groundtruth_classes
,
groundtruth_label_weights
,
groundtruth_instance_masks
,
groundtruth_label_weights
,
groundtruth_instance_masks
,
groundtruth_keypoints
),
groundtruth_keypoints
,
groundtruth_label_confidences
),
}
}
return
prep_func_arg_map
return
prep_func_arg_map
...
...
research/object_detection/core/preprocessor_test.py
View file @
2c685655
...
@@ -3931,6 +3931,32 @@ class PreprocessorTest(test_case.TestCase, parameterized.TestCase):
...
@@ -3931,6 +3931,32 @@ class PreprocessorTest(test_case.TestCase, parameterized.TestCase):
self
.
assertAllClose
(
image
[:,
:,
0
],
self
.
assertAllClose
(
image
[:,
:,
0
],
masks
[
0
,
:,
:])
masks
[
0
,
:,
:])
def
test_random_scale_crop_and_pad_to_square_handles_confidences
(
self
):
def
graph_fn
():
image
=
tf
.
zeros
([
10
,
10
,
1
])
boxes
=
tf
.
constant
([[
0
,
0
,
0.5
,
0.5
],
[
0.5
,
0.5
,
0.75
,
0.75
]])
label_weights
=
tf
.
constant
([
1.0
,
1.0
])
box_labels
=
tf
.
constant
([
0
,
1
])
box_confidences
=
tf
.
constant
([
-
1.0
,
1.0
])
(
_
,
new_boxes
,
_
,
_
,
new_confidences
)
=
preprocessor
.
random_scale_crop_and_pad_to_square
(
image
,
boxes
,
box_labels
,
label_weights
,
label_confidences
=
box_confidences
,
scale_min
=
0.8
,
scale_max
=
0.9
,
output_size
=
10
)
return
new_boxes
,
new_confidences
boxes
,
confidences
=
self
.
execute_cpu
(
graph_fn
,
[])
self
.
assertLen
(
boxes
,
2
)
self
.
assertAllEqual
(
confidences
,
[
-
1.0
,
1.0
])
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
tf
.
test
.
main
()
tf
.
test
.
main
()
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