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
39678c06
"git@developer.sourcefind.cn:modelzoo/bert4torch.git" did not exist on "66a1d0d01bb0c007344bc9d46810747234e6bbb5"
Unverified
Commit
39678c06
authored
Oct 23, 2021
by
srihari-humbarwadi
Browse files
precompute grid coordinates
parent
797d3a5b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
official/vision/beta/projects/panoptic_maskrcnn/modeling/layers/paste_masks.py
...projects/panoptic_maskrcnn/modeling/layers/paste_masks.py
+7
-6
No files found.
official/vision/beta/projects/panoptic_maskrcnn/modeling/layers/paste_masks.py
View file @
39678c06
...
@@ -108,15 +108,16 @@ class PasteMasks(tf.keras.layers.Layer):
...
@@ -108,15 +108,16 @@ class PasteMasks(tf.keras.layers.Layer):
'grid_sampler'
:
grid_sampler
'grid_sampler'
:
grid_sampler
}
}
def
build
(
self
,
input_shape
):
self
.
_x_coords
=
tf
.
range
(
0
,
self
.
_output_size
[
1
],
dtype
=
tf
.
float32
)
self
.
_y_coords
=
tf
.
range
(
0
,
self
.
_output_size
[
0
],
dtype
=
tf
.
float32
)
def
call
(
self
,
inputs
):
def
call
(
self
,
inputs
):
masks
,
boxes
=
inputs
masks
,
boxes
=
inputs
masks_dtype
=
masks
.
dtype
masks
=
tf
.
cast
(
masks
,
dtype
=
tf
.
float32
)
boxes
=
tf
.
cast
(
boxes
,
dtype
=
tf
.
float32
)
y0
,
x0
,
y1
,
x1
=
tf
.
split
(
boxes
,
4
,
axis
=
1
)
y0
,
x0
,
y1
,
x1
=
tf
.
split
(
boxes
,
4
,
axis
=
1
)
x_coords
=
tf
.
range
(
0
,
self
.
_output_size
[
1
]
,
dtype
=
boxes
.
dtype
)
x_coords
=
tf
.
cast
(
self
.
_x_coords
,
dtype
=
boxes
.
dtype
)
y_coords
=
tf
.
range
(
0
,
self
.
_output_size
[
0
]
,
dtype
=
boxes
.
dtype
)
y_coords
=
tf
.
cast
(
self
.
_y_coords
,
dtype
=
boxes
.
dtype
)
x_coords
=
(
x_coords
-
x0
)
/
(
x1
-
x0
)
*
2
-
1
x_coords
=
(
x_coords
-
x0
)
/
(
x1
-
x0
)
*
2
-
1
y_coords
=
(
y_coords
-
y0
)
/
(
y1
-
y0
)
*
2
-
1
y_coords
=
(
y_coords
-
y0
)
/
(
y1
-
y0
)
*
2
-
1
...
@@ -127,7 +128,7 @@ class PasteMasks(tf.keras.layers.Layer):
...
@@ -127,7 +128,7 @@ class PasteMasks(tf.keras.layers.Layer):
tf
.
expand_dims
(
y_coords
,
axis
=
2
),
tf
.
expand_dims
(
y_coords
,
axis
=
2
),
multiples
=
[
1
,
1
,
self
.
_output_size
[
1
]])
multiples
=
[
1
,
1
,
self
.
_output_size
[
1
]])
pasted_masks
=
self
.
_grid_sampler
((
masks
,
x_coords
,
y_coords
))
pasted_masks
=
self
.
_grid_sampler
((
masks
,
x_coords
,
y_coords
))
return
tf
.
cast
(
pasted_masks
,
dtype
=
masks_dtype
)
return
pasted_masks
def
get_config
(
self
):
def
get_config
(
self
):
return
self
.
_config_dict
return
self
.
_config_dict
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