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
b14f82a3
"docs/source/vscode:/vscode.git/clone" did not exist on "c5e48eb4f0b4b87322a48f9e7cfb4aef02b2a016"
Unverified
Commit
b14f82a3
authored
Oct 15, 2021
by
srihari-humbarwadi
Browse files
skip boxes with zero area while pasting masks
parent
2e908198
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
15 deletions
+16
-15
official/vision/beta/projects/panoptic_maskrcnn/modeling/layers/panoptic_segmentation_generator.py
...skrcnn/modeling/layers/panoptic_segmentation_generator.py
+16
-15
No files found.
official/vision/beta/projects/panoptic_maskrcnn/modeling/layers/panoptic_segmentation_generator.py
View file @
b14f82a3
...
...
@@ -79,26 +79,27 @@ class PanopticSegmentationGenerator(tf.keras.layers.Layer):
pasted_mask
=
tf
.
ones
(
self
.
_output_size
+
[
1
],
dtype
=
mask
.
dtype
)
*
self
.
_void_class_label
ymin
=
box
[
0
]
xmin
=
box
[
1
]
ymin
=
tf
.
clip_by_value
(
box
[
0
],
0
,
self
.
_output_size
[
0
])
xmin
=
tf
.
clip_by_value
(
box
[
1
],
0
,
self
.
_output_size
[
1
])
ymax
=
tf
.
clip_by_value
(
box
[
2
]
+
1
,
0
,
self
.
_output_size
[
0
])
xmax
=
tf
.
clip_by_value
(
box
[
3
]
+
1
,
0
,
self
.
_output_size
[
1
])
box_height
=
ymax
-
ymin
box_width
=
xmax
-
xmin
# resize mask to match the shape of the instance bounding box
resized_mask
=
tf
.
image
.
resize
(
mask
,
size
=
(
box_height
,
box_width
),
method
=
'nearest'
)
# paste resized mask on a blank mask that matches image shape
pasted_mask
=
tf
.
raw_ops
.
TensorStridedSliceUpdate
(
input
=
pasted_mask
,
begin
=
[
ymin
,
xmin
],
end
=
[
ymax
,
xmax
],
strides
=
[
1
,
1
],
value
=
resized_mask
)
if
not
(
box_height
==
0
or
box_width
==
0
):
# resize mask to match the shape of the instance bounding box
resized_mask
=
tf
.
image
.
resize
(
mask
,
size
=
(
box_height
,
box_width
),
method
=
'nearest'
)
# paste resized mask on a blank mask that matches image shape
pasted_mask
=
tf
.
raw_ops
.
TensorStridedSliceUpdate
(
input
=
pasted_mask
,
begin
=
[
ymin
,
xmin
],
end
=
[
ymax
,
xmax
],
strides
=
[
1
,
1
],
value
=
resized_mask
)
return
pasted_mask
...
...
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