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
1408d2c6
Unverified
Commit
1408d2c6
authored
Mar 26, 2022
by
srihari-humbarwadi
Browse files
use DSConv2D in heads
parent
8b641b13
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
15 deletions
+38
-15
official/vision/beta/projects/panoptic_maskrcnn/configs/panoptic_deeplab.py
...ta/projects/panoptic_maskrcnn/configs/panoptic_deeplab.py
+4
-4
official/vision/beta/projects/panoptic_maskrcnn/modeling/heads/panoptic_deeplab_heads.py
...anoptic_maskrcnn/modeling/heads/panoptic_deeplab_heads.py
+5
-4
official/vision/beta/projects/panoptic_maskrcnn/modeling/layers/fusion_layers.py
...ojects/panoptic_maskrcnn/modeling/layers/fusion_layers.py
+29
-7
No files found.
official/vision/beta/projects/panoptic_maskrcnn/configs/panoptic_deeplab.py
View file @
1408d2c6
...
@@ -200,10 +200,10 @@ def panoptic_deeplab_coco() -> cfg.ExperimentConfig:
...
@@ -200,10 +200,10 @@ def panoptic_deeplab_coco() -> cfg.ExperimentConfig:
dilation_rates
=
aspp_dilation_rates
)),
dilation_rates
=
aspp_dilation_rates
)),
semantic_head
=
SemanticHead
(
semantic_head
=
SemanticHead
(
level
=
level
,
level
=
level
,
num_convs
=
2
,
num_convs
=
1
,
num_filters
=
256
,
num_filters
=
256
,
kernel_size
=
5
,
kernel_size
=
5
,
use_depthwise_convolution
=
Fals
e
,
use_depthwise_convolution
=
Tru
e
,
upsample_factor
=
1
,
upsample_factor
=
1
,
low_level
=
(
3
,
2
),
low_level
=
(
3
,
2
),
low_level_num_filters
=
(
64
,
32
),
low_level_num_filters
=
(
64
,
32
),
...
@@ -211,10 +211,10 @@ def panoptic_deeplab_coco() -> cfg.ExperimentConfig:
...
@@ -211,10 +211,10 @@ def panoptic_deeplab_coco() -> cfg.ExperimentConfig:
prediction_kernel_size
=
1
),
prediction_kernel_size
=
1
),
instance_head
=
InstanceHead
(
instance_head
=
InstanceHead
(
level
=
level
,
level
=
level
,
num_convs
=
2
,
num_convs
=
1
,
num_filters
=
32
,
num_filters
=
32
,
kernel_size
=
5
,
kernel_size
=
5
,
use_depthwise_convolution
=
Fals
e
,
use_depthwise_convolution
=
Tru
e
,
upsample_factor
=
1
,
upsample_factor
=
1
,
low_level
=
(
3
,
2
),
low_level
=
(
3
,
2
),
low_level_num_filters
=
(
32
,
16
),
low_level_num_filters
=
(
32
,
16
),
...
...
official/vision/beta/projects/panoptic_maskrcnn/modeling/heads/panoptic_deeplab_heads.py
View file @
1408d2c6
...
@@ -19,7 +19,7 @@ import tensorflow as tf
...
@@ -19,7 +19,7 @@ import tensorflow as tf
from
official.modeling
import
tf_utils
from
official.modeling
import
tf_utils
from
official.vision.beta.projects.panoptic_maskrcnn.modeling.layers
import
fusion_layers
from
official.vision.beta.projects.panoptic_maskrcnn.modeling.layers
import
fusion_layers
from
official.vision.
beta.
ops
import
spatial_transform_ops
from
official.vision.ops
import
spatial_transform_ops
class
PanopticDeeplabHead
(
tf
.
keras
.
layers
.
Layer
):
class
PanopticDeeplabHead
(
tf
.
keras
.
layers
.
Layer
):
...
@@ -109,7 +109,7 @@ class PanopticDeeplabHead(tf.keras.layers.Layer):
...
@@ -109,7 +109,7 @@ class PanopticDeeplabHead(tf.keras.layers.Layer):
conv_kwargs
=
{
conv_kwargs
=
{
'kernel_size'
:
kernel_size
if
not
use_depthwise_convolution
else
1
,
'kernel_size'
:
kernel_size
if
not
use_depthwise_convolution
else
1
,
'padding'
:
'same'
,
'padding'
:
'same'
,
'use_bias'
:
Fals
e
,
'use_bias'
:
Tru
e
,
'kernel_initializer'
:
random_initializer
,
'kernel_initializer'
:
random_initializer
,
'kernel_regularizer'
:
self
.
_config_dict
[
'kernel_regularizer'
],
'kernel_regularizer'
:
self
.
_config_dict
[
'kernel_regularizer'
],
}
}
...
@@ -127,6 +127,7 @@ class PanopticDeeplabHead(tf.keras.layers.Layer):
...
@@ -127,6 +127,7 @@ class PanopticDeeplabHead(tf.keras.layers.Layer):
low_level
=
self
.
_config_dict
[
'low_level'
],
low_level
=
self
.
_config_dict
[
'low_level'
],
num_projection_filters
=
self
.
_config_dict
[
'low_level_num_filters'
],
num_projection_filters
=
self
.
_config_dict
[
'low_level_num_filters'
],
num_output_filters
=
self
.
_config_dict
[
'fusion_num_output_filters'
],
num_output_filters
=
self
.
_config_dict
[
'fusion_num_output_filters'
],
use_depthwise_convolution
=
self
.
_config_dict
[
'use_depthwise_convolution'
],
activation
=
self
.
_config_dict
[
'activation'
],
activation
=
self
.
_config_dict
[
'activation'
],
use_sync_bn
=
self
.
_config_dict
[
'use_sync_bn'
],
use_sync_bn
=
self
.
_config_dict
[
'use_sync_bn'
],
norm_momentum
=
self
.
_config_dict
[
'norm_momentum'
],
norm_momentum
=
self
.
_config_dict
[
'norm_momentum'
],
...
@@ -142,9 +143,9 @@ class PanopticDeeplabHead(tf.keras.layers.Layer):
...
@@ -142,9 +143,9 @@ class PanopticDeeplabHead(tf.keras.layers.Layer):
self
.
_convs
.
append
(
self
.
_convs
.
append
(
tf
.
keras
.
layers
.
DepthwiseConv2D
(
tf
.
keras
.
layers
.
DepthwiseConv2D
(
name
=
'panoptic_deeplab_head_depthwise_conv_{}'
.
format
(
i
),
name
=
'panoptic_deeplab_head_depthwise_conv_{}'
.
format
(
i
),
kernel_size
=
3
,
kernel_size
=
kernel_size
,
padding
=
'same'
,
padding
=
'same'
,
use_bias
=
Fals
e
,
use_bias
=
Tru
e
,
depthwise_initializer
=
random_initializer
,
depthwise_initializer
=
random_initializer
,
depthwise_regularizer
=
self
.
_config_dict
[
'kernel_regularizer'
],
depthwise_regularizer
=
self
.
_config_dict
[
'kernel_regularizer'
],
depth_multiplier
=
1
))
depth_multiplier
=
1
))
...
...
official/vision/beta/projects/panoptic_maskrcnn/modeling/layers/fusion_layers.py
View file @
1408d2c6
...
@@ -39,6 +39,7 @@ class PanopticDeepLabFusion(tf.keras.layers.Layer):
...
@@ -39,6 +39,7 @@ class PanopticDeepLabFusion(tf.keras.layers.Layer):
low_level
:
List
[
int
]
=
[
3
,
2
],
low_level
:
List
[
int
]
=
[
3
,
2
],
num_projection_filters
:
List
[
int
]
=
[
64
,
32
],
num_projection_filters
:
List
[
int
]
=
[
64
,
32
],
num_output_filters
:
int
=
256
,
num_output_filters
:
int
=
256
,
use_depthwise_convolution
:
bool
=
False
,
activation
:
str
=
'relu'
,
activation
:
str
=
'relu'
,
use_sync_bn
:
bool
=
False
,
use_sync_bn
:
bool
=
False
,
norm_momentum
:
float
=
0.99
,
norm_momentum
:
float
=
0.99
,
...
@@ -52,7 +53,11 @@ class PanopticDeepLabFusion(tf.keras.layers.Layer):
...
@@ -52,7 +53,11 @@ class PanopticDeepLabFusion(tf.keras.layers.Layer):
Args:
Args:
level: An `int` level at which the decoder was appled at.
level: An `int` level at which the decoder was appled at.
low_level: A list of `int` of minimum level to use in feature fusion.
low_level: A list of `int` of minimum level to use in feature fusion.
num_filters: An `int` number of filters in conv2d layers.
num_projection_filters: A list of `int` with number of filters for
projection conv2d layers.
num_output_filters: An `int` number of filters in output conv2d layers.
use_depthwise_convolution: A bool to specify if use depthwise separable
convolutions.
activation: A `str` name of the activation function.
activation: A `str` name of the activation function.
use_sync_bn: A `bool` that indicates whether to use synchronized batch
use_sync_bn: A `bool` that indicates whether to use synchronized batch
normalization across different replicas.
normalization across different replicas.
...
@@ -75,6 +80,7 @@ class PanopticDeepLabFusion(tf.keras.layers.Layer):
...
@@ -75,6 +80,7 @@ class PanopticDeepLabFusion(tf.keras.layers.Layer):
'low_level'
:
low_level
,
'low_level'
:
low_level
,
'num_projection_filters'
:
num_projection_filters
,
'num_projection_filters'
:
num_projection_filters
,
'num_output_filters'
:
num_output_filters
,
'num_output_filters'
:
num_output_filters
,
'use_depthwise_convolution'
:
use_depthwise_convolution
,
'activation'
:
activation
,
'activation'
:
activation
,
'use_sync_bn'
:
use_sync_bn
,
'use_sync_bn'
:
use_sync_bn
,
'norm_momentum'
:
norm_momentum
,
'norm_momentum'
:
norm_momentum
,
...
@@ -93,7 +99,7 @@ class PanopticDeepLabFusion(tf.keras.layers.Layer):
...
@@ -93,7 +99,7 @@ class PanopticDeepLabFusion(tf.keras.layers.Layer):
conv_op
=
tf
.
keras
.
layers
.
Conv2D
conv_op
=
tf
.
keras
.
layers
.
Conv2D
conv_kwargs
=
{
conv_kwargs
=
{
'padding'
:
'same'
,
'padding'
:
'same'
,
'use_bias'
:
Fals
e
,
'use_bias'
:
Tru
e
,
'kernel_initializer'
:
tf
.
initializers
.
VarianceScaling
(),
'kernel_initializer'
:
tf
.
initializers
.
VarianceScaling
(),
'kernel_regularizer'
:
self
.
_config_dict
[
'kernel_regularizer'
],
'kernel_regularizer'
:
self
.
_config_dict
[
'kernel_regularizer'
],
}
}
...
@@ -116,11 +122,27 @@ class PanopticDeepLabFusion(tf.keras.layers.Layer):
...
@@ -116,11 +122,27 @@ class PanopticDeepLabFusion(tf.keras.layers.Layer):
filters
=
self
.
_config_dict
[
'num_projection_filters'
][
i
],
filters
=
self
.
_config_dict
[
'num_projection_filters'
][
i
],
kernel_size
=
1
,
kernel_size
=
1
,
**
conv_kwargs
))
**
conv_kwargs
))
self
.
_fusion_convs
.
append
(
if
self
.
_config_dict
[
'use_depthwise_convolution'
]:
conv_op
(
depthwise_initializer
=
tf
.
keras
.
initializers
.
RandomNormal
(
stddev
=
0.01
)
filters
=
self
.
_config_dict
[
'num_output_filters'
],
fusion_conv
=
tf
.
keras
.
Sequential
([
kernel_size
=
5
,
tf
.
keras
.
layers
.
DepthwiseConv2D
(
**
conv_kwargs
))
kernel_size
=
5
,
padding
=
'same'
,
use_bias
=
True
,
depthwise_initializer
=
depthwise_initializer
,
depthwise_regularizer
=
self
.
_config_dict
[
'kernel_regularizer'
],
depth_multiplier
=
1
),
bn_op
(
**
bn_kwargs
),
conv_op
(
filters
=
self
.
_config_dict
[
'num_output_filters'
],
kernel_size
=
1
,
**
conv_kwargs
)])
else
:
fusion_conv
=
conv_op
(
filters
=
self
.
_config_dict
[
'num_output_filters'
],
kernel_size
=
5
,
**
conv_kwargs
)
self
.
_fusion_convs
.
append
(
fusion_conv
)
self
.
_projection_norms
.
append
(
bn_op
(
**
bn_kwargs
))
self
.
_projection_norms
.
append
(
bn_op
(
**
bn_kwargs
))
self
.
_fusion_norms
.
append
(
bn_op
(
**
bn_kwargs
))
self
.
_fusion_norms
.
append
(
bn_op
(
**
bn_kwargs
))
...
...
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