[Improvement] Move train_cfg/test_cfg inside model (#341)

* [Improvement] Move train_cfg/test_cfg inside model

* fixed config dict

* fixed config dict
This commit is contained in:
Jerry Jiarui XU 2021-01-19 17:06:23 -08:00 committed by GitHub
parent 0ee3016558
commit faaf29e668
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
88 changed files with 266 additions and 247 deletions

View File

@ -40,7 +40,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -38,7 +38,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -38,7 +38,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -29,7 +29,7 @@ model = dict(
10.289121, 9.953208, 4.3097677, 9.490387, 7.674431, 9.396905, 10.289121, 9.953208, 4.3097677, 9.490387, 7.674431, 9.396905,
10.347791, 6.3927646, 10.226669, 10.241062, 10.280587, 10.347791, 6.3927646, 10.226669, 10.241062, 10.280587,
10.396974, 10.055647 10.396974, 10.055647
]))) ])),
# model training and testing settings # model training and testing settings
train_cfg = dict(sampler=None) train_cfg=dict(sampler=None),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -38,7 +38,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -38,7 +38,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -44,7 +44,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='slide', crop_size=256, stride=170) test_cfg=dict(mode='slide', crop_size=256, stride=170))

View File

@ -40,7 +40,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -38,7 +38,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -40,7 +40,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -41,7 +41,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -42,7 +42,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -51,8 +51,7 @@ model = dict(
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=True, loss_weight=0.4)), type='CrossEntropyLoss', use_sigmoid=True, loss_weight=0.4)),
]) ],
# model training and testing settings
# model training and testing settings train_cfg=dict(),
train_cfg = dict() test_cfg=dict(mode='whole'))
test_cfg = dict(mode='whole')

View File

@ -46,7 +46,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -39,7 +39,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -45,7 +45,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='slide', crop_size=256, stride=170) test_cfg=dict(mode='slide', crop_size=256, stride=170))

View File

@ -30,7 +30,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -40,7 +40,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -19,7 +19,7 @@ model = dict(
act_cfg=dict(type='ReLU'), act_cfg=dict(type='ReLU'),
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -40,7 +40,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -62,7 +62,7 @@ model = dict(
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)), type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)),
]) ],
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -41,7 +41,7 @@ model = dict(
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0))
]) ],
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -45,12 +45,12 @@ model = dict(
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0)) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=1.0))
]) ],
# model training and testing settings # model training and testing settings
train_cfg = dict( train_cfg=dict(
num_points=2048, oversample_ratio=3, importance_sample_ratio=0.75) num_points=2048, oversample_ratio=3, importance_sample_ratio=0.75),
test_cfg = dict( test_cfg=dict(
mode='whole', mode='whole',
subdivision_steps=2, subdivision_steps=2,
subdivision_num_points=8196, subdivision_num_points=8196,
scale_factor=2) scale_factor=2))

View File

@ -43,7 +43,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -38,7 +38,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -44,7 +44,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='slide', crop_size=256, stride=170) test_cfg=dict(mode='slide', crop_size=256, stride=170))

View File

@ -38,7 +38,7 @@ model = dict(
norm_cfg=norm_cfg, norm_cfg=norm_cfg,
align_corners=False, align_corners=False,
loss_decode=dict( loss_decode=dict(
type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4))) type='CrossEntropyLoss', use_sigmoid=False, loss_weight=0.4)),
# model training and testing settings # model training and testing settings
train_cfg = dict() train_cfg=dict(),
test_cfg = dict(mode='whole') test_cfg=dict(mode='whole'))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -4,6 +4,7 @@ _base_ = [
'../_base_/schedules/schedule_40k.py' '../_base_/schedules/schedule_40k.py'
] ]
model = dict( model = dict(
decode_head=dict(num_classes=60), auxiliary_head=dict(num_classes=60)) decode_head=dict(num_classes=60),
test_cfg = dict(mode='slide', crop_size=(480, 480), stride=(320, 320)) auxiliary_head=dict(num_classes=60),
test_cfg=dict(mode='slide', crop_size=(480, 480), stride=(320, 320)))
optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001) optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001)

View File

