Leotju / MGAN

Mask-Guided Attention Network for Occluded Pedestrian Detection. (ICCV'19)
128 stars 26 forks source link

Sharing training config? #16

Open msha096 opened 3 years ago

msha096 commented 3 years ago

Hi,

Is there anyone who would like to share the training file? I tried to set up by myself but failed.

model = dict(
    type='MGAN',
    pretrained='modelzoo://vgg16',
    backbone=dict(
        type='VGG',
        depth=16,
        frozen_stages=1),
    neck=None,
    rpn_head=dict(
        type='RPNHead',
        in_channels=512,
        feat_channels=512,
        anchor_scales=[4., 5.4, 7.2, 9.8, 13.2, 17.9, 24.2, 33.0, 44.1, 59.6, 80.0],
        anchor_ratios=[2.44],
        anchor_strides=[8],
        target_means=[.0, .0, .0, .0],
        target_stds=[1.0, 1.0, 1.0, 1.0],
        loss_cls=dict(
            type='CrossEntropyLoss', use_sigmoid=True, loss_weight=1.0),
        loss_bbox=dict(type='SmoothL1Loss', beta=1.0 / 9.0, loss_weight=1.0)
    ),
    bbox_roi_extractor=dict(
        type='SingleRoIExtractor',
        roi_layer=dict(type='RoIAlign', out_size=7, sample_num=2),
        out_channels=512,
        featmap_strides=[8]),
    mgan_head=dict(
        type='MGANHead'),
    bbox_head=dict(
        type='SharedFCBBoxHead',
        num_fcs=2,
        in_channels=512,
        fc_out_channels=1024,
        roi_feat_size=7,
        num_classes=2,
        target_means=[0., 0., 0., 0.],
        target_stds=[0.1, 0.1, 0.2, 0.2],
        reg_class_agnostic=False,
        loss_cls=dict(
            type='FocalLoss',
            use_sigmoid=True,
            gamma=2.0,
            alpha=0.25,
            loss_weight=1.0),
        loss_bbox=dict(type='SmoothL1Loss', beta=0.11, loss_weight=1.0)
    )
)
# make up train_cfg, 2020-09-09
train_cfg = dict(
    assigner=dict(
        type='MaxIoUAssigner',
        pos_iou_thr=0.5,
        neg_iou_thr=0.4,
        min_pos_iou=0,
        ignore_iof_thr=-1),
    allowed_border=-1,
    pos_weight=-1,
    debug=False)

test_cfg = dict(
    rpn=dict(
        nms_across_levels=False,
        nms_pre=12000,
        nms_post=2000,
        max_num=2000,
        nms_thr=0.7,
        min_bbox_size=0),
    rcnn=dict(
        score_thr=0.0, nms=dict(type='nms', iou_thr=0.5), max_per_img=100)
)

dataset_type = 'CocoDataset'
data_root = 'datasets/CityPersons/'
img_norm_cfg = dict(mean=[123.675, 116.28, 103.53], std=[58.395, 57.12, 57.375], to_rgb=True)
data = dict(
    imgs_per_gpu=2,
    workers_per_gpu=2,
    train=dict(
        type=dataset_type,
    ann_file=data_root + 'annotations/train.json',
    img_prefix=data_root,
    img_scale=[(1216, 608),(2048, 1024)],
        multiscale_mode='range',
        img_norm_cfg=img_norm_cfg,
        size_divisor=32,
        flip_ratio=0.5,
        with_mask=False,
        with_crowd=True,
        with_label=True,
        extra_aug=dict(
            photo_metric_distortion=dict(brightness_delta=180, contrast_range=(0.5, 1.5),
                 saturation_range=(0.5, 1.5), hue_delta=18),
             random_crop=dict(min_ious=(0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9), min_crop_size=0.1),
         ),
    ),
    test=dict(
        type=dataset_type,
        ann_file=data_root + 'val_gt_for_mmdetction.json',
        img_prefix=data_root + '/leftImg8bit_trainvaltest/leftImg8bit/val_all_in_folder/',
        img_scale=(2048, 1024),
        img_norm_cfg=img_norm_cfg,
        size_divisor=32,
        flip_ratio=0,
        with_mask=False,
        with_label=False,
        test_mode=True)
)

mean_teacher=True
optimizer = dict(type='SGD', lr=0.00125, momentum=0.9, weight_decay=0.0001)
optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2), mean_teacher = dict(alpha=0.999))
# learning policy
lr_config = dict(
    policy='step',
    warmup='linear',
    warmup_iters=500,
    warmup_ratio=1.0 / 3,
    step=[8, 11])
checkpoint_config = dict(interval=1)
# yapf:disable
log_config = dict(
    interval=50,
    hooks=[
        dict(type='TextLoggerHook'),
        # dict(type='TensorboardLoggerHook')
    ])

# runtime settings
total_epochs = 40
dist_params = dict(backend='nccl')
log_level = 'INFO'
work_dir = '../work_dirs/mgan_0'
load_from = None
resume_from = None
workflow = [('train', 1)]`

With the following error:

`  File "tools/train.py", line 98, in <module>
    main()
  File "tools/train.py", line 94, in main
    logger=logger)
  File "/home/mingzhi/Downloads/Pedestron/mmdet/apis/train.py", line 63, in train_detector
    _non_dist_train(model, dataset, cfg, validate=validate)
  File "/home/mingzhi/Downloads/Pedestron/mmdet/apis/train.py", line 228, in _non_dist_train
    runner.run(data_loaders, cfg.workflow, cfg.total_epochs)
  File "/home/mingzhi/anaconda3/envs/pedest/lib/python3.7/site-packages/mmcv/runner/runner.py", line 358, in run
    epoch_runner(data_loaders[i], **kwargs)
  File "/home/mingzhi/anaconda3/envs/pedest/lib/python3.7/site-packages/mmcv/runner/runner.py", line 264, in train
    self.model, data_batch, train_mode=True, **kwargs)
  File "/home/mingzhi/Downloads/Pedestron/mmdet/apis/train.py", line 42, in batch_processor
    loss, log_vars = parse_losses(losses)
  File "/home/mingzhi/Downloads/Pedestron/mmdet/apis/train.py", line 22, in parse_losses
    for loss_name, loss_value in losses.items():
AttributeError: 'NoneType' object has no attribute 'items'`

In the paper, the loss function is combined with Faster R-CNN's loss + 0.5* MGA loss (BCE) + location-sensitive loss.

No idea where to config loss functions' weights... Anyone can help???

Thanks!

hiahiapiupiu commented 1 year ago

Hello, have you successfully replicated this code? I am also replicating this code, but it was not successful.