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
25015e1b
Commit
25015e1b
authored
Dec 10, 2018
by
ThangVu
Browse files
add group norm support
parent
2b17166a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
7 deletions
+19
-7
mmdet/models/bbox_heads/convfc_bbox_head.py
mmdet/models/bbox_heads/convfc_bbox_head.py
+10
-4
mmdet/models/necks/fpn.py
mmdet/models/necks/fpn.py
+1
-1
mmdet/models/utils/norm.py
mmdet/models/utils/norm.py
+8
-2
No files found.
mmdet/models/bbox_heads/convfc_bbox_head.py
View file @
25015e1b
import
torch.nn
as
nn
from
.bbox_head
import
BBoxHead
from
..utils
import
ConvModule
from
..utils
import
ConvModule
,
build_norm_layer
class
ConvFCBBoxHead
(
BBoxHead
):
...
...
@@ -113,8 +113,13 @@ class ConvFCBBoxHead(BBoxHead):
for
i
in
range
(
num_branch_fcs
):
fc_in_channels
=
(
last_layer_dim
if
i
==
0
else
self
.
fc_out_channels
)
branch_fcs
.
append
(
nn
.
Linear
(
fc_in_channels
,
self
.
fc_out_channels
))
if
self
.
normalize
is
not
None
:
branch_fcs
.
append
(
nn
.
Sequential
(
nn
.
Linear
(
fc_in_channels
,
self
.
fc_out_channels
,
False
),
build_norm_layer
(
self
.
normalize
,
self
.
fc_out_channels
)))
else
:
branch_fcs
.
append
(
nn
.
Linear
(
fc_in_channels
,
self
.
fc_out_channels
))
last_layer_dim
=
self
.
fc_out_channels
return
branch_convs
,
branch_fcs
,
last_layer_dim
...
...
@@ -124,7 +129,8 @@ class ConvFCBBoxHead(BBoxHead):
for
m
in
module_list
.
modules
():
if
isinstance
(
m
,
nn
.
Linear
):
nn
.
init
.
xavier_uniform_
(
m
.
weight
)
nn
.
init
.
constant_
(
m
.
bias
,
0
)
if
m
.
bias
is
not
None
:
nn
.
init
.
constant_
(
m
.
bias
,
0
)
def
forward
(
self
,
x
):
# shared part
...
...
mmdet/models/necks/fpn.py
View file @
25015e1b
import
torch.nn
as
nn
import
torch.nn.functional
as
F
from
..utils
import
ConvModule
from
..utils
import
xavier_init
from
mmcv.cnn
import
xavier_init
class
FPN
(
nn
.
Module
):
...
...
mmdet/models/utils/norm.py
View file @
25015e1b
import
torch.nn
as
nn
norm_cfg
=
{
'BN'
:
nn
.
BatchNorm2d
,
'SyncBN'
:
None
,
'GN'
:
None
}
norm_cfg
=
{
'BN'
:
nn
.
BatchNorm2d
,
'SyncBN'
:
None
,
'GN'
:
nn
.
GroupNorm
}
def
build_norm_layer
(
cfg
,
num_features
):
...
...
@@ -9,9 +9,15 @@ def build_norm_layer(cfg, num_features):
cfg_
.
setdefault
(
'eps'
,
1e-5
)
layer_type
=
cfg_
.
pop
(
'type'
)
# args name matching
if
layer_type
==
'GN'
:
cfg_
.
setdefault
(
'num_channels'
,
num_features
)
else
:
cfg_
.
setdefault
(
'num_features'
,
num_features
)
if
layer_type
not
in
norm_cfg
:
raise
KeyError
(
'Unrecognized norm type {}'
.
format
(
layer_type
))
elif
norm_cfg
[
layer_type
]
is
None
:
raise
NotImplementedError
return
norm_cfg
[
layer_type
](
num_features
,
**
cfg_
)
return
norm_cfg
[
layer_type
](
**
cfg_
)
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