@ -4,6 +4,7 @@ _base_ = [
'../_base_/schedules/schedule_80k.py' '../_base_/schedules/schedule_80k.py'
] ]
model = dict( model = dict(
decode_head=dict(num_classes=60), auxiliary_head=dict(num_classes=60)) decode_head=dict(num_classes=60),
test_cfg = dict(mode='slide', crop_size=(480, 480), stride=(320, 320)) auxiliary_head=dict(num_classes=60),
test_cfg=dict(mode='slide', crop_size=(480, 480), stride=(320, 320)))
optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001) optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001)

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -4,6 +4,7 @@ _base_ = [
'../_base_/schedules/schedule_40k.py' '../_base_/schedules/schedule_40k.py'
] ]
model = dict( model = dict(
decode_head=dict(num_classes=60), auxiliary_head=dict(num_classes=60)) decode_head=dict(num_classes=60),
test_cfg = dict(mode='slide', crop_size=(480, 480), stride=(320, 320)) auxiliary_head=dict(num_classes=60),
test_cfg=dict(mode='slide', crop_size=(480, 480), stride=(320, 320)))
optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001) optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001)

View File

@ -4,6 +4,7 @@ _base_ = [
'../_base_/schedules/schedule_80k.py' '../_base_/schedules/schedule_80k.py'
] ]
model = dict( model = dict(
decode_head=dict(num_classes=60), auxiliary_head=dict(num_classes=60)) decode_head=dict(num_classes=60),
test_cfg = dict(mode='slide', crop_size=(480, 480), stride=(320, 320)) auxiliary_head=dict(num_classes=60),
test_cfg=dict(mode='slide', crop_size=(480, 480), stride=(320, 320)))
optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001) optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001)

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,8 +5,8 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))
optimizer = dict( optimizer = dict(
paramwise_cfg=dict( paramwise_cfg=dict(
custom_keys=dict(theta=dict(wd_mult=0.), phi=dict(wd_mult=0.)))) custom_keys=dict(theta=dict(wd_mult=0.), phi=dict(wd_mult=0.))))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -2,6 +2,7 @@ _base_ = [
'../_base_/models/fcn_r50-d8.py', '../_base_/datasets/pascal_context.py', '../_base_/models/fcn_r50-d8.py', '../_base_/datasets/pascal_context.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py' '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py'
] ]
model = dict(decode_head=dict(num_classes=60)) model = dict(
test_cfg = dict(mode='slide', crop_size=(480, 480), stride=(320, 320)) decode_head=dict(num_classes=60),
test_cfg=dict(mode='slide', crop_size=(480, 480), stride=(320, 320)))
optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001) optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001)

View File

@ -2,6 +2,7 @@ _base_ = [
'../_base_/models/fcn_r50-d8.py', '../_base_/datasets/pascal_context.py', '../_base_/models/fcn_r50-d8.py', '../_base_/datasets/pascal_context.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py' '../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py'
] ]
model = dict(decode_head=dict(num_classes=60)) model = dict(
test_cfg = dict(mode='slide', crop_size=(480, 480), stride=(320, 320)) decode_head=dict(num_classes=60),
test_cfg=dict(mode='slide', crop_size=(480, 480), stride=(320, 320)))
optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001) optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001)

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -2,6 +2,7 @@ _base_ = [
'../_base_/models/fcn_hr18.py', '../_base_/datasets/pascal_context.py', '../_base_/models/fcn_hr18.py', '../_base_/datasets/pascal_context.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py' '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py'
] ]
model = dict(decode_head=dict(num_classes=60)) model = dict(
test_cfg = dict(mode='slide', crop_size=(480, 480), stride=(320, 320)) decode_head=dict(num_classes=60),
test_cfg=dict(mode='slide', crop_size=(480, 480), stride=(320, 320)))
optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001) optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001)

View File

@ -2,6 +2,7 @@ _base_ = [
'../_base_/models/fcn_hr18.py', '../_base_/datasets/pascal_context.py', '../_base_/models/fcn_hr18.py', '../_base_/datasets/pascal_context.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py' '../_base_/default_runtime.py', '../_base_/schedules/schedule_80k.py'
] ]
model = dict(decode_head=dict(num_classes=60)) model = dict(
test_cfg = dict(mode='slide', crop_size=(480, 480), stride=(320, 320)) decode_head=dict(num_classes=60),
test_cfg=dict(mode='slide', crop_size=(480, 480), stride=(320, 320)))
optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001) optimizer = dict(type='SGD', lr=0.004, momentum=0.9, weight_decay=0.0001)

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -3,5 +3,5 @@ _base_ = [
'../_base_/datasets/chase_db1.py', '../_base_/default_runtime.py', '../_base_/datasets/chase_db1.py', '../_base_/default_runtime.py',
'../_base_/schedules/schedule_40k.py' '../_base_/schedules/schedule_40k.py'
] ]
test_cfg = dict(crop_size=(128, 128), stride=(85, 85)) model = dict(test_cfg=dict(crop_size=(128, 128), stride=(85, 85)))
evaluation = dict(metric='mDice') evaluation = dict(metric='mDice')

