Table of Contents
About The Project
仓库中的脚本用于将 labelme 标注的数据转换为 PASCAL VOC 格式和 MS COCO 格式的数据集,便于直接利用支持这两种格式的框架进行训练。
脚本都使用 Python 写的。
大部分的脚步都是参考的 labelme 项目中的 examples 内容。然后添加一些根据自己的数据集自定义的功能,比如标签转换、自定义图像名称等。
注意:这些脚本其实并不复杂,有 Python 基础的同学可以过一遍转换的流程,确保在你的数据集上是可以正常运行的。有一些地方我标注了 MARK,表示在这些地方需要留意,可以根据自己的需要进行修改。
拓展:这些脚本当时只是用来转换我自己的数据集。如果你需要转换其他领域的数据集,比如实例分割、语义分割或者视频标注等等。建议去 lebelme 的 examples 部分看看,作者提供了一些示例代码,可以参考。
Built With
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 git@github.com:veraposeidon/labelme2Datasets.git
-
本地安装
cd labelme2Datasets # (推荐)可编辑模式安装,即可以修改代码 pip install -e . # 第二种安装方式,可以直接运行脚本,但是不能修改代码 #python setup.py install
直接使用 PyPI
同时发布了一个 PyPI package,labelme2datasets。
可以直接使用 pip3 install labelme2datasets 进行安装。
如果项目中的流程不适用于你的数据集,建议通过上述 develop mode 安装和修改代码。
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
Roadmap
- 将所有的脚本都通过 Pylint
- 中英文 README
- 调整项目结构
- 发布 Pypi 包
See the open issues for a full list of proposed features (and known issues).
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
License
Distributed under the MIT License. See LICENSE for more information.
Contact
veraposeidon - veraposeidon@gmail.com
Project Link: https://github.com/veraposeidon/labelme2Datasets
Acknowledgments
Metadata
Release files for labelme2datasets 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| labelme2datasets-0.0.4.tar.gz | 16.8 kB | Without provenance | Details for labelme2datasets-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| labelme2datasets-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for labelme2datasets-0.0.4-py3-none-any.whl |
Total release size: 32.1 kB
Release files / labelme2datasets-0.0.4.tar.gz
| Download URL | labelme2datasets-0.0.4.tar.gz |
|---|---|
| Size | 16.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
03a247632beeab1678e5ed55a9d22d86b6fd6c2fcd88bf5c8f865933388b9d3f
|
|
BLAKE2b-256 checksum How to use checksums |
4ca48cbe033a048345788c771b97344e8b7eaee3f1b4ba49a3450628849d8d64
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Release files / labelme2datasets-0.0.4-py3-none-any.whl
| Download URL | labelme2datasets-0.0.4-py3-none-any.whl |
|---|---|
| Size | 15.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e54b5a90525073a4fbb831b8729fc18ab5b19979be9da2a6bd6c99219b1ce0b7
|
|
BLAKE2b-256 checksum How to use checksums |
db2df31d6b8d3f689ba1918933fbba843657673f3686612724d378f3233340f2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.25
|
Security for labelme2datasets 0.0.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.