Skip to content

Commit 4c62867

Browse files
authored
Delete deprecated warning in FPN (open-mmlab#5311)
* deprecated warning in FPN * modify doc string * modify related files
1 parent dd0e8ed commit 4c62867

File tree

6 files changed

+13
-60
lines changed

6 files changed

+13
-60
lines changed

configs/autoassign/autoassign_r50_fpn_8x2_1x_coco.py

-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
out_channels=256,
2323
start_level=1,
2424
add_extra_convs=True,
25-
extra_convs_on_inputs=True,
2625
num_outs=5,
2726
relu_before_extra_convs=True,
2827
init_cfg=dict(type='Caffe2Xavier', layer='Conv2d')),

configs/fcos/fcos_r50_caffe_fpn_gn-head_1x_coco.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
in_channels=[256, 512, 1024, 2048],
2121
out_channels=256,
2222
start_level=1,
23-
add_extra_convs=True,
24-
extra_convs_on_inputs=False, # use P5
23+
add_extra_convs='on_output', # use P5
2524
num_outs=5,
2625
relu_before_extra_convs=True),
2726
bbox_head=dict(

configs/vfnet/vfnet_r50_fpn_1x_coco.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
in_channels=[256, 512, 1024, 2048],
2121
out_channels=256,
2222
start_level=1,
23-
add_extra_convs=True,
24-
extra_convs_on_inputs=False, # use P5
23+
add_extra_convs='on_output', # use P5
2524
num_outs=5,
2625
relu_before_extra_convs=True),
2726
bbox_head=dict(

mmdet/models/necks/fpn.py

+2-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import warnings
2-
31
import torch.nn as nn
42
import torch.nn.functional as F
53
from mmcv.cnn import ConvModule
@@ -25,17 +23,13 @@ class FPN(BaseModule):
2523
build the feature pyramid. Default: -1, which means the last level.
2624
add_extra_convs (bool | str): If bool, it decides whether to add conv
2725
layers on top of the original feature maps. Default to False.
28-
If True, its actual mode is specified by `extra_convs_on_inputs`.
26+
If True, it is equivalent to `add_extra_convs='on_input'`.
2927
If str, it specifies the source feature map of the extra convs.
3028
Only the following options are allowed
3129
3230
- 'on_input': Last feat map of neck inputs (i.e. backbone feature).
3331
- 'on_lateral': Last feature map after lateral convs.
3432
- 'on_output': The last output feature map after fpn convs.
35-
extra_convs_on_inputs (bool, deprecated): Whether to apply extra convs
36-
on the original feature from the backbone. If True,
37-
it is equivalent to `add_extra_convs='on_input'`. If False, it is
38-
equivalent to set `add_extra_convs='on_output'`. Default to True.
3933
relu_before_extra_convs (bool): Whether to apply relu before the extra
4034
conv. Default: False.
4135
no_norm_on_lateral (bool): Whether to apply norm on lateral.
@@ -71,7 +65,6 @@ def __init__(self,
7165
start_level=0,
7266
end_level=-1,
7367
add_extra_convs=False,
74-
extra_convs_on_inputs=True,
7568
relu_before_extra_convs=False,
7669
no_norm_on_lateral=False,
7770
conv_cfg=None,
@@ -107,15 +100,7 @@ def __init__(self,
107100
# Extra_convs_source choices: 'on_input', 'on_lateral', 'on_output'
108101
assert add_extra_convs in ('on_input', 'on_lateral', 'on_output')
109102
elif add_extra_convs: # True
110-
if extra_convs_on_inputs:
111-
# TODO: deprecate `extra_convs_on_inputs`
112-
warnings.simplefilter('once')
113-
warnings.warn(
114-
'"extra_convs_on_inputs" will be deprecated in v2.9.0,'
115-
'Please use "add_extra_convs"', DeprecationWarning)
116-
self.add_extra_convs = 'on_input'
117-
else:
118-
self.add_extra_convs = 'on_output'
103+
self.add_extra_convs = 'on_input'
119104

120105
self.lateral_convs = nn.ModuleList()
121106
self.fpn_convs = nn.ModuleList()

mmdet/models/necks/pafpn.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,15 @@ class PAFPN(FPN):
2222
build the feature pyramid. Default: 0.
2323
end_level (int): Index of the end input backbone level (exclusive) to
2424
build the feature pyramid. Default: -1, which means the last level.
25-
add_extra_convs (bool): Whether to add conv layers on top of the
26-
original feature maps. Default: False.
27-
extra_convs_on_inputs (bool): Whether to apply extra conv on
28-
the original feature from the backbone. Default: False.
25+
add_extra_convs (bool | str): If bool, it decides whether to add conv
26+
layers on top of the original feature maps. Default to False.
27+
If True, it is equivalent to `add_extra_convs='on_input'`.
28+
If str, it specifies the source feature map of the extra convs.
29+
Only the following options are allowed
30+
31+
- 'on_input': Last feat map of neck inputs (i.e. backbone feature).
32+
- 'on_lateral': Last feature map after lateral convs.
33+
- 'on_output': The last output feature map after fpn convs.
2934
relu_before_extra_convs (bool): Whether to apply relu before the extra
3035
conv. Default: False.
3136
no_norm_on_lateral (bool): Whether to apply norm on lateral.
@@ -44,7 +49,6 @@ def __init__(self,
4449
start_level=0,
4550
end_level=-1,
4651
add_extra_convs=False,
47-
extra_convs_on_inputs=True,
4852
relu_before_extra_convs=False,
4953
no_norm_on_lateral=False,
5054
conv_cfg=None,
@@ -59,7 +63,6 @@ def __init__(self,
5963
start_level,
6064
end_level,
6165
add_extra_convs,
62-
extra_convs_on_inputs,
6366
relu_before_extra_convs,
6467
no_norm_on_lateral,
6568
conv_cfg,

tests/test_models/test_necks.py

-32
Original file line numberDiff line numberDiff line change
@@ -169,38 +169,6 @@ def test_fpn():
169169
outs[i].shape[1] == out_channels
170170
outs[i].shape[2] == outs[i].shape[3] == s // (2**i)
171171

172-
# extra_convs_on_inputs=False is equal to extra convs source is 'on_output'
173-
fpn_model = FPN(
174-
in_channels=in_channels,
175-
out_channels=out_channels,
176-
add_extra_convs=True,
177-
extra_convs_on_inputs=False,
178-
start_level=1,
179-
num_outs=5,
180-
)
181-
assert fpn_model.add_extra_convs == 'on_output'
182-
outs = fpn_model(feats)
183-
assert len(outs) == fpn_model.num_outs
184-
for i in range(fpn_model.num_outs):
185-
outs[i].shape[1] == out_channels
186-
outs[i].shape[2] == outs[i].shape[3] == s // (2**i)
187-
188-
# extra_convs_on_inputs=True is equal to extra convs source is 'on_input'
189-
fpn_model = FPN(
190-
in_channels=in_channels,
191-
out_channels=out_channels,
192-
add_extra_convs=True,
193-
extra_convs_on_inputs=True,
194-
start_level=1,
195-
num_outs=5,
196-
)
197-
assert fpn_model.add_extra_convs == 'on_input'
198-
outs = fpn_model(feats)
199-
assert len(outs) == fpn_model.num_outs
200-
for i in range(fpn_model.num_outs):
201-
outs[i].shape[1] == out_channels
202-
outs[i].shape[2] == outs[i].shape[3] == s // (2**i)
203-
204172

205173
def test_channel_mapper():
206174
"""Tests ChannelMapper."""

0 commit comments

Comments
 (0)