View File

@ -2,5 +2,5 @@ _base_ = [
'../_base_/models/deeplabv3_unet_s5-d16.py', '../_base_/datasets/stare.py', '../_base_/models/deeplabv3_unet_s5-d16.py', '../_base_/datasets/stare.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py' '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py'
] ]
test_cfg = dict(crop_size=(128, 128), stride=(85, 85)) model = dict(test_cfg=dict(crop_size=(128, 128), stride=(85, 85)))
evaluation = dict(metric='mDice') evaluation = dict(metric='mDice')

View File

@ -2,5 +2,5 @@ _base_ = [
'../_base_/models/deeplabv3_unet_s5-d16.py', '../_base_/datasets/hrf.py', '../_base_/models/deeplabv3_unet_s5-d16.py', '../_base_/datasets/hrf.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py' '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py'
] ]
test_cfg = dict(crop_size=(256, 256), stride=(170, 170)) model = dict(test_cfg=dict(crop_size=(256, 256), stride=(170, 170)))
evaluation = dict(metric='mDice') evaluation = dict(metric='mDice')

View File

@ -2,5 +2,5 @@ _base_ = [
'../_base_/models/deeplabv3_unet_s5-d16.py', '../_base_/datasets/drive.py', '../_base_/models/deeplabv3_unet_s5-d16.py', '../_base_/datasets/drive.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py' '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py'
] ]
test_cfg = dict(crop_size=(64, 64), stride=(42, 42)) model = dict(test_cfg=dict(crop_size=(64, 64), stride=(42, 42)))
evaluation = dict(metric='mDice') evaluation = dict(metric='mDice')

View File

@ -2,5 +2,5 @@ _base_ = [
'../_base_/models/fcn_unet_s5-d16.py', '../_base_/datasets/chase_db1.py', '../_base_/models/fcn_unet_s5-d16.py', '../_base_/datasets/chase_db1.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py' '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py'
] ]
test_cfg = dict(crop_size=(128, 128), stride=(85, 85)) model = dict(test_cfg=dict(crop_size=(128, 128), stride=(85, 85)))
evaluation = dict(metric='mDice') evaluation = dict(metric='mDice')

View File

@ -2,5 +2,5 @@ _base_ = [
'../_base_/models/fcn_unet_s5-d16.py', '../_base_/datasets/stare.py', '../_base_/models/fcn_unet_s5-d16.py', '../_base_/datasets/stare.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py' '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py'
] ]
test_cfg = dict(crop_size=(128, 128), stride=(85, 85)) model = dict(test_cfg=dict(crop_size=(128, 128), stride=(85, 85)))
evaluation = dict(metric='mDice') evaluation = dict(metric='mDice')

View File

@ -2,5 +2,5 @@ _base_ = [
'../_base_/models/fcn_unet_s5-d16.py', '../_base_/datasets/hrf.py', '../_base_/models/fcn_unet_s5-d16.py', '../_base_/datasets/hrf.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py' '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py'
] ]
test_cfg = dict(crop_size=(256, 256), stride=(170, 170)) model = dict(test_cfg=dict(crop_size=(256, 256), stride=(170, 170)))
evaluation = dict(metric='mDice') evaluation = dict(metric='mDice')

View File

@ -2,5 +2,5 @@ _base_ = [
'../_base_/models/fcn_unet_s5-d16.py', '../_base_/datasets/drive.py', '../_base_/models/fcn_unet_s5-d16.py', '../_base_/datasets/drive.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py' '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py'
] ]
test_cfg = dict(crop_size=(64, 64), stride=(42, 42)) model = dict(test_cfg=dict(crop_size=(64, 64), stride=(42, 42)))
evaluation = dict(metric='mDice') evaluation = dict(metric='mDice')

View File

