使用PaddleDetection自带脚本将自制labelme数据集转为coco格式

问题

PaddleDetection(ppdet)自带一个能将labelme标注的数据集转为coco格式的脚本,还能设置比例分配train、val和test数据集的比例。当前使用的ppdet版本为ver. 0.4。

转换方法

1. clone ppdet进入根目录
git clone https://github.com/PaddlePaddle/PaddleDetection.git
2. 执行转换脚本
python tools/x2coco.py \
                --dataset_type labelme \
                --json_input_dir ./labelme_annos/ \
                --image_input_dir ./labelme_imgs/ \
                --output_dir ./cocome/ \
                --train_proportion 0.8 \
                --val_proportion 0.2 \
                --test_proportion 0.0

如果只是想要合并所有训练集可以这样写

python tools/x2coco.py --dataset_type labelme --json_input_dir E:\BaiduNetdiskDownload\coco-airs\label --image_input_dir E:\BaiduNetdiskDownload\coco-airs\image  --output_dir E:\BaiduNetdiskDownload\coco-airs\dataset --train_proportion 1.0 --val_proportion 0.0 --test_proportion 0.0
参数描述
dataset_type需要转换的数据格式,目前支持:’voc‘、’labelme‘和’cityscape‘
json_input_dir使用labelme标注的json文件所在文件夹
image_input_dir图像文件所在文件夹
output_dir转换后的COCO格式数据集存放位置
train_proportion标注数据中用于train的比例
val_proportion标注数据中用于validation的比例
test_proportion标注数据中用于infer的比例

分类可在categories修改。

{    
    "images":[...],
    "categories": [
    {"supercategory": "component","id": 1,"name": "mouth"},
    {"supercategory": "component","id": 2,"name": "teeth"},
    {"supercategory": "component","id": 3,"name": "tongue"},
    {"supercategory": "component","id": 4,"name": "oropharynx"},
    {"supercategory": "component","id": 5,"name": "uvula"},
    ]
}

预测效果
预测效果

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Alex-Leung

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值