Closed CuongNN218 closed 3 years ago
I try to train VFNet Model with 14 class and get warning above. Is it normal ? I just change num_class in configs file VFNet to 14
it seems incorrect, Can you provide a detailed config?
@hhaAndroid `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)))
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)
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 = dict( lr=0.005, paramwise_cfg=dict(bias_lr_mult=2., bias_decay_mult=0.)) optimizer_config = dict(grad_clip=None)
lr_config = dict( policy='step', warmup='linear', warmup_iters=500, warmup_ratio=0.1, step=[36, 40]) total_epochs = 41
swa_lr_config = dict( policy='cyclic', target_ratio=(1, 0.01), cyclic_times=18, step_ratio_up=0.0) swa_total_epochs = 18
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)]`
@hhaAndroid I just change the classes in config file from 80 to 14
what is the ./weights/SWA-VFNetX-1-18-53.4_VFNetX-R2101-41e-0.01-0.0001-52.2.pth
? it seems that we don’t provide this. weight
what is the
./weights/SWA-VFNetX-1-18-53.4_VFNetX-R2101-41e-0.01-0.0001-52.2.pth
? it seems that we don’t provide this. weight I download it from this repo and use this repo to training: https://github.com/hyz-xmaster/VarifocalNet. It's the original repo of VFNet
@hhaAndroid if i set workflow = [('train', 3)]
, i expect that the validation process will run after 3 epochs training. Maybe i'm wrong, can you correct me ?
@CuongNN218
You should use the weight provided by openmmlab instead of hyz-xmaster/VarifocalNet
.
For now, you can use EvalHook
or val workflow
for validation, I recommend using EvalHook
, example setting:
workflow = [('train', 1)]
evaluation = dict(interval=3)
This means the validation process will run after 3 epochs of training