@ -3,5 +3,5 @@ _base_ = [
'../_base_/datasets/chase_db1.py', '../_base_/default_runtime.py', '../_base_/datasets/chase_db1.py', '../_base_/default_runtime.py',
'../_base_/schedules/schedule_40k.py' '../_base_/schedules/schedule_40k.py'
] ]
test_cfg = dict(crop_size=(128, 128), stride=(85, 85)) model = dict(test_cfg=dict(crop_size=(128, 128), stride=(85, 85)))
evaluation = dict(metric='mDice') evaluation = dict(metric='mDice')

View File

@ -2,5 +2,5 @@ _base_ = [
'../_base_/models/pspnet_unet_s5-d16.py', '../_base_/datasets/stare.py', '../_base_/models/pspnet_unet_s5-d16.py', '../_base_/datasets/stare.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py' '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py'
] ]
test_cfg = dict(crop_size=(128, 128), stride=(85, 85)) model = dict(test_cfg=dict(crop_size=(128, 128), stride=(85, 85)))
evaluation = dict(metric='mDice') evaluation = dict(metric='mDice')

View File

@ -2,5 +2,5 @@ _base_ = [
'../_base_/models/pspnet_unet_s5-d16.py', '../_base_/datasets/hrf.py', '../_base_/models/pspnet_unet_s5-d16.py', '../_base_/datasets/hrf.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py' '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py'
] ]
test_cfg = dict(crop_size=(256, 256), stride=(170, 170)) model = dict(test_cfg=dict(crop_size=(256, 256), stride=(170, 170)))
evaluation = dict(metric='mDice') evaluation = dict(metric='mDice')

View File

@ -2,5 +2,5 @@ _base_ = [
'../_base_/models/pspnet_unet_s5-d16.py', '../_base_/datasets/drive.py', '../_base_/models/pspnet_unet_s5-d16.py', '../_base_/datasets/drive.py',
'../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py' '../_base_/default_runtime.py', '../_base_/schedules/schedule_40k.py'
] ]
test_cfg = dict(crop_size=(64, 64), stride=(42, 42)) model = dict(test_cfg=dict(crop_size=(64, 64), stride=(42, 42)))
evaluation = dict(metric='mDice') evaluation = dict(metric='mDice')

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -5,5 +5,5 @@ _base_ = [
] ]
model = dict( model = dict(
decode_head=dict(align_corners=True), decode_head=dict(align_corners=True),
auxiliary_head=dict(align_corners=True)) auxiliary_head=dict(align_corners=True),
test_cfg = dict(mode='slide', crop_size=(769, 769), stride=(513, 513)) test_cfg=dict(mode='slide', crop_size=(769, 769), stride=(513, 513)))

View File

@ -27,7 +27,8 @@ def init_segmentor(config, checkpoint=None, device='cuda:0'):
raise TypeError('config must be a filename or Config object, ' raise TypeError('config must be a filename or Config object, '
'but got {}'.format(type(config))) 'but got {}'.format(type(config)))
config.model.pretrained = None config.model.pretrained = None
model = build_segmentor(config.model, test_cfg=config.test_cfg) config.model.train_cfg = None
model = build_segmentor(config.model, test_cfg=config.get('test_cfg'))
if checkpoint is not None: if checkpoint is not None:
checkpoint = load_checkpoint(model, checkpoint, map_location='cpu') checkpoint = load_checkpoint(model, checkpoint, map_location='cpu')
model.CLASSES = checkpoint['meta']['CLASSES'] model.CLASSES = checkpoint['meta']['CLASSES']

View File

@ -1,3 +1,5 @@
import warnings
from mmcv.utils import Registry, build_from_cfg from mmcv.utils import Registry, build_from_cfg
from torch import nn from torch import nn
@ -53,4 +55,12 @@ def build_loss(cfg):
def build_segmentor(cfg, train_cfg=None, test_cfg=None): def build_segmentor(cfg, train_cfg=None, test_cfg=None):
"""Build segmentor.""" """Build segmentor."""
if train_cfg is not None or test_cfg is not None:
warnings.warn(
'train_cfg and test_cfg is deprecated, '
'please specify them in model', UserWarning)
assert cfg.get('train_cfg') is None or train_cfg is None, \
'train_cfg specified in both outer field and model field '
assert cfg.get('test_cfg') is None or test_cfg is None, \
'test_cfg specified in both outer field and model field '
return build(cfg, SEGMENTORS, dict(train_cfg=train_cfg, test_cfg=test_cfg)) return build(cfg, SEGMENTORS, dict(train_cfg=train_cfg, test_cfg=test_cfg))

