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
025149c1
Commit
025149c1
authored
May 07, 2019
by
ThangVu
Browse files
change frozen to requires_grad for clear behavior
parent
01e5ec51
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
29 additions
and
32 deletions
+29
-32
configs/cascade_mask_rcnn_r50_c4_1x.py
configs/cascade_mask_rcnn_r50_c4_1x.py
+2
-2
configs/cascade_rcnn_r50_c4_1x.py
configs/cascade_rcnn_r50_c4_1x.py
+2
-2
configs/fast_rcnn_r50_c4_1x.py
configs/fast_rcnn_r50_c4_1x.py
+2
-2
configs/faster_rcnn_r50_c4_1x.py
configs/faster_rcnn_r50_c4_1x.py
+2
-2
configs/gn+ws/faster_rcnn_r50_fpn_gn_ws_1x.py
configs/gn+ws/faster_rcnn_r50_fpn_gn_ws_1x.py
+1
-1
configs/gn+ws/mask_rcnn_r50_fpn_gn_ws_20_23_24e.py
configs/gn+ws/mask_rcnn_r50_fpn_gn_ws_20_23_24e.py
+1
-1
configs/gn+ws/mask_rcnn_r50_fpn_gn_ws_2x.py
configs/gn+ws/mask_rcnn_r50_fpn_gn_ws_2x.py
+1
-1
configs/gn+ws/mask_rcnn_x101_32x4d_fpn_gn_ws_2x.py
configs/gn+ws/mask_rcnn_x101_32x4d_fpn_gn_ws_2x.py
+1
-1
configs/gn/mask_rcnn_r101_fpn_gn_2x.py
configs/gn/mask_rcnn_r101_fpn_gn_2x.py
+1
-1
configs/gn/mask_rcnn_r50_fpn_gn_2x.py
configs/gn/mask_rcnn_r50_fpn_gn_2x.py
+1
-1
configs/gn/mask_rcnn_r50_fpn_gn_contrib_2x.py
configs/gn/mask_rcnn_r50_fpn_gn_contrib_2x.py
+1
-1
configs/mask_rcnn_r50_c4_1x.py
configs/mask_rcnn_r50_c4_1x.py
+2
-2
configs/rpn_r50_c4_1x.py
configs/rpn_r50_c4_1x.py
+1
-1
mmdet/models/backbones/resnet.py
mmdet/models/backbones/resnet.py
+3
-3
mmdet/models/shared_heads/res_layer.py
mmdet/models/shared_heads/res_layer.py
+1
-1
mmdet/models/utils/norm.py
mmdet/models/utils/norm.py
+7
-10
No files found.
configs/cascade_mask_rcnn_r50_c4_1x.py
View file @
025149c1
...
@@ -11,7 +11,7 @@ model = dict(
...
@@ -11,7 +11,7 @@ model = dict(
dilations
=
(
1
,
1
,
1
),
dilations
=
(
1
,
1
,
1
),
out_indices
=
(
2
,
),
out_indices
=
(
2
,
),
frozen_stages
=
1
,
frozen_stages
=
1
,
normalize
=
dict
(
type
=
'BN'
,
frozen
=
Tru
e
),
normalize
=
dict
(
type
=
'BN'
,
requires_grad
=
Fals
e
),
norm_eval
=
True
,
norm_eval
=
True
,
style
=
'caffe'
),
style
=
'caffe'
),
shared_head
=
dict
(
shared_head
=
dict
(
...
@@ -21,7 +21,7 @@ model = dict(
...
@@ -21,7 +21,7 @@ model = dict(
stride
=
2
,
stride
=
2
,
dilation
=
1
,
dilation
=
1
,
style
=
'caffe'
,
style
=
'caffe'
,
normalize
=
dict
(
type
=
'BN'
,
frozen
=
Tru
e
),
normalize
=
dict
(
type
=
'BN'
,
requires_grad
=
Fals
e
),
norm_eval
=
True
),
norm_eval
=
True
),
rpn_head
=
dict
(
rpn_head
=
dict
(
type
=
'RPNHead'
,
type
=
'RPNHead'
,
...
...
configs/cascade_rcnn_r50_c4_1x.py
View file @
025149c1
...
@@ -11,7 +11,7 @@ model = dict(
...
@@ -11,7 +11,7 @@ model = dict(
dilations
=
(
1
,
1
,
1
),
dilations
=
(
1
,
1
,
1
),
out_indices
=
(
2
,
),
out_indices
=
(
2
,
),
frozen_stages
=
1
,
frozen_stages
=
1
,
normalize
=
dict
(
type
=
'BN'
,
frozen
=
Tru
e
),
normalize
=
dict
(
type
=
'BN'
,
requires_grad
=
Fals
e
),
norm_eval
=
True
,
norm_eval
=
True
,
style
=
'caffe'
),
style
=
'caffe'
),
shared_head
=
dict
(
shared_head
=
dict
(
...
@@ -21,7 +21,7 @@ model = dict(
...
@@ -21,7 +21,7 @@ model = dict(
stride
=
2
,
stride
=
2
,
dilation
=
1
,
dilation
=
1
,
style
=
'caffe'
,
style
=
'caffe'
,
normalize
=
dict
(
type
=
'BN'
,
frozen
=
Tru
e
),
normalize
=
dict
(
type
=
'BN'
,
requires_grad
=
Fals
e
),
norm_eval
=
True
),
norm_eval
=
True
),
rpn_head
=
dict
(
rpn_head
=
dict
(
type
=
'RPNHead'
,
type
=
'RPNHead'
,
...
...
configs/fast_rcnn_r50_c4_1x.py
View file @
025149c1
...
@@ -10,7 +10,7 @@ model = dict(
...
@@ -10,7 +10,7 @@ model = dict(
dilations
=
(
1
,
1
,
1
),
dilations
=
(
1
,
1
,
1
),
out_indices
=
(
2
,
),
out_indices
=
(
2
,
),
frozen_stages
=
1
,
frozen_stages
=
1
,
normalize
=
dict
(
type
=
'BN'
,
frozen
=
Tru
e
),
normalize
=
dict
(
type
=
'BN'
,
requires_grad
=
Fals
e
),
norm_eval
=
True
,
norm_eval
=
True
,
style
=
'caffe'
),
style
=
'caffe'
),
shared_head
=
dict
(
shared_head
=
dict
(
...
@@ -20,7 +20,7 @@ model = dict(
...
@@ -20,7 +20,7 @@ model = dict(
stride
=
2
,
stride
=
2
,
dilation
=
1
,
dilation
=
1
,
style
=
'caffe'
,
style
=
'caffe'
,
normalize
=
dict
(
type
=
'BN'
,
frozen
=
Tru
e
),
normalize
=
dict
(
type
=
'BN'
,
requires_grad
=
Fals
e
),
norm_eval
=
True
),
norm_eval
=
True
),
bbox_roi_extractor
=
dict
(
bbox_roi_extractor
=
dict
(
type
=
'SingleRoIExtractor'
,
type
=
'SingleRoIExtractor'
,
...
...
configs/faster_rcnn_r50_c4_1x.py
View file @
025149c1
...
@@ -10,7 +10,7 @@ model = dict(
...
@@ -10,7 +10,7 @@ model = dict(
dilations
=
(
1
,
1
,
1
),
dilations
=
(
1
,
1
,
1
),
out_indices
=
(
2
,
),
out_indices
=
(
2
,
),
frozen_stages
=
1
,
frozen_stages
=
1
,
normalize
=
dict
(
type
=
'BN'
,
frozen
=
Tru
e
),
normalize
=
dict
(
type
=
'BN'
,
requires_grad
=
Fals
e
),
norm_eval
=
True
,
norm_eval
=
True
,
style
=
'caffe'
),
style
=
'caffe'
),
shared_head
=
dict
(
shared_head
=
dict
(
...
@@ -20,7 +20,7 @@ model = dict(
...
@@ -20,7 +20,7 @@ model = dict(
stride
=
2
,
stride
=
2
,
dilation
=
1
,
dilation
=
1
,
style
=
'caffe'
,
style
=
'caffe'
,
normalize
=
dict
(
type
=
'BN'
,
frozen
=
Tru
e
),
normalize
=
dict
(
type
=
'BN'
,
requires_grad
=
Fals
e
),
norm_eval
=
True
),
norm_eval
=
True
),
rpn_head
=
dict
(
rpn_head
=
dict
(
type
=
'RPNHead'
,
type
=
'RPNHead'
,
...
...
configs/gn+ws/faster_rcnn_r50_fpn_gn_ws_1x.py
View file @
025149c1
# model settings
# model settings
conv_cfg
=
dict
(
type
=
'ConvWS'
)
conv_cfg
=
dict
(
type
=
'ConvWS'
)
normalize
=
dict
(
type
=
'GN'
,
num_groups
=
32
,
frozen
=
Fals
e
)
normalize
=
dict
(
type
=
'GN'
,
num_groups
=
32
,
requires_grad
=
Tru
e
)
model
=
dict
(
model
=
dict
(
type
=
'FasterRCNN'
,
type
=
'FasterRCNN'
,
pretrained
=
'open-mmlab://jhu/resnet50_gn_ws'
,
pretrained
=
'open-mmlab://jhu/resnet50_gn_ws'
,
...
...
configs/gn+ws/mask_rcnn_r50_fpn_gn_ws_20_23_24e.py
View file @
025149c1
# model settings
# model settings
conv_cfg
=
dict
(
type
=
'ConvWS'
)
conv_cfg
=
dict
(
type
=
'ConvWS'
)
normalize
=
dict
(
type
=
'GN'
,
num_groups
=
32
,
frozen
=
Fals
e
)
normalize
=
dict
(
type
=
'GN'
,
num_groups
=
32
,
requires_grad
=
Tru
e
)
model
=
dict
(
model
=
dict
(
type
=
'MaskRCNN'
,
type
=
'MaskRCNN'
,
pretrained
=
'open-mmlab://jhu/resnet50_gn_ws'
,
pretrained
=
'open-mmlab://jhu/resnet50_gn_ws'
,
...
...
configs/gn+ws/mask_rcnn_r50_fpn_gn_ws_2x.py
View file @
025149c1
# model settings
# model settings
conv_cfg
=
dict
(
type
=
'ConvWS'
)
conv_cfg
=
dict
(
type
=
'ConvWS'
)
normalize
=
dict
(
type
=
'GN'
,
num_groups
=
32
,
frozen
=
Fals
e
)
normalize
=
dict
(
type
=
'GN'
,
num_groups
=
32
,
requires_grad
=
Tru
e
)
model
=
dict
(
model
=
dict
(
type
=
'MaskRCNN'
,
type
=
'MaskRCNN'
,
pretrained
=
'open-mmlab://jhu/resnet50_gn_ws'
,
pretrained
=
'open-mmlab://jhu/resnet50_gn_ws'
,
...
...
configs/gn+ws/mask_rcnn_x101_32x4d_fpn_gn_ws_2x.py
View file @
025149c1
# model settings
# model settings
conv_cfg
=
dict
(
type
=
'ConvWS'
)
conv_cfg
=
dict
(
type
=
'ConvWS'
)
normalize
=
dict
(
type
=
'GN'
,
num_groups
=
32
,
frozen
=
Fals
e
)
normalize
=
dict
(
type
=
'GN'
,
num_groups
=
32
,
requires_grad
=
Tru
e
)
model
=
dict
(
model
=
dict
(
type
=
'MaskRCNN'
,
type
=
'MaskRCNN'
,
pretrained
=
'open-mmlab://jhu/resnext101_32x4d_gn_ws'
,
pretrained
=
'open-mmlab://jhu/resnext101_32x4d_gn_ws'
,
...
...
configs/gn/mask_rcnn_r101_fpn_gn_2x.py
View file @
025149c1
# model settings
# model settings
normalize
=
dict
(
type
=
'GN'
,
num_groups
=
32
,
frozen
=
Fals
e
)
normalize
=
dict
(
type
=
'GN'
,
num_groups
=
32
,
requires_grad
=
Tru
e
)
model
=
dict
(
model
=
dict
(
type
=
'MaskRCNN'
,
type
=
'MaskRCNN'
,
...
...
configs/gn/mask_rcnn_r50_fpn_gn_2x.py
View file @
025149c1
# model settings
# model settings
normalize
=
dict
(
type
=
'GN'
,
num_groups
=
32
,
frozen
=
Fals
e
)
normalize
=
dict
(
type
=
'GN'
,
num_groups
=
32
,
requires_grad
=
Tru
e
)
model
=
dict
(
model
=
dict
(
type
=
'MaskRCNN'
,
type
=
'MaskRCNN'
,
...
...
configs/gn/mask_rcnn_r50_fpn_gn_contrib_2x.py
View file @
025149c1
# model settings
# model settings
normalize
=
dict
(
type
=
'GN'
,
num_groups
=
32
,
frozen
=
Fals
e
)
normalize
=
dict
(
type
=
'GN'
,
num_groups
=
32
,
requires_grad
=
Tru
e
)
model
=
dict
(
model
=
dict
(
type
=
'MaskRCNN'
,
type
=
'MaskRCNN'
,
...
...
configs/mask_rcnn_r50_c4_1x.py
View file @
025149c1
...
@@ -10,7 +10,7 @@ model = dict(
...
@@ -10,7 +10,7 @@ model = dict(
dilations
=
(
1
,
1
,
1
),
dilations
=
(
1
,
1
,
1
),
out_indices
=
(
2
,
),
out_indices
=
(
2
,
),
frozen_stages
=
1
,
frozen_stages
=
1
,
normalize
=
dict
(
type
=
'BN'
,
frozen
=
Tru
e
),
normalize
=
dict
(
type
=
'BN'
,
requires_grad
=
Fals
e
),
norm_eval
=
True
,
norm_eval
=
True
,
style
=
'caffe'
),
style
=
'caffe'
),
shared_head
=
dict
(
shared_head
=
dict
(
...
@@ -20,7 +20,7 @@ model = dict(
...
@@ -20,7 +20,7 @@ model = dict(
stride
=
2
,
stride
=
2
,
dilation
=
1
,
dilation
=
1
,
style
=
'caffe'
,
style
=
'caffe'
,
normalize
=
dict
(
type
=
'BN'
,
frozen
=
Tru
e
),
normalize
=
dict
(
type
=
'BN'
,
requires_grad
=
Fals
e
),
norm_eval
=
True
),
norm_eval
=
True
),
rpn_head
=
dict
(
rpn_head
=
dict
(
type
=
'RPNHead'
,
type
=
'RPNHead'
,
...
...
configs/rpn_r50_c4_1x.py
View file @
025149c1
...
@@ -10,7 +10,7 @@ model = dict(
...
@@ -10,7 +10,7 @@ model = dict(
dilations
=
(
1
,
1
,
1
),
dilations
=
(
1
,
1
,
1
),
out_indices
=
(
2
,
),
out_indices
=
(
2
,
),
frozen_stages
=
1
,
frozen_stages
=
1
,
normalize
=
dict
(
type
=
'BN'
,
frozen
=
Tru
e
),
normalize
=
dict
(
type
=
'BN'
,
requires_grad
=
Fals
e
),
norm_eval
=
True
,
norm_eval
=
True
,
style
=
'caffe'
),
style
=
'caffe'
),
neck
=
None
,
neck
=
None
,
...
...
mmdet/models/backbones/resnet.py
View file @
025149c1
...
@@ -307,8 +307,8 @@ class ResNet(nn.Module):
...
@@ -307,8 +307,8 @@ class ResNet(nn.Module):
style (str): `pytorch` or `caffe`. If set to "pytorch", the stride-two
style (str): `pytorch` or `caffe`. If set to "pytorch", the stride-two
layer is the 3x3 conv layer, otherwise the stride-two layer is
layer is the 3x3 conv layer, otherwise the stride-two layer is
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 (
stop grad and set eval mode).
not freezing any parameters.
-1 means
not freezing any parameters.
normalize (dict): dictionary to construct and config norm layer.
normalize (dict): dictionary to construct and config norm layer.
norm_eval (bool): Whether to set norm layers to eval mode, namely,
norm_eval (bool): Whether to set norm layers to eval mode, namely,
freeze running stats (mean and var). Note: Effect on Batch Norm
freeze running stats (mean and var). Note: Effect on Batch Norm
...
@@ -336,7 +336,7 @@ class ResNet(nn.Module):
...
@@ -336,7 +336,7 @@ class ResNet(nn.Module):
style
=
'pytorch'
,
style
=
'pytorch'
,
frozen_stages
=-
1
,
frozen_stages
=-
1
,
conv_cfg
=
None
,
conv_cfg
=
None
,
normalize
=
dict
(
type
=
'BN'
,
frozen
=
Fals
e
),
normalize
=
dict
(
type
=
'BN'
,
requires_grad
=
Tru
e
),
norm_eval
=
True
,
norm_eval
=
True
,
dcn
=
None
,
dcn
=
None
,
stage_with_dcn
=
(
False
,
False
,
False
,
False
),
stage_with_dcn
=
(
False
,
False
,
False
,
False
),
...
...
mmdet/models/shared_heads/res_layer.py
View file @
025149c1
...
@@ -17,7 +17,7 @@ class ResLayer(nn.Module):
...
@@ -17,7 +17,7 @@ class ResLayer(nn.Module):
stride
=
2
,
stride
=
2
,
dilation
=
1
,
dilation
=
1
,
style
=
'pytorch'
,
style
=
'pytorch'
,
normalize
=
dict
(
type
=
'BN'
,
frozen
=
Fals
e
),
normalize
=
dict
(
type
=
'BN'
,
requires_grad
=
Tru
e
),
norm_eval
=
True
,
norm_eval
=
True
,
with_cp
=
False
,
with_cp
=
False
,
dcn
=
None
):
dcn
=
None
):
...
...
mmdet/models/utils/norm.py
View file @
025149c1
...
@@ -17,15 +17,13 @@ def build_norm_layer(cfg, num_features, postfix=''):
...
@@ -17,15 +17,13 @@ def build_norm_layer(cfg, num_features, postfix=''):
cfg (dict): cfg should contain:
cfg (dict): cfg should contain:
type (str): identify norm layer type.
type (str): identify norm layer type.
layer args: args needed to instantiate a norm layer.
layer args: args needed to instantiate a norm layer.
frozen (bool): [optional] whether stop gradient updates
requires_grad (bool): [optional] whether stop gradient updates
of norm layer, it is helpful to set frozen mode
num_features (int): number of channels from input.
in backbone's norms.
postfix (int, str): appended into norm abbreviation to
num_features (int): number of channels from input
postfix (int, str): appended into norm abbreation to
create named layer.
create named layer.
Returns:
Returns:
name (str): abbreation + postfix
name (str): abbre
vi
ation + postfix
layer (nn.Module): created norm layer
layer (nn.Module): created norm layer
"""
"""
assert
isinstance
(
cfg
,
dict
)
and
'type'
in
cfg
assert
isinstance
(
cfg
,
dict
)
and
'type'
in
cfg
...
@@ -42,7 +40,7 @@ def build_norm_layer(cfg, num_features, postfix=''):
...
@@ -42,7 +40,7 @@ def build_norm_layer(cfg, num_features, postfix=''):
assert
isinstance
(
postfix
,
(
int
,
str
))
assert
isinstance
(
postfix
,
(
int
,
str
))
name
=
abbr
+
str
(
postfix
)
name
=
abbr
+
str
(
postfix
)
frozen
=
cfg_
.
pop
(
'frozen'
,
Fals
e
)
requires_grad
=
cfg_
.
pop
(
'requires_grad'
,
Tru
e
)
cfg_
.
setdefault
(
'eps'
,
1e-5
)
cfg_
.
setdefault
(
'eps'
,
1e-5
)
if
layer_type
!=
'GN'
:
if
layer_type
!=
'GN'
:
layer
=
norm_layer
(
num_features
,
**
cfg_
)
layer
=
norm_layer
(
num_features
,
**
cfg_
)
...
@@ -50,8 +48,7 @@ def build_norm_layer(cfg, num_features, postfix=''):
...
@@ -50,8 +48,7 @@ def build_norm_layer(cfg, num_features, postfix=''):
assert
'num_groups'
in
cfg_
assert
'num_groups'
in
cfg_
layer
=
norm_layer
(
num_channels
=
num_features
,
**
cfg_
)
layer
=
norm_layer
(
num_channels
=
num_features
,
**
cfg_
)
if
frozen
:
for
param
in
layer
.
parameters
():
for
param
in
layer
.
parameters
():
param
.
requires_grad
=
requires_grad
param
.
requires_grad
=
False
return
name
,
layer
return
name
,
layer
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