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
bee93859
Commit
bee93859
authored
Jan 04, 2019
by
ThangVu
Browse files
revise group norm (5)
parent
574a920a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
3 deletions
+11
-3
configs/mask_rcnn_r50_fpn_gn_2x.py
configs/mask_rcnn_r50_fpn_gn_2x.py
+1
-0
mmdet/models/backbones/resnet.py
mmdet/models/backbones/resnet.py
+3
-3
mmdet/models/utils/norm.py
mmdet/models/utils/norm.py
+7
-0
No files found.
configs/mask_rcnn_r50_fpn_gn_2x.py
View file @
bee93859
...
@@ -9,6 +9,7 @@ model = dict(
...
@@ -9,6 +9,7 @@ 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
=
dict
(
normalize
=
dict
(
type
=
'GN'
,
type
=
'GN'
,
num_groups
=
32
,
num_groups
=
32
,
...
...
mmdet/models/backbones/resnet.py
View file @
bee93859
...
@@ -37,8 +37,8 @@ class BasicBlock(nn.Module):
...
@@ -37,8 +37,8 @@ class BasicBlock(nn.Module):
self
.
norm1_name
,
norm1
=
build_norm_layer
(
normalize
,
planes
,
postfix
=
1
)
self
.
norm1_name
,
norm1
=
build_norm_layer
(
normalize
,
planes
,
postfix
=
1
)
self
.
norm2_name
,
norm2
=
build_norm_layer
(
normalize
,
planes
,
postfix
=
2
)
self
.
norm2_name
,
norm2
=
build_norm_layer
(
normalize
,
planes
,
postfix
=
2
)
self
.
add_module
(
self
.
norm1
,
norm1
)
self
.
add_module
(
self
.
norm1
_name
,
norm1
)
self
.
add_module
(
self
.
norm2
,
norm2
)
self
.
add_module
(
self
.
norm2
_name
,
norm2
)
self
.
relu
=
nn
.
ReLU
(
inplace
=
True
)
self
.
relu
=
nn
.
ReLU
(
inplace
=
True
)
self
.
conv2
=
conv3x3
(
planes
,
planes
)
self
.
conv2
=
conv3x3
(
planes
,
planes
)
...
@@ -325,12 +325,12 @@ class ResNet(nn.Module):
...
@@ -325,12 +325,12 @@ class ResNet(nn.Module):
self
.
relu
=
nn
.
ReLU
(
inplace
=
True
)
self
.
relu
=
nn
.
ReLU
(
inplace
=
True
)
self
.
maxpool
=
nn
.
MaxPool2d
(
kernel_size
=
3
,
stride
=
2
,
padding
=
1
)
self
.
maxpool
=
nn
.
MaxPool2d
(
kernel_size
=
3
,
stride
=
2
,
padding
=
1
)
def
_freeze_stages
(
self
):
if
self
.
frozen_stages
>=
0
:
if
self
.
frozen_stages
>=
0
:
for
m
in
[
self
.
conv1
,
self
.
norm1
]:
for
m
in
[
self
.
conv1
,
self
.
norm1
]:
for
param
in
m
.
parameters
():
for
param
in
m
.
parameters
():
param
.
requires_grad
=
False
param
.
requires_grad
=
False
def
_freeze_stages
(
self
):
for
i
in
range
(
1
,
self
.
frozen_stages
+
1
):
for
i
in
range
(
1
,
self
.
frozen_stages
+
1
):
m
=
getattr
(
self
,
'layer{}'
.
format
(
i
))
m
=
getattr
(
self
,
'layer{}'
.
format
(
i
))
for
param
in
m
.
parameters
():
for
param
in
m
.
parameters
():
...
...
mmdet/models/utils/norm.py
View file @
bee93859
...
@@ -31,6 +31,13 @@ def build_norm_layer(cfg, num_features, postfix=''):
...
@@ -31,6 +31,13 @@ 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