View File

@ -45,8 +45,6 @@ def test_config_build_segmentor():
config_mod = Config.fromfile(config_fpath) config_mod = Config.fromfile(config_fpath)
config_mod.model config_mod.model
config_mod.train_cfg
config_mod.test_cfg
print('Building segmentor, config_fpath = {!r}'.format(config_fpath)) print('Building segmentor, config_fpath = {!r}'.format(config_fpath))
# Remove pretrained keys to allow for testing in an offline environment # Remove pretrained keys to allow for testing in an offline environment
@ -54,10 +52,7 @@ def test_config_build_segmentor():
config_mod.model['pretrained'] = None config_mod.model['pretrained'] = None
print('building {}'.format(config_fname)) print('building {}'.format(config_fname))
segmentor = build_segmentor( segmentor = build_segmentor(config_mod.model)
config_mod.model,
train_cfg=config_mod.train_cfg,
test_cfg=config_mod.test_cfg)
assert segmentor is not None assert segmentor is not None
head_config = config_mod.model['decode_head'] head_config = config_mod.model['decode_head']

View File

@ -76,12 +76,9 @@ def _get_segmentor_cfg(fname):
These are deep copied to allow for safe modification of parameters without These are deep copied to allow for safe modification of parameters without
influencing other tests. influencing other tests.
""" """
import mmcv
config = _get_config_module(fname) config = _get_config_module(fname)
model = copy.deepcopy(config.model) model = copy.deepcopy(config.model)
train_cfg = mmcv.Config(copy.deepcopy(config.train_cfg)) return model
test_cfg = mmcv.Config(copy.deepcopy(config.test_cfg))
return model, train_cfg, test_cfg
def test_pspnet_forward(): def test_pspnet_forward():
@ -212,12 +209,12 @@ def _convert_batchnorm(module):
_check_input_dim) _check_input_dim)
@patch('torch.distributed.get_world_size', get_world_size) @patch('torch.distributed.get_world_size', get_world_size)
def _test_encoder_decoder_forward(cfg_file): def _test_encoder_decoder_forward(cfg_file):
model, train_cfg, test_cfg = _get_segmentor_cfg(cfg_file) model = _get_segmentor_cfg(cfg_file)
model['pretrained'] = None model['pretrained'] = None
test_cfg['mode'] = 'whole' model['test_cfg']['mode'] = 'whole'
from mmseg.models import build_segmentor from mmseg.models import build_segmentor
segmentor = build_segmentor(model, train_cfg=train_cfg, test_cfg=test_cfg) segmentor = build_segmentor(model)
if isinstance(segmentor.decode_head, nn.ModuleList): if isinstance(segmentor.decode_head, nn.ModuleList):
num_classes = segmentor.decode_head[-1].num_classes num_classes = segmentor.decode_head[-1].num_classes

View File

