Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load weight mismatch #11

Open
CuongNN218 opened this issue Feb 2, 2021 · 8 comments
Open

Load weight mismatch #11

CuongNN218 opened this issue Feb 2, 2021 · 8 comments

Comments

@CuongNN218
Copy link

image
@hyz-xmaster Hi, thanks for your great work. I'm using VFNetX with custom data set with 14 classes and get this warning. But when i use VFNet with R50 backbone with no DCN this warning disappeared. Is it normal ?

@CuongNN218
Copy link
Author

`base = './vfnet_r50_fpn_mdconv_c3-c5_mstrain_2x_coco.py'
model = dict(
pretrained='open-mmlab://res2net101_v1d_26w_4s',
backbone=dict(
type='Res2Net',
depth=101,
scales=4,
base_width=26,
num_stages=4,
out_indices=(0, 1, 2, 3),
frozen_stages=1,
norm_cfg=dict(type='BN', requires_grad=True),
norm_eval=True,
style='pytorch',
dcn=dict(type='DCNv2', deform_groups=1, fallback_on_stride=False),
stage_with_dcn=(False, True, True, True)),
neck=dict(
type='PAFPNX',
in_channels=[256, 512, 1024, 2048],
out_channels=384,
start_level=1,
add_extra_convs=True,
extra_convs_on_inputs=False, # use P5
num_outs=5,
relu_before_extra_convs=True,
pafpn_conv_cfg=dict(type='DCNv2'),
no_norm_on_lateral=True,
norm_cfg=dict(type='GN', num_groups=32, requires_grad=True)),
bbox_head=dict(
type='VFNetHead',
num_classes=14,
in_channels=384,
stacked_convs=4,
feat_channels=384,
strides=[8, 16, 32, 64, 128],
regress_ranges=((-1, 64), (64, 128), (128, 256), (256, 512), (512,
1e8)),
anchor_generator=dict(
type='AnchorGenerator',
ratios=[1.0],
octave_base_scale=8,
scales_per_octave=1,
center_offset=0.0,
strides=[8, 16, 32, 64, 128]),
center_sampling=False,
dcn_on_last_conv=True,
use_atss=True,
use_vfl=True,
loss_cls=dict(
type='VarifocalLoss',
use_sigmoid=True,
alpha=0.75,
gamma=2.0,
iou_weighted=True,
loss_weight=1.0),
loss_bbox=dict(type='GIoULoss', loss_weight=1.5),
loss_bbox_refine=dict(type='GIoULoss', loss_weight=2.0)))

training and testing settings

train_cfg = dict(
assigner=dict(type='ATSSAssigner', topk=9),
allowed_border=-1,
pos_weight=-1,
debug=False)
test_cfg = dict(
nms_pre=1000,
min_bbox_size=0,
score_thr=0.05,
nms=dict(type='soft_nms', iou_threshold=0.65),
max_per_img=100)

data setting

dataset_type = 'CocoDataset'
data_root = ''
dataset_type = 'CocoDataset'
classes =('Aortic enlargement',
'Atelectasis',
'Calcification',
'Cardiomegaly',
'Consolidation',
'ILD',
'Infiltration',
'Lung Opacity',
'Nodule/Mass',
'Other lesion',
'Pleural effusion',
'Pleural thickening',
'Pneumothorax',
'Pulmonary fibrosis',)

img_norm_cfg = dict(
mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
train_pipeline = [
dict(type='LoadImageFromFile'),
dict(type='LoadAnnotations', with_bbox=True),
dict(
type='RandomCrop',
crop_type='relative_range',
crop_size=(0.75, 0.75),
crop_p=0.5),
dict(
type='Resize',
img_scale=[(896, 896)],
ratio_range=(0.75, 1.25),
multiscale_mode='range',
keep_ratio=True),
dict(
type='CutOut',
n_holes=(5, 10),
cutout_shape=[(4, 4), (4, 8), (8, 4), (8, 8),
(16, 8), (8, 16), (16, 16), (16, 32), (32, 16), (32, 32),
(32, 48), (48, 32), (48, 48)],
cutout_p=0.5),
dict(type='RandomFlip', flip_ratio=0.5),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img', 'gt_bboxes', 'gt_labels']),
]
test_pipeline = [
dict(type='LoadImageFromFile'),
dict(
type='MultiScaleFlipAug',
img_scale=[(1200, 1200), (1024, 1024), (896, 896), (640, 640)],
flip=False,
transforms=[
dict(type='Resize', keep_ratio=True),
dict(type='RandomFlip'),
dict(type='Normalize', **img_norm_cfg),
dict(type='Pad', size_divisor=32),
dict(type='DefaultFormatBundle'),
dict(type='Collect', keys=['img']),
])
]
data = dict(
samples_per_gpu=4,
workers_per_gpu=4,
train=dict(
ann_file='/root/vinBigdata/mmdet_data/fold_0/annotations/train.json',
classes=classes,
img_prefix='/root/vinBigdata/mmdet_data/fold_0/train',
pipeline=train_pipeline),
val=dict(ann_file='/root/vinBigdata/mmdet_data/fold_0/annotations/val.json',
classes=classes,
img_prefix='/root/vinBigdata/mmdet_data/fold_0/val',
pipeline=test_pipeline),
test=dict(ann_file='/root/vinBigdata/mmdet_data/fold_0/annotations/val.json',
classes=classes,
img_prefix='/root/vinBigdata/mmdet_data/fold_0/val',
pipeline=test_pipeline))

optimizer

optimizer = dict(
lr=0.005, paramwise_cfg=dict(bias_lr_mult=2., bias_decay_mult=0.))
optimizer_config = dict(grad_clip=None)

learning policy

lr_config = dict(
policy='step',
warmup='linear',
warmup_iters=500,
warmup_ratio=0.1,
step=[36, 40])
total_epochs = 41

swa learning policy

swa_lr_config = dict(
policy='cyclic',
target_ratio=(1, 0.01),
cyclic_times=18,
step_ratio_up=0.0)
swa_total_epochs = 18

runtime

load_from = './weights/SWA-VFNetX-1-18-53.4_VFNetX-R2101-41e-0.01-0.0001-52.2.pth'
resume_from = None
workflow = [('train', 3)]`

@CuongNN218
Copy link
Author

above is my config file

@hyz-xmaster
Copy link
Owner

Hi @CuongNN218, what is your MMDetection version? lower than v2.4.0?

@CuongNN218
Copy link
Author

CuongNN218 commented Feb 2, 2021

@hyz-xmaster i used mmdetection 2.8.0 and use your repo to training. Can you check my config file for me ?

@hyz-xmaster
Copy link
Owner

Hi @CuongNN218, it is normal, because the original Res2Net has no DCN layers, so when you insert DCN layers, there is mismatch between the layer names of the original Res2Net and the DCN-based Res2Net. However, in the pre-trained VFNetX model which you are loading, there are DCN weights in the backbone, matching the DCN-based Res2Net.

@hyz-xmaster
Copy link
Owner

Regarding your config file, it seems fine. I am just curious about why you set workflow = [('train', 3)] since it is usual to set workflow = [('train', 1)].

@CuongNN218
Copy link
Author

@hyz-xmaster https://mmdetection.readthedocs.io/en/latest/tutorials/customize_runtime.html#customize-workflow you can read it in the link below. maybe i'm wrong about validation after 3 epochs

@hyz-xmaster
Copy link
Owner

@CuongNN218, you can add evaluation = dict(interval=3, metric='bbox') to the config file to enable evaluation on the val set after 3 training epochs. This will overwrite the default evaluation = dict(interval=1, metric='bbox').

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants