mmdetection训练自己的VOC数据集

16 篇文章 6 订阅
13 篇文章 0 订阅

最新的请移步我的另一篇博文【2.6.0】:https://blog.csdn.net/jy1023408440/article/details/110135699

官方步骤:

https://github.com/open-mmlab/mmdetection/blob/master/GETTING_STARTED.md

首先根据规范的VOC数据集导入到项目目录下,如下图所示:

mmdetection
├── mmdet
├── tools
├── configs
├── data
│   ├── VOCdevkit
│   │   ├── VOC2007
│   │   │   ├── Annotations
│   │   │   ├── JPEGImages
│   │   │   ├── ImageSets
│   │   │   │   ├── Main
│   │   │   │   │   ├── test.txt
│   │   │   │   │   ├── trainval.txt
然后复制configs/retinanet_x101_64x4d_fpn_1x.py ,更名为my.py

修改其中dataset settings部分:

dataset_type = 'VOCDataset'
data_root = 'data/VOCdevkit/'
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='RepeatDataset',  # to avoid reloading datasets frequently
        times=3,
        dataset=dict(
            type=dataset_type,
            ann_file=[
                data_root + 'VOC2007/ImageSets/Main/train.txt',#train.txt
            ],
            img_prefix=[data_root + 'VOC2007/'],
            img_scale=(1333, 800),
            img_norm_cfg=img_norm_cfg,
            size_divisor=32,
            flip_ratio=0.5,
            with_mask=False,
            with_crowd=False,
            with_label=True)),
    val=dict(
        type=dataset_type,
        ann_file=data_root + 'VOC2007/ImageSets/Main/trainval.txt',
        img_prefix=data_root + 'VOC2007/',
        img_scale=(1333, 800),
        img_norm_cfg=img_norm_cfg,
        size_divisor=32,
        flip_ratio=0,
        with_mask=False,
        with_crowd=False,
        with_label=True),
    test=dict(
        type=dataset_type,
        ann_file=data_root + 'VOC2007/ImageSets/Main/test.txt',
        img_prefix=data_root + 'VOC2007/',
        img_scale=(1333, 800),
        img_norm_cfg=img_norm_cfg,
        size_divisor=32,
        flip_ratio=0,
        with_mask=False,
        with_crowd=False,
        with_label=False,
        test_mode=True))

修改mmdetection/mmdet/datasets/voc.py下classes为自己的类

如遇到label=self.cat2label 报错,请查看本人的其他博客

 

运行python setup.py install,重新编译
 

运行代码python tools/train.py  config/my.py

 

推荐一个讲解比较详细的源代码的私人博客(如有侵权,请联系删除)
https://heary.cn/posts/mmdetection-基于PyTorch的开源目标检测系统/

评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值