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
SOLOv2-pytorch
Commits
82e75455
"python/vscode:/vscode.git/clone" did not exist on "849c83a0c099edd18727c11341c064ecffca08ba"
Commit
82e75455
authored
Jan 10, 2019
by
thangvu
Committed by
ThangVu
Jan 10, 2019
Browse files
revise norm config
parent
55a4feb5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
33 deletions
+23
-33
configs/mask_rcnn_r50_fpn_gn_2x.py
configs/mask_rcnn_r50_fpn_gn_2x.py
+9
-15
mmdet/models/backbones/resnet.py
mmdet/models/backbones/resnet.py
+8
-8
mmdet/models/backbones/resnext.py
mmdet/models/backbones/resnext.py
+6
-3
mmdet/models/utils/norm.py
mmdet/models/utils/norm.py
+0
-7
No files found.
configs/mask_rcnn_r50_fpn_gn_2x.py
View file @
82e75455
# model settings
# model settings
normalize
=
dict
(
type
=
'GN'
,
num_groups
=
32
,
frozen
=
False
)
model
=
dict
(
model
=
dict
(
type
=
'MaskRCNN'
,
type
=
'MaskRCNN'
,
pretrained
=
'tools/resnet50-GN.path'
,
pretrained
=
'tools/resnet50-GN.path'
,
...
@@ -9,20 +14,13 @@ model = dict(
...
@@ -9,20 +14,13 @@ model = dict(
out_indices
=
(
0
,
1
,
2
,
3
),
out_indices
=
(
0
,
1
,
2
,
3
),
frozen_stages
=
1
,
frozen_stages
=
1
,
style
=
'pytorch'
,
style
=
'pytorch'
,
# Note: eval_mode and frozen are required args for backbone
normalize
=
normalize
),
normalize
=
dict
(
type
=
'GN'
,
num_groups
=
32
,
eval_mode
=
False
,
frozen
=
False
)),
neck
=
dict
(
neck
=
dict
(
type
=
'FPN'
,
type
=
'FPN'
,
in_channels
=
[
256
,
512
,
1024
,
2048
],
in_channels
=
[
256
,
512
,
1024
,
2048
],
out_channels
=
256
,
out_channels
=
256
,
num_outs
=
5
,
num_outs
=
5
,
normalize
=
dict
(
normalize
=
normalize
),
type
=
'GN'
,
num_groups
=
32
)),
rpn_head
=
dict
(
rpn_head
=
dict
(
type
=
'RPNHead'
,
type
=
'RPNHead'
,
in_channels
=
256
,
in_channels
=
256
,
...
@@ -50,9 +48,7 @@ model = dict(
...
@@ -50,9 +48,7 @@ model = dict(
target_means
=
[
0.
,
0.
,
0.
,
0.
],
target_means
=
[
0.
,
0.
,
0.
,
0.
],
target_stds
=
[
0.1
,
0.1
,
0.2
,
0.2
],
target_stds
=
[
0.1
,
0.1
,
0.2
,
0.2
],
reg_class_agnostic
=
False
,
reg_class_agnostic
=
False
,
normalize
=
dict
(
normalize
=
normalize
),
type
=
'GN'
,
num_groups
=
32
)),
mask_roi_extractor
=
dict
(
mask_roi_extractor
=
dict
(
type
=
'SingleRoIExtractor'
,
type
=
'SingleRoIExtractor'
,
roi_layer
=
dict
(
type
=
'RoIAlign'
,
out_size
=
14
,
sample_num
=
2
),
roi_layer
=
dict
(
type
=
'RoIAlign'
,
out_size
=
14
,
sample_num
=
2
),
...
@@ -64,9 +60,7 @@ model = dict(
...
@@ -64,9 +60,7 @@ model = dict(
in_channels
=
256
,
in_channels
=
256
,
conv_out_channels
=
256
,
conv_out_channels
=
256
,
num_classes
=
81
,
num_classes
=
81
,
normalize
=
dict
(
normalize
=
normalize
))
type
=
'GN'
,
num_groups
=
32
)))
# model training and testing settings
# model training and testing settings
train_cfg
=
dict
(
train_cfg
=
dict
(
...
...
mmdet/models/backbones/resnet.py
View file @
82e75455
...
@@ -236,11 +236,14 @@ class ResNet(nn.Module):
...
@@ -236,11 +236,14 @@ class ResNet(nn.Module):
the first 1x1 conv layer.
the first 1x1 conv layer.
frozen_stages (int): Stages to be frozen (all param fixed). -1 means
frozen_stages (int): Stages to be frozen (all param fixed). -1 means
not freezing any parameters.
not freezing any parameters.
normalize (dict): dictionary to construct norm layer. Additionally,
normalize (dict): dictionary to construct and config norm layer.
eval mode and gradent freezing are controlled by
norm_eval (bool): Whether to set norm layers to eval mode, namely,
eval (bool) and frozen (bool) respectively.
freeze running stats (mean and var). Note: Effect on Batch Norm
and its variants only.
with_cp (bool): Use checkpoint or not. Using checkpoint will save some
with_cp (bool): Use checkpoint or not. Using checkpoint will save some
memory while slowing down the training speed.
memory while slowing down the training speed.
zero_init_residual (bool): whether to use zero init for last norm layer
in resblocks to let them behave as identity.
"""
"""
arch_settings
=
{
arch_settings
=
{
...
@@ -261,8 +264,8 @@ class ResNet(nn.Module):
...
@@ -261,8 +264,8 @@ class ResNet(nn.Module):
frozen_stages
=-
1
,
frozen_stages
=-
1
,
normalize
=
dict
(
normalize
=
dict
(
type
=
'BN'
,
type
=
'BN'
,
eval_mode
=
True
,
frozen
=
False
),
frozen
=
False
),
norm_eval
=
True
,
with_cp
=
False
,
with_cp
=
False
,
zero_init_residual
=
True
):
zero_init_residual
=
True
):
super
(
ResNet
,
self
).
__init__
()
super
(
ResNet
,
self
).
__init__
()
...
@@ -278,11 +281,9 @@ class ResNet(nn.Module):
...
@@ -278,11 +281,9 @@ class ResNet(nn.Module):
assert
max
(
out_indices
)
<
num_stages
assert
max
(
out_indices
)
<
num_stages
self
.
style
=
style
self
.
style
=
style
self
.
frozen_stages
=
frozen_stages
self
.
frozen_stages
=
frozen_stages
assert
(
isinstance
(
normalize
,
dict
)
and
'eval_mode'
in
normalize
and
'frozen'
in
normalize
)
self
.
norm_eval
=
normalize
.
pop
(
'eval_mode'
)
self
.
normalize
=
normalize
self
.
normalize
=
normalize
self
.
with_cp
=
with_cp
self
.
with_cp
=
with_cp
self
.
norm_eval
=
norm_eval
self
.
zero_init_residual
=
zero_init_residual
self
.
zero_init_residual
=
zero_init_residual
self
.
block
,
stage_blocks
=
self
.
arch_settings
[
depth
]
self
.
block
,
stage_blocks
=
self
.
arch_settings
[
depth
]
self
.
stage_blocks
=
stage_blocks
[:
num_stages
]
self
.
stage_blocks
=
stage_blocks
[:
num_stages
]
...
@@ -350,7 +351,6 @@ class ResNet(nn.Module):
...
@@ -350,7 +351,6 @@ class ResNet(nn.Module):
elif
isinstance
(
m
,
(
nn
.
BatchNorm2d
,
nn
.
GroupNorm
)):
elif
isinstance
(
m
,
(
nn
.
BatchNorm2d
,
nn
.
GroupNorm
)):
constant_init
(
m
,
1
)
constant_init
(
m
,
1
)
# zero init for last norm layer https://arxiv.org/abs/1706.02677
if
self
.
zero_init_residual
:
if
self
.
zero_init_residual
:
for
m
in
self
.
modules
():
for
m
in
self
.
modules
():
if
isinstance
(
m
,
Bottleneck
):
if
isinstance
(
m
,
Bottleneck
):
...
...
mmdet/models/backbones/resnext.py
View file @
82e75455
...
@@ -122,11 +122,14 @@ class ResNeXt(ResNet):
...
@@ -122,11 +122,14 @@ class ResNeXt(ResNet):
the first 1x1 conv layer.
the first 1x1 conv layer.
frozen_stages (int): Stages to be frozen (all param fixed). -1 means
frozen_stages (int): Stages to be frozen (all param fixed). -1 means
not freezing any parameters.
not freezing any parameters.
normalize (dict): dictionary to construct norm layer. Additionally,
normalize (dict): dictionary to construct and config norm layer.
eval mode and gradent freezing are controlled by
norm_eval (bool): Whether to set norm layers to eval mode, namely,
eval (bool) and frozen (bool) respectively.
freeze running stats (mean and var). Note: Effect on Batch Norm
and its variants only.
with_cp (bool): Use checkpoint or not. Using checkpoint will save some
with_cp (bool): Use checkpoint or not. Using checkpoint will save some
memory while slowing down the training speed.
memory while slowing down the training speed.
zero_init_residual (bool): whether to use zero init for last norm layer
in resblocks to let them behave as identity.
"""
"""
arch_settings
=
{
arch_settings
=
{
...
...
mmdet/models/utils/norm.py
View file @
82e75455
...
@@ -31,13 +31,6 @@ def build_norm_layer(cfg, num_features, postfix=''):
...
@@ -31,13 +31,6 @@ def build_norm_layer(cfg, num_features, postfix=''):
assert
isinstance
(
cfg
,
dict
)
and
'type'
in
cfg
assert
isinstance
(
cfg
,
dict
)
and
'type'
in
cfg
cfg_
=
cfg
.
copy
()
cfg_
=
cfg
.
copy
()
# eval_mode is supported and popped out for processing in module
# having pretrained weight only (e.g. backbone)
# raise an exception if eval_mode is in here
if
'eval_mode'
in
cfg
:
raise
Exception
(
'eval_mode for modules without pretrained weights '
'is not supported'
)
layer_type
=
cfg_
.
pop
(
'type'
)
layer_type
=
cfg_
.
pop
(
'type'
)
if
layer_type
not
in
norm_cfg
:
if
layer_type
not
in
norm_cfg
:
raise
KeyError
(
'Unrecognized norm type {}'
.
format
(
layer_type
))
raise
KeyError
(
'Unrecognized norm type {}'
.
format
(
layer_type
))
...
...
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