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
4f8826ac
Unverified
Commit
4f8826ac
authored
Mar 16, 2022
by
srihari-humbarwadi
Browse files
rename output tensor keys
parent
a6c6089b
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
15 deletions
+29
-15
official/vision/beta/projects/panoptic_maskrcnn/modeling/heads/panoptic_deeplab_heads.py
...anoptic_maskrcnn/modeling/heads/panoptic_deeplab_heads.py
+6
-6
official/vision/beta/projects/panoptic_maskrcnn/modeling/heads/panoptic_deeplab_heads_test.py
...ic_maskrcnn/modeling/heads/panoptic_deeplab_heads_test.py
+2
-2
official/vision/beta/projects/panoptic_maskrcnn/modeling/panoptic_deeplab_model_test.py
...panoptic_maskrcnn/modeling/panoptic_deeplab_model_test.py
+21
-7
No files found.
official/vision/beta/projects/panoptic_maskrcnn/modeling/heads/panoptic_deeplab_heads.py
View file @
4f8826ac
...
@@ -381,7 +381,7 @@ class InstanceHead(PanopticDeeplabHead):
...
@@ -381,7 +381,7 @@ class InstanceHead(PanopticDeeplabHead):
"""Creates the variables of the instance head."""
"""Creates the variables of the instance head."""
super
(
InstanceHead
,
self
).
build
(
input_shape
)
super
(
InstanceHead
,
self
).
build
(
input_shape
)
self
.
_instance_center_prediction_conv
=
tf
.
keras
.
layers
.
Conv2D
(
self
.
_instance_center_prediction_conv
=
tf
.
keras
.
layers
.
Conv2D
(
name
=
'instance_center
_prediction
'
,
name
=
'instance_center
s_heatmap
'
,
filters
=
1
,
filters
=
1
,
kernel_size
=
self
.
_config_dict
[
'prediction_kernel_size'
],
kernel_size
=
self
.
_config_dict
[
'prediction_kernel_size'
],
padding
=
'same'
,
padding
=
'same'
,
...
@@ -391,7 +391,7 @@ class InstanceHead(PanopticDeeplabHead):
...
@@ -391,7 +391,7 @@ class InstanceHead(PanopticDeeplabHead):
bias_regularizer
=
self
.
_config_dict
[
'bias_regularizer'
])
bias_regularizer
=
self
.
_config_dict
[
'bias_regularizer'
])
self
.
_instance_center_regression_conv
=
tf
.
keras
.
layers
.
Conv2D
(
self
.
_instance_center_regression_conv
=
tf
.
keras
.
layers
.
Conv2D
(
name
=
'instance_center
_regression
'
,
name
=
'instance_center
s_offset
'
,
filters
=
2
,
filters
=
2
,
kernel_size
=
self
.
_config_dict
[
'prediction_kernel_size'
],
kernel_size
=
self
.
_config_dict
[
'prediction_kernel_size'
],
padding
=
'same'
,
padding
=
'same'
,
...
@@ -409,10 +409,10 @@ class InstanceHead(PanopticDeeplabHead):
...
@@ -409,10 +409,10 @@ class InstanceHead(PanopticDeeplabHead):
training
=
tf
.
keras
.
backend
.
learning_phase
()
training
=
tf
.
keras
.
backend
.
learning_phase
()
x
=
super
(
InstanceHead
,
self
).
call
(
inputs
,
training
=
training
)
x
=
super
(
InstanceHead
,
self
).
call
(
inputs
,
training
=
training
)
instance_center
_prediction
=
self
.
_instance_center_prediction_conv
(
x
)
instance_center
s_heatmap
=
self
.
_instance_center_prediction_conv
(
x
)
instance_center
_regression
=
self
.
_instance_center_regression_conv
(
x
)
instance_center
s_offset
=
self
.
_instance_center_regression_conv
(
x
)
outputs
=
{
outputs
=
{
'instance_center
_prediction
'
:
instance_center
_prediction
,
'instance_center
s_heatmap
'
:
instance_center
s_heatmap
,
'instance_center
_regression
'
:
instance_center
_regression
'instance_center
s_offset
'
:
instance_center
s_offset
}
}
return
outputs
return
outputs
official/vision/beta/projects/panoptic_maskrcnn/modeling/heads/panoptic_deeplab_heads_test.py
View file @
4f8826ac
...
@@ -71,10 +71,10 @@ class PanopticDeeplabHeadsTest(parameterized.TestCase, tf.test.TestCase):
...
@@ -71,10 +71,10 @@ class PanopticDeeplabHeadsTest(parameterized.TestCase, tf.test.TestCase):
semantic_outputs
.
numpy
().
shape
,
semantic_outputs
.
numpy
().
shape
,
[
2
,
h
,
w
,
num_classes
])
[
2
,
h
,
w
,
num_classes
])
self
.
assertAllEqual
(
self
.
assertAllEqual
(
instance_outputs
[
'instance_center
_prediction
'
].
numpy
().
shape
,
instance_outputs
[
'instance_center
s_heatmap
'
].
numpy
().
shape
,
[
2
,
h
,
w
,
1
])
[
2
,
h
,
w
,
1
])
self
.
assertAllEqual
(
self
.
assertAllEqual
(
instance_outputs
[
'instance_center
_regression
'
].
numpy
().
shape
,
instance_outputs
[
'instance_center
s_offset
'
].
numpy
().
shape
,
[
2
,
h
,
w
,
2
])
[
2
,
h
,
w
,
2
])
...
...
official/vision/beta/projects/panoptic_maskrcnn/modeling/panoptic_deeplab_model_test.py
View file @
4f8826ac
...
@@ -41,6 +41,11 @@ class PanopticDeeplabNetworkTest(parameterized.TestCase, tf.test.TestCase):
...
@@ -41,6 +41,11 @@ class PanopticDeeplabNetworkTest(parameterized.TestCase, tf.test.TestCase):
batch_size
=
2
if
training
else
1
batch_size
=
2
if
training
else
1
num_classes
=
10
num_classes
=
10
inputs
=
np
.
random
.
rand
(
batch_size
,
input_size
,
input_size
,
3
)
inputs
=
np
.
random
.
rand
(
batch_size
,
input_size
,
input_size
,
3
)
image_info
=
tf
.
convert_to_tensor
(
[[[
input_size
,
input_size
],
[
input_size
,
input_size
],
[
1
,
1
],
[
0
,
0
]]])
image_info
=
tf
.
tile
(
image_info
,
[
batch_size
,
1
,
1
])
tf
.
keras
.
backend
.
set_image_data_format
(
'channels_last'
)
tf
.
keras
.
backend
.
set_image_data_format
(
'channels_last'
)
backbone
=
backbones
.
ResNet
(
model_id
=
50
)
backbone
=
backbones
.
ResNet
(
model_id
=
50
)
...
@@ -65,13 +70,15 @@ class PanopticDeeplabNetworkTest(parameterized.TestCase, tf.test.TestCase):
...
@@ -65,13 +70,15 @@ class PanopticDeeplabNetworkTest(parameterized.TestCase, tf.test.TestCase):
low_level_num_filters
=
(
64
,
32
))
low_level_num_filters
=
(
64
,
32
))
post_processor
=
panoptic_deeplab_merge
.
PostProcessor
(
post_processor
=
panoptic_deeplab_merge
.
PostProcessor
(
output_size
=
[
input_size
,
input_size
],
center_score_threshold
=
0.1
,
center_score_threshold
=
0.1
,
thing_class_ids
=
[
1
,
2
,
3
,
4
],
thing_class_ids
=
[
1
,
2
,
3
,
4
],
label_divisor
=
[
256
],
label_divisor
=
[
256
],
stuff_area_limit
=
4096
,
stuff_area_limit
=
4096
,
ignore_label
=
0
,
ignore_label
=
0
,
nms_kernel
=
41
,
nms_kernel
=
41
,
keep_k_centers
=
41
)
keep_k_centers
=
41
,
rescale_predictions
=
True
)
model
=
panoptic_deeplab_model
.
PanopticDeeplabModel
(
model
=
panoptic_deeplab_model
.
PanopticDeeplabModel
(
backbone
=
backbone
,
backbone
=
backbone
,
...
@@ -81,12 +88,15 @@ class PanopticDeeplabNetworkTest(parameterized.TestCase, tf.test.TestCase):
...
@@ -81,12 +88,15 @@ class PanopticDeeplabNetworkTest(parameterized.TestCase, tf.test.TestCase):
instance_head
=
instance_head
,
instance_head
=
instance_head
,
post_processor
=
post_processor
)
post_processor
=
post_processor
)
outputs
=
model
(
inputs
,
training
=
training
)
outputs
=
model
(
inputs
=
inputs
,
image_info
=
image_info
,
training
=
training
)
if
training
:
if
training
:
self
.
assertIn
(
'segmentation_outputs'
,
outputs
)
self
.
assertIn
(
'segmentation_outputs'
,
outputs
)
self
.
assertIn
(
'instance_center
_prediction
'
,
outputs
)
self
.
assertIn
(
'instance_center
s_heatmap
'
,
outputs
)
self
.
assertIn
(
'instance_center
_regression
'
,
outputs
)
self
.
assertIn
(
'instance_center
s_offset
'
,
outputs
)
self
.
assertAllEqual
(
self
.
assertAllEqual
(
[
2
,
input_size
//
(
2
**
low_level
[
-
1
]),
[
2
,
input_size
//
(
2
**
low_level
[
-
1
]),
...
@@ -97,12 +107,12 @@ class PanopticDeeplabNetworkTest(parameterized.TestCase, tf.test.TestCase):
...
@@ -97,12 +107,12 @@ class PanopticDeeplabNetworkTest(parameterized.TestCase, tf.test.TestCase):
[
2
,
input_size
//
(
2
**
low_level
[
-
1
]),
[
2
,
input_size
//
(
2
**
low_level
[
-
1
]),
input_size
//
(
2
**
low_level
[
-
1
]),
input_size
//
(
2
**
low_level
[
-
1
]),
1
],
1
],
outputs
[
'instance_center
_prediction
'
].
numpy
().
shape
)
outputs
[
'instance_center
s_heatmap
'
].
numpy
().
shape
)
self
.
assertAllEqual
(
self
.
assertAllEqual
(
[
2
,
input_size
//
(
2
**
low_level
[
-
1
]),
[
2
,
input_size
//
(
2
**
low_level
[
-
1
]),
input_size
//
(
2
**
low_level
[
-
1
]),
input_size
//
(
2
**
low_level
[
-
1
]),
2
],
2
],
outputs
[
'instance_center
_regression
'
].
numpy
().
shape
)
outputs
[
'instance_center
s_offset
'
].
numpy
().
shape
)
else
:
else
:
self
.
assertIn
(
'panoptic_outputs'
,
outputs
)
self
.
assertIn
(
'panoptic_outputs'
,
outputs
)
...
@@ -110,6 +120,8 @@ class PanopticDeeplabNetworkTest(parameterized.TestCase, tf.test.TestCase):
...
@@ -110,6 +120,8 @@ class PanopticDeeplabNetworkTest(parameterized.TestCase, tf.test.TestCase):
self
.
assertIn
(
'instance_mask'
,
outputs
)
self
.
assertIn
(
'instance_mask'
,
outputs
)
self
.
assertIn
(
'instance_centers'
,
outputs
)
self
.
assertIn
(
'instance_centers'
,
outputs
)
self
.
assertIn
(
'instance_scores'
,
outputs
)
self
.
assertIn
(
'instance_scores'
,
outputs
)
self
.
assertIn
(
'segmentation_outputs'
,
outputs
)
@
combinations
.
generate
(
@
combinations
.
generate
(
combinations
.
combine
(
combinations
.
combine
(
...
@@ -142,13 +154,15 @@ class PanopticDeeplabNetworkTest(parameterized.TestCase, tf.test.TestCase):
...
@@ -142,13 +154,15 @@ class PanopticDeeplabNetworkTest(parameterized.TestCase, tf.test.TestCase):
low_level_num_filters
=
(
64
,
32
))
low_level_num_filters
=
(
64
,
32
))
post_processor
=
panoptic_deeplab_merge
.
PostProcessor
(
post_processor
=
panoptic_deeplab_merge
.
PostProcessor
(
output_size
=
[
640
,
640
],
center_score_threshold
=
0.1
,
center_score_threshold
=
0.1
,
thing_class_ids
=
[
1
,
2
,
3
,
4
],
thing_class_ids
=
[
1
,
2
,
3
,
4
],
label_divisor
=
[
256
],
label_divisor
=
[
256
],
stuff_area_limit
=
4096
,
stuff_area_limit
=
4096
,
ignore_label
=
0
,
ignore_label
=
0
,
nms_kernel
=
41
,
nms_kernel
=
41
,
keep_k_centers
=
41
)
keep_k_centers
=
41
,
rescale_predictions
=
True
)
model
=
panoptic_deeplab_model
.
PanopticDeeplabModel
(
model
=
panoptic_deeplab_model
.
PanopticDeeplabModel
(
backbone
=
backbone
,
backbone
=
backbone
,
...
...
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