@ -1,6 +1,6 @@
import mmcv
import numpy as np import numpy as np
import torch import torch
from mmcv import ConfigDict
from torch import nn from torch import nn
from mmseg.models import BACKBONES, HEADS, build_segmentor from mmseg.models import BACKBONES, HEADS, build_segmentor
@ -123,31 +123,33 @@ def _segmentor_forward_train_test(segmentor):
def test_encoder_decoder(): def test_encoder_decoder():
# test 1 decode head, w.o. aux head # test 1 decode head, w.o. aux head
cfg = dict(
cfg = ConfigDict(
type='EncoderDecoder', type='EncoderDecoder',
backbone=dict(type='ExampleBackbone'), backbone=dict(type='ExampleBackbone'),
decode_head=dict(type='ExampleDecodeHead')) decode_head=dict(type='ExampleDecodeHead'),
test_cfg = mmcv.Config(dict(mode='whole')) train_cfg=None,
segmentor = build_segmentor(cfg, train_cfg=None, test_cfg=test_cfg) test_cfg=dict(mode='whole'))
segmentor = build_segmentor(cfg)
_segmentor_forward_train_test(segmentor) _segmentor_forward_train_test(segmentor)
# test slide mode # test slide mode
test_cfg = mmcv.Config(dict(mode='slide', crop_size=(3, 3), stride=(2, 2))) cfg.test_cfg = ConfigDict(mode='slide', crop_size=(3, 3), stride=(2, 2))
segmentor = build_segmentor(cfg, train_cfg=None, test_cfg=test_cfg) segmentor = build_segmentor(cfg)
_segmentor_forward_train_test(segmentor) _segmentor_forward_train_test(segmentor)
# test 1 decode head, 1 aux head # test 1 decode head, 1 aux head
cfg = dict( cfg = ConfigDict(
type='EncoderDecoder', type='EncoderDecoder',
backbone=dict(type='ExampleBackbone'), backbone=dict(type='ExampleBackbone'),
decode_head=dict(type='ExampleDecodeHead'), decode_head=dict(type='ExampleDecodeHead'),
auxiliary_head=dict(type='ExampleDecodeHead')) auxiliary_head=dict(type='ExampleDecodeHead'))
test_cfg = mmcv.Config(dict(mode='whole')) cfg.test_cfg = ConfigDict(mode='whole')
segmentor = build_segmentor(cfg, train_cfg=None, test_cfg=test_cfg) segmentor = build_segmentor(cfg)
_segmentor_forward_train_test(segmentor) _segmentor_forward_train_test(segmentor)
# test 1 decode head, 2 aux head # test 1 decode head, 2 aux head
cfg = dict( cfg = ConfigDict(
type='EncoderDecoder', type='EncoderDecoder',
backbone=dict(type='ExampleBackbone'), backbone=dict(type='ExampleBackbone'),
decode_head=dict(type='ExampleDecodeHead'), decode_head=dict(type='ExampleDecodeHead'),
@ -155,15 +157,15 @@ def test_encoder_decoder():
dict(type='ExampleDecodeHead'), dict(type='ExampleDecodeHead'),
dict(type='ExampleDecodeHead') dict(type='ExampleDecodeHead')
]) ])
test_cfg = mmcv.Config(dict(mode='whole')) cfg.test_cfg = ConfigDict(mode='whole')
segmentor = build_segmentor(cfg, train_cfg=None, test_cfg=test_cfg) segmentor = build_segmentor(cfg)
_segmentor_forward_train_test(segmentor) _segmentor_forward_train_test(segmentor)
def test_cascade_encoder_decoder(): def test_cascade_encoder_decoder():
# test 1 decode head, w.o. aux head # test 1 decode head, w.o. aux head
cfg = dict( cfg = ConfigDict(
type='CascadeEncoderDecoder', type='CascadeEncoderDecoder',
num_stages=2, num_stages=2,
backbone=dict(type='ExampleBackbone'), backbone=dict(type='ExampleBackbone'),
@ -171,17 +173,17 @@ def test_cascade_encoder_decoder():
dict(type='ExampleDecodeHead'), dict(type='ExampleDecodeHead'),
dict(type='ExampleCascadeDecodeHead') dict(type='ExampleCascadeDecodeHead')
]) ])
test_cfg = mmcv.Config(dict(mode='whole')) cfg.test_cfg = ConfigDict(mode='whole')
segmentor = build_segmentor(cfg, train_cfg=None, test_cfg=test_cfg) segmentor = build_segmentor(cfg)
_segmentor_forward_train_test(segmentor) _segmentor_forward_train_test(segmentor)
# test slide mode # test slide mode
test_cfg = mmcv.Config(dict(mode='slide', crop_size=(3, 3), stride=(2, 2))) cfg.test_cfg = ConfigDict(mode='slide', crop_size=(3, 3), stride=(2, 2))
segmentor = build_segmentor(cfg, train_cfg=None, test_cfg=test_cfg) segmentor = build_segmentor(cfg)
_segmentor_forward_train_test(segmentor) _segmentor_forward_train_test(segmentor)
# test 1 decode head, 1 aux head # test 1 decode head, 1 aux head
cfg = dict( cfg = ConfigDict(
type='CascadeEncoderDecoder', type='CascadeEncoderDecoder',
num_stages=2, num_stages=2,
backbone=dict(type='ExampleBackbone'), backbone=dict(type='ExampleBackbone'),
@ -190,12 +192,12 @@ def test_cascade_encoder_decoder():
dict(type='ExampleCascadeDecodeHead') dict(type='ExampleCascadeDecodeHead')
], ],
auxiliary_head=dict(type='ExampleDecodeHead')) auxiliary_head=dict(type='ExampleDecodeHead'))
test_cfg = mmcv.Config(dict(mode='whole')) cfg.test_cfg = ConfigDict(mode='whole')
segmentor = build_segmentor(cfg, train_cfg=None, test_cfg=test_cfg) segmentor = build_segmentor(cfg)
_segmentor_forward_train_test(segmentor) _segmentor_forward_train_test(segmentor)
# test 1 decode head, 2 aux head # test 1 decode head, 2 aux head
cfg = dict( cfg = ConfigDict(
type='CascadeEncoderDecoder', type='CascadeEncoderDecoder',
num_stages=2, num_stages=2,
backbone=dict(type='ExampleBackbone'), backbone=dict(type='ExampleBackbone'),
@ -207,6 +209,6 @@ def test_cascade_encoder_decoder():
dict(type='ExampleDecodeHead'), dict(type='ExampleDecodeHead'),
dict(type='ExampleDecodeHead') dict(type='ExampleDecodeHead')
]) ])
test_cfg = mmcv.Config(dict(mode='whole')) cfg.test_cfg = ConfigDict(mode='whole')
segmentor = build_segmentor(cfg, train_cfg=None, test_cfg=test_cfg) segmentor = build_segmentor(cfg)
_segmentor_forward_train_test(segmentor) _segmentor_forward_train_test(segmentor)

