
English README Available
Table of Contents
-
About The Project
-
Getting Started
- Usage
- Roadmap
- Contributing
- License
- Contact
- Acknowledgments
About The Project
仓库中的脚本用于将 labelme 标注的数据转换为 PASCAL VOC 格式和 MS COCO 格式的数据集,便于直接利用支持这两种格式的框架进行训练。
脚本都使用 Python 写的。
大部分的脚步都是参考的 labelme 项目中的 examples 内容。然后添加一些根据自己的数据集自定义的功能,比如标签转换、自定义图像名称等。
注意:这些脚本其实并不复杂,有 Python 基础的同学可以过一遍转换的流程,确保在你的数据集上是可以正常运行的。有一些地方我标注了 MARK,表示在这些地方需要留意,可以根据自己的需要进行修改。
拓展:这些脚本当时只是用来转换我自己的数据集。如果你需要转换其他领域的数据集,比如实例分割、语义分割或者视频标注等等。建议去 lebelme 的 examples 部分看看,作者提供了一些示例代码,可以参考。
(back to top)
Built With
(back to top)
Getting Started
Prerequisites
-
将 lebelme 标注得到的 JSON 文件放在一个文件夹内。举个例子,命名为 labelme_jsons_dir。
-
准备好一份 text 文本,里面包含数据集的分类标签。举个例子,命名为 label_names.txt。可以参考下项目里的 test/label_names.txt。
-
如果有转换标签的需求(比如中文标签转为英文),准备一个文本,包含转换的规则,举个例子,命名为label_dict.txt。可以参考下项目里的 test/label_dict.txt 。
Installation
develop mode 安装
-
建议使用 Python 3.10 或更高版本的虚拟环境安装 Python Package。
conda create --name=labelme python=3.10
conda activate labelme
pip install -r requirements.txt
-
克隆仓库。
git clone [email protected]:veraposeidon/labelme2Datasets.git
-
本地安装
cd labelme2Datasets
# (推荐)可编辑模式安装,即可以修改代码
pip install -e .
# 第二种安装方式,可以直接运行脚本,但是不能修改代码
#python setup.py install
直接使用 PyPI
同时发布了一个 PyPI package,labelme2datasets。
可以直接使用 pip3 install labelme2datasets 进行安装。
如果项目中的流程不适用于你的数据集,建议通过上述 develop mode 安装和修改代码。
(back to top)
Usage
-
转换单个 JSON 文件。 (labelme_json2dataset.py)
labelme_json2dataset --json_file=data/sample.json \
--output_dir=output/test_single_output
-
转换 JSON 文件夹labelme_jsons_dir 到 VOC 格式的数据集。 (labelme_bbox_json2voc.py)
- 不需要标签转换
labelme_bbox_json2voc --json_dir=data/sample_jsons \
--output_dir=output/test_voc_output --labels data/label_names.txt
- 需要标签转换
labelme_bbox_json2voc --json_dir=data/sample_jsons \
--output_dir=output/test_voc_output \
--labels data/label_names.txt \
--label_dict data/label_dict.txt
-
分割 VOC 数据的训练集和测试集。 (split_voc_datasets.py)
split_voc_datasets --voc_dir output/test_voc_output --test_ratio 0.3 --random_seed 42
train.txt 和 test.txt 会出现在 voc_dir/ImageSets/Main/ 文件夹下。
-
将 VOC 数据集转换为 COCO 数据集 (voc2coco.py)
voc2coco --voc_dir output/test_voc_output --coco_dir output/test_coco_output
(back to top)
Roadmap
See the open issues for a full list of proposed features (and known issues).
(back to top)
Contributing
如果你有什么建议可以让这个项目变得更好,可以 Fork 项目并且提交 Pull Request。
也可以简单地在 issues 中开一个 issue。
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature)
- Commit your Changes (
git commit -m 'Add some AmazingFeature')
- Push to the Branch (
git push origin feature/AmazingFeature)
- Open a Pull Request
(back to top)
License
Distributed under the MIT License. See LICENSE for more information.
(back to top)
veraposeidon - [email protected]
Project Link: https://github.com/veraposeidon/labelme2Datasets
(back to top)
Acknowledgments
(back to top)
评论