mmdetection使用

mmdetection参考博客

https://blog.csdn.net/gaoyi135/article/details/90613895#1dataset_31

 

csv2coco

https://github.com/spytensor/prepare_detection_dataset/blob/master/csv2coco.py

 

所有的命令跑之前都看看configs/XXX.py最下面,对应的work_dir建了没有

work_dir = './work_dirs/ga_faster_rcnn_x101_32x4d_fpn_1x'

 

test部分

1.制作test数据集的假csv,格式为

路径,bbox(4),label_name

2.运用csv2coco把数据集转换为coco的格式

3.把获得的coco格式的test数据集放到对应的位置,然后

修改config文件(以ga_faster_x101_32x4d_fpn_1x.py为例)中的(第5行 img_scale)

test_pipeline = [
    dict(type='LoadImageFromFile'),
    dict(
        type='MultiScaleFlipAug',
        img_scale=(683, 512),
        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']),
        ])
]

修改config文件中的第14行开始的test相关的dict(主要是16,17行)

data = dict(
    imgs_per_gpu=2,
    workers_per_gpu=2,
    train=dict(
        type=dataset_type,
        ann_file=data_root + 'annotations/instances_train2017.json',
        img_prefix=data_root + 'images/'  + 'train2017/',
        pipeline=train_pipeline),
    val=dict(
        type=dataset_type,
        ann_file=data_root + 'annotations/instances_val2017.json',
        img_prefix=data_root + 'images/'  + 'val2017/',
        pipeline=test_pipeline),
    test=dict(
        type=dataset_type,
        ann_file=data_root + 'annotations/instances_test2017.json',
        img_prefix=data_root  + 'images/'+ 'test2017/',
        pipeline=test_pipeline))

 

4.运行test.py

2019年9月14号晚上我用的是这个命令

python tools/test.py /xxxx/xxxx/mmdetection/configs/guided_anchoring/ga_faster_x101_32x4d_fpn_1x.py /xxxx/xxxx/mmdetection/work_dirs3/epoch_1.pth --json_out res091420 --eval bbox

此命令将生成包含bbox信息的coco格式的json,如果需要pkl和可视化,mmdet也提供了接口,参考下面的readme应该就懂了

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

 

5.对得到的json运行exchange.py

运行时需要修改文件中的第13,14行

data_anno="/xxxx/xxxx/mmdetection/results.pkl.bbox.json"
res_txt = "/xxxx/xxxx/guipang/ZJLAB_ZSD_2019/coco/annotations/res.txt"

 

 

  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值