View File

@ -40,7 +40,8 @@ def main():
shuffle=False) shuffle=False)
# build the model and load checkpoint # build the model and load checkpoint
model = build_segmentor(cfg.model, train_cfg=None, test_cfg=cfg.test_cfg) cfg.model.train_cfg = None
model = build_segmentor(cfg.model, test_cfg=cfg.get('test_cfg'))
load_checkpoint(model, args.checkpoint, map_location='cpu') load_checkpoint(model, args.checkpoint, map_location='cpu')
model = MMDataParallel(model, device_ids=[0]) model = MMDataParallel(model, device_ids=[0])

View File

@ -33,7 +33,9 @@ def main():
cfg = Config.fromfile(args.config) cfg = Config.fromfile(args.config)
cfg.model.pretrained = None cfg.model.pretrained = None
model = build_segmentor( model = build_segmentor(
cfg.model, train_cfg=cfg.train_cfg, test_cfg=cfg.test_cfg).cuda() cfg.model,
train_cfg=cfg.get('train_cfg'),
test_cfg=cfg.get('test_cfg')).cuda()
model.eval() model.eval()
if hasattr(model, 'forward_dummy'): if hasattr(model, 'forward_dummy'):

View File

@ -181,8 +181,9 @@ if __name__ == '__main__':
cfg.model.pretrained = None cfg.model.pretrained = None
# build the model and load checkpoint # build the model and load checkpoint
cfg.model.train_cfg = None
segmentor = build_segmentor( segmentor = build_segmentor(
cfg.model, train_cfg=None, test_cfg=cfg.test_cfg) cfg.model, train_cfg=None, test_cfg=cfg.get('test_cfg'))
# convert SyncBN to BN # convert SyncBN to BN
segmentor = _convert_batchnorm(segmentor) segmentor = _convert_batchnorm(segmentor)

View File

@ -110,7 +110,8 @@ def main():
shuffle=False) shuffle=False)
# build the model and load checkpoint # build the model and load checkpoint
model = build_segmentor(cfg.model, train_cfg=None, test_cfg=cfg.test_cfg) cfg.model.train_cfg = None
model = build_segmentor(cfg.model, test_cfg=cfg.get('test_cfg'))
checkpoint = load_checkpoint(model, args.checkpoint, map_location='cpu') checkpoint = load_checkpoint(model, args.checkpoint, map_location='cpu')
model.CLASSES = checkpoint['meta']['CLASSES'] model.CLASSES = checkpoint['meta']['CLASSES']
model.PALETTE = checkpoint['meta']['PALETTE'] model.PALETTE = checkpoint['meta']['PALETTE']

View File

@ -128,7 +128,9 @@ def main():
meta['exp_name'] = osp.basename(args.config) meta['exp_name'] = osp.basename(args.config)
model = build_segmentor( model = build_segmentor(
cfg.model, train_cfg=cfg.train_cfg, test_cfg=cfg.test_cfg) cfg.model,
train_cfg=cfg.get('train_cfg'),
test_cfg=cfg.get('test_cfg'))
logger.info(model) logger.info(model)