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
a3f34adb
Commit
a3f34adb
authored
Sep 07, 2022
by
Vighnesh Birodkar
Committed by
TF Object Detection Team
Sep 07, 2022
Browse files
Support dot-product in consistency metric.
PiperOrigin-RevId: 472760525
parent
18044f42
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
4 deletions
+18
-4
research/object_detection/meta_architectures/deepmac_meta_arch.py
.../object_detection/meta_architectures/deepmac_meta_arch.py
+18
-4
No files found.
research/object_detection/meta_architectures/deepmac_meta_arch.py
View file @
a3f34adb
...
...
@@ -449,15 +449,24 @@ def gaussian_pixel_similarity(a, b, theta):
return
similarity
def
d
ilated_cross
_pixel_similarity
(
feature_map
,
dilation
=
2
,
theta
=
2.0
):
"""Dilated cross pixel similarity as defined in [1].
def
d
otprod
_pixel_similarity
(
a
,
b
):
return
tf
.
reduce_sum
(
a
*
b
,
axis
=-
1
)
[1]: https://arxiv.org/abs/2012.02310
def
dilated_cross_pixel_similarity
(
feature_map
,
dilation
=
2
,
theta
=
2.0
,
method
=
'gaussian'
):
"""Dilated cross pixel similarity.
method supports 2 values
- 'gaussian' from https://arxiv.org/abs/2012.02310
- 'dotprod' computes the dot product between feature vector for similarity.
This assumes that the features are normalized.
Args:
feature_map: A float tensor of shape [batch_size, height, width, channels]
dilation: int, the dilation factor.
theta: The denominator while taking difference inside the gaussian.
method: str, either 'gaussian' or 'dotprod'.
Returns:
dilated_similarity: A tensor of shape [8, batch_size, height, width]
...
...
@@ -465,7 +474,12 @@ def dilated_cross_pixel_similarity(feature_map, dilation=2, theta=2.0):
neighbors
=
generate_2d_neighbors
(
feature_map
,
dilation
)
feature_map
=
feature_map
[
tf
.
newaxis
]
if
method
==
'gaussian'
:
return
gaussian_pixel_similarity
(
feature_map
,
neighbors
,
theta
=
theta
)
elif
method
==
'dotprod'
:
return
dotprod_pixel_similarity
(
feature_map
,
neighbors
)
else
:
raise
ValueError
(
'Unknown method for pixel sim %s'
%
method
)
def
dilated_cross_same_mask_label
(
instance_masks
,
dilation
=
2
):
...
...
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