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
6291404a
"vscode:/vscode.git/clone" did not exist on "acd21a6d60e40ab0da39ffd30ffa943c798b52a9"
Commit
6291404a
authored
Jun 25, 2020
by
syiming
Browse files
compute tensor once and change all values not belone to this level to zero
parent
a0593dc5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
research/object_detection/utils/spatial_transform_ops.py
research/object_detection/utils/spatial_transform_ops.py
+17
-3
No files found.
research/object_detection/utils/spatial_transform_ops.py
View file @
6291404a
...
@@ -19,6 +19,7 @@ from __future__ import division
...
@@ -19,6 +19,7 @@ from __future__ import division
from
__future__
import
print_function
from
__future__
import
print_function
import
tensorflow.compat.v1
as
tf
import
tensorflow.compat.v1
as
tf
import
numpy
as
np
def
_coordinate_vector_1d
(
start
,
end
,
size
,
align_endpoints
):
def
_coordinate_vector_1d
(
start
,
end
,
size
,
align_endpoints
):
...
@@ -419,9 +420,22 @@ def multilevel_native_crop_and_resize(images, boxes, box_levels,
...
@@ -419,9 +420,22 @@ def multilevel_native_crop_and_resize(images, boxes, box_levels,
return
native_crop_and_resize
(
images
[
0
],
boxes
,
crop_size
,
scope
=
None
)
return
native_crop_and_resize
(
images
[
0
],
boxes
,
crop_size
,
scope
=
None
)
croped_feature_list
=
[]
croped_feature_list
=
[]
for
level
,
image
in
enumerate
(
images
):
for
level
,
image
in
enumerate
(
images
):
level_boxes
=
tf
.
gather
(
boxes
,
box_levels
==
(
level
-
1
))
# indicies = tf.boolean_mask(tf.range(0, boxes[0]), box_levels == level)
cropped
=
native_crop_and_resize
(
image
,
level_boxes
,
crop_size
)
# print(indicies)
croped_feature_list
.
append
(
cropped
)
# level_boxes = tf.gather(boxes, indicies)
# print(level_boxes)
# level_boxes = boxes[box_levels == level]
# level_boxes = tf.reshape(level_boxes,
# [1, -1] + level_boxes.shape.as_list()[1:])
cropped
=
native_crop_and_resize
(
image
,
boxes
,
crop_size
)
print
(
cropped
)
cond
=
tf
.
tile
(
tf
.
equal
(
box_levels
,
level
)[:,
:,
tf
.
newaxis
],
[
1
,
1
]
+
[
tf
.
math
.
reduce_prod
(
cropped
.
shape
.
as_list
()[
2
:])])
cond
=
tf
.
reshape
(
cond
,
cropped
.
shape
)
print
(
cond
)
cropped_final
=
tf
.
where
(
cond
,
cropped
,
tf
.
zeros_like
(
cropped
))
# cropped[tf.where(box_levels != level)] = tf.zeros(crop_size)
print
(
cropped_final
)
croped_feature_list
.
append
(
cropped_final
)
return
tf
.
concat
(
croped_feature_list
,
axis
=
0
)
return
tf
.
concat
(
croped_feature_list
,
axis
=
0
)
...
...
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