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
55a4feb5
Commit
55a4feb5
authored
Jan 10, 2019
by
thangvu
Browse files
revise norm order in backbone resblocks and minor fix
parent
bc5ec9bf
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
15 deletions
+17
-15
mmdet/models/backbones/resnet.py
mmdet/models/backbones/resnet.py
+13
-11
mmdet/models/backbones/resnext.py
mmdet/models/backbones/resnext.py
+3
-3
mmdet/models/utils/norm.py
mmdet/models/utils/norm.py
+1
-1
No files found.
mmdet/models/backbones/resnet.py
View file @
55a4feb5
...
@@ -33,15 +33,16 @@ class BasicBlock(nn.Module):
...
@@ -33,15 +33,16 @@ class BasicBlock(nn.Module):
with_cp
=
False
,
with_cp
=
False
,
normalize
=
dict
(
type
=
'BN'
)):
normalize
=
dict
(
type
=
'BN'
)):
super
(
BasicBlock
,
self
).
__init__
()
super
(
BasicBlock
,
self
).
__init__
()
self
.
conv1
=
conv3x3
(
inplanes
,
planes
,
stride
,
dilation
)
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
.
conv1
=
conv3x3
(
inplanes
,
planes
,
stride
,
dilation
)
self
.
add_module
(
self
.
norm1_name
,
norm1
)
self
.
add_module
(
self
.
norm1_name
,
norm1
)
self
.
conv2
=
conv3x3
(
planes
,
planes
)
self
.
add_module
(
self
.
norm2_name
,
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
.
downsample
=
downsample
self
.
downsample
=
downsample
self
.
stride
=
stride
self
.
stride
=
stride
self
.
dilation
=
dilation
self
.
dilation
=
dilation
...
@@ -101,12 +102,20 @@ class Bottleneck(nn.Module):
...
@@ -101,12 +102,20 @@ class Bottleneck(nn.Module):
else
:
else
:
self
.
conv1_stride
=
stride
self
.
conv1_stride
=
stride
self
.
conv2_stride
=
1
self
.
conv2_stride
=
1
self
.
norm1_name
,
norm1
=
build_norm_layer
(
normalize
,
planes
,
postfix
=
1
)
self
.
norm2_name
,
norm2
=
build_norm_layer
(
normalize
,
planes
,
postfix
=
2
)
self
.
norm3_name
,
norm3
=
build_norm_layer
(
normalize
,
planes
*
self
.
expansion
,
postfix
=
3
)
self
.
conv1
=
nn
.
Conv2d
(
self
.
conv1
=
nn
.
Conv2d
(
inplanes
,
inplanes
,
planes
,
planes
,
kernel_size
=
1
,
kernel_size
=
1
,
stride
=
self
.
conv1_stride
,
stride
=
self
.
conv1_stride
,
bias
=
False
)
bias
=
False
)
self
.
add_module
(
self
.
norm1_name
,
norm1
)
self
.
conv2
=
nn
.
Conv2d
(
self
.
conv2
=
nn
.
Conv2d
(
planes
,
planes
,
planes
,
planes
,
...
@@ -115,18 +124,11 @@ class Bottleneck(nn.Module):
...
@@ -115,18 +124,11 @@ class Bottleneck(nn.Module):
padding
=
dilation
,
padding
=
dilation
,
dilation
=
dilation
,
dilation
=
dilation
,
bias
=
False
)
bias
=
False
)
self
.
norm1_name
,
norm1
=
build_norm_layer
(
normalize
,
planes
,
postfix
=
1
)
self
.
norm2_name
,
norm2
=
build_norm_layer
(
normalize
,
planes
,
postfix
=
2
)
self
.
norm3_name
,
norm3
=
build_norm_layer
(
normalize
,
planes
*
self
.
expansion
,
postfix
=
3
)
self
.
add_module
(
self
.
norm1_name
,
norm1
)
self
.
add_module
(
self
.
norm2_name
,
norm2
)
self
.
add_module
(
self
.
norm2_name
,
norm2
)
self
.
add_module
(
self
.
norm3_name
,
norm3
)
self
.
conv3
=
nn
.
Conv2d
(
self
.
conv3
=
nn
.
Conv2d
(
planes
,
planes
*
self
.
expansion
,
kernel_size
=
1
,
bias
=
False
)
planes
,
planes
*
self
.
expansion
,
kernel_size
=
1
,
bias
=
False
)
self
.
add_module
(
self
.
norm3_name
,
norm3
)
self
.
relu
=
nn
.
ReLU
(
inplace
=
True
)
self
.
relu
=
nn
.
ReLU
(
inplace
=
True
)
self
.
downsample
=
downsample
self
.
downsample
=
downsample
self
.
stride
=
stride
self
.
stride
=
stride
...
...
mmdet/models/backbones/resnext.py
View file @
55a4feb5
...
@@ -30,9 +30,6 @@ class Bottleneck(_Bottleneck):
...
@@ -30,9 +30,6 @@ class Bottleneck(_Bottleneck):
self
.
norm3_name
,
norm3
=
build_norm_layer
(
self
.
normalize
,
self
.
norm3_name
,
norm3
=
build_norm_layer
(
self
.
normalize
,
self
.
planes
*
self
.
expansion
,
self
.
planes
*
self
.
expansion
,
postfix
=
3
)
postfix
=
3
)
self
.
add_module
(
self
.
norm1_name
,
norm1
)
self
.
add_module
(
self
.
norm2_name
,
norm2
)
self
.
add_module
(
self
.
norm3_name
,
norm3
)
self
.
conv1
=
nn
.
Conv2d
(
self
.
conv1
=
nn
.
Conv2d
(
self
.
inplanes
,
self
.
inplanes
,
...
@@ -40,6 +37,7 @@ class Bottleneck(_Bottleneck):
...
@@ -40,6 +37,7 @@ class Bottleneck(_Bottleneck):
kernel_size
=
1
,
kernel_size
=
1
,
stride
=
self
.
conv1_stride
,
stride
=
self
.
conv1_stride
,
bias
=
False
)
bias
=
False
)
self
.
add_module
(
self
.
norm1_name
,
norm1
)
self
.
conv2
=
nn
.
Conv2d
(
self
.
conv2
=
nn
.
Conv2d
(
width
,
width
,
width
,
width
,
...
@@ -49,8 +47,10 @@ class Bottleneck(_Bottleneck):
...
@@ -49,8 +47,10 @@ class Bottleneck(_Bottleneck):
dilation
=
self
.
dilation
,
dilation
=
self
.
dilation
,
groups
=
groups
,
groups
=
groups
,
bias
=
False
)
bias
=
False
)
self
.
add_module
(
self
.
norm2_name
,
norm2
)
self
.
conv3
=
nn
.
Conv2d
(
self
.
conv3
=
nn
.
Conv2d
(
width
,
self
.
planes
*
self
.
expansion
,
kernel_size
=
1
,
bias
=
False
)
width
,
self
.
planes
*
self
.
expansion
,
kernel_size
=
1
,
bias
=
False
)
self
.
add_module
(
self
.
norm3_name
,
norm3
)
def
make_res_layer
(
block
,
def
make_res_layer
(
block
,
...
...
mmdet/models/utils/norm.py
View file @
55a4feb5
...
@@ -2,7 +2,7 @@ import torch.nn as nn
...
@@ -2,7 +2,7 @@ import torch.nn as nn
norm_cfg
=
{
norm_cfg
=
{
# format: layer_type: (abbreation, module)
# format: layer_type: (abbre
vi
ation, module)
'BN'
:
(
'bn'
,
nn
.
BatchNorm2d
),
'BN'
:
(
'bn'
,
nn
.
BatchNorm2d
),
'SyncBN'
:
(
'bn'
,
None
),
'SyncBN'
:
(
'bn'
,
None
),
'GN'
:
(
'gn'
,
nn
.
GroupNorm
),
'GN'
:
(
'gn'
,
nn
.
GroupNorm
),
...
...
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