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

Pretrained models of mobileNet and ssd300-mobilenetv2-voc #5495

Closed
TheLostIn opened this issue Jun 30, 2021 · 1 comment
Closed

Pretrained models of mobileNet and ssd300-mobilenetv2-voc #5495

TheLostIn opened this issue Jun 30, 2021 · 1 comment
Assignees
Labels
reimplementation Issues in model reimplementation

Comments

@TheLostIn
Copy link

TheLostIn commented Jun 30, 2021

Hi, I'm running ssd300-mobilenetv2-voc, I found there is no init_weight function in mmdetection/mmdet/models/backbones/mobilenet_v2.py.
And maybe baselines of ssd300-mobilenetv2-voc and ssd512-mobilenetv2-voc can be added to the model zoo.

Here's my config file

input_size = 300
model = dict(
    type='SingleStageDetector',
    # pretrained='/home/van/erestu/DATA/Distilling/pretrained_model/mobilenetv2_1.0-0c6065bc.pth',
    backbone=dict(
        type='MobileNetV2',
        out_indices=(4, 7),
        widen_factor=1.0
        ),
    neck=dict(
        type='SSDNeck',
        in_channels=[1280],
        out_channels=[1280, 512, 256, 256, 126],
        level_strides=[2, 2, 2, 2],
        level_paddings=[1, 1, 1, 1],
        l2_norm_scale=None,
        use_depthwise=True,
        norm_cfg=dict(type='BN'),
        act_cfg=dict(type='ReLU6')
    ),

    bbox_head=dict(
        type='SSDHead',
        in_channels=(96, 1280, 512, 256, 256, 126),
        num_classes=20,
        use_depthwise=True,
        anchor_generator=dict(
            type='SSDAnchorGenerator',
            scale_major=False,
            input_size=input_size,
            basesize_ratio_range=(0.15, 0.9),
            strides=[16, 30, 60, 100, 150, 300],
            ratios=[[2], [2, 3], [2, 3], [2, 3], [2], [2]]),
        bbox_coder=dict(
            type='DeltaXYWHBBoxCoder',
            target_means=[.0, .0, .0, .0],
            target_stds=[0.1, 0.1, 0.2, 0.2])),
        )

# model training and testing settings
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,
    neg_pos_ratio=3,
    smoothl1_beta=1.,
    debug=False)

test_cfg=dict(
    nms_pre=1000,
    min_bbox_size=0,
    score_thr=0.05,
    nms=dict(type='nms', iou_thr=0.5),
    max_per_img=100)

# dataset settings
dataset_type = 'VOCDataset'
data_root = 'VOCdevkit/'
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='Resize', img_scale=(1000, 600), keep_ratio=True),
    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=(1000, 600),
        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='ImageToTensor', keys=['img']),
            dict(type='Collect', keys=['img']),
        ])
]
data = dict(
    samples_per_gpu=1,
    workers_per_gpu=1,
    train=dict(
        type='RepeatDataset',
        times=3,
        dataset=dict(
            type=dataset_type,
            ann_file=[
                data_root + 'VOC2007/ImageSets/Main/trainval.txt',
                data_root + 'VOC2012/ImageSets/Main/trainval.txt'
            ],
            img_prefix=[data_root + 'VOC2007/', data_root + 'VOC2012/'],
            pipeline=train_pipeline)),
    val=dict(
        type=dataset_type,
        ann_file=data_root + 'VOC2007/ImageSets/Main/test.txt',
        img_prefix=data_root + 'VOC2007/',
        pipeline=test_pipeline),
    test=dict(
        type=dataset_type,
        ann_file=data_root + 'VOC2007/ImageSets/Main/test.txt',
        img_prefix=data_root + 'VOC2007/',
        pipeline=test_pipeline))
evaluation = dict(interval=1, metric='mAP')
# optimizer
optimizer = dict(type='SGD', lr=0.01, momentum=0.9, weight_decay=0.0001)
optimizer_config = dict(grad_clip=None)
# learning policy
lr_config = dict(
    policy='step',
    warmup='linear',
    warmup_iters=200,
    warmup_ratio=0.001,
    step=[3])
# runtime settings
total_epochs = 4  # actual epoch = 4 * 3 = 12
checkpoint_config = dict(interval=1)
# yapf:disable
log_config = dict(
    interval=100,
    hooks=[
        dict(type='TextLoggerHook'),
        # dict(type='TensorboardLoggerHook')
    ])
# yapf:enable
dist_params = dict(backend='nccl')
log_level = 'INFO'
load_from = None
resume_from = None
workflow = [('train', 1)]
runner = dict(type='EpochBasedRunner', max_epochs=4)
@TheLostIn TheLostIn added the reimplementation Issues in model reimplementation label Jun 30, 2021
@TheLostIn TheLostIn changed the title Pretrained model of mobileNet and ssd300-mobilenetv2-voc Pretrained models of mobileNet and ssd300-mobilenetv2-voc Jun 30, 2021
@RangiLyu
Copy link
Member

RangiLyu commented Jul 7, 2021

MobileNetV2 imagenet pretrained model has been uploaded (open-mmlab/mmcv#1177). Now you can set init_cfg=dict(type='Pretrained', checkpoint='open-mmlab://mmdet/mobilenet_v2') in backbone with the latest MMCV.

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

No branches or pull requests

2 participants