赞
踩
现成的代码可用
https://github.com/fcakyon/labelme2coco
举个使用例子:下载或者clone之后,在该项目的根目录中创建一个main.py文件,使用下面这个代码。
- # import functions
- from labelme2coco import get_coco_from_labelme_folder, save_json
-
- # set labelme training data directory
- labelme_train_folder = "D:/test11/train"
- # 修改路径
- # train文件夹中是有图片文件有json文件的
-
- # set labelme validation data directory
- labelme_val_folder = "D:/test11/val"
- # 修改路径
- # val文件夹中是有图片文件有json文件的
-
- # set path for coco json to be saved
- export_dir = "D:/test11/annotations/"
- # 输出路径
-
- # create train coco object
- train_coco = get_coco_from_labelme_folder(labelme_train_folder)
-
- # export train coco json
- save_json(train_coco.json, export_dir+"train.json")
- #输出路径及输出文件名称train.json
-
- # create val coco object
- val_coco = get_coco_from_labelme_folder(labelme_val_folder, coco_category_list=train_coco.json_categories)
-
- # export val coco json
- save_json(val_coco.json, export_dir+"val.json")
- #输出路径及输出文件名称val.json
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。