Skip to main content

PyPI PythonVersion Pylint codebeat badge chinese
Contributors Forks Stargazers Issues MIT License


Logo

labelme2Datasets

用于将 LabelMe 标注的数据转换为 VOC 格式和 COCO 格式的数据集。
Report Bug · Request Feature

English README Available

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. 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

  1. 将 lebelme 标注得到的 JSON 文件放在一个文件夹内。举个例子,命名为 labelme_jsons_dir。

  2. 准备好一份 text 文本,里面包含数据集的分类标签。举个例子,命名为 label_names.txt。可以参考下项目里的 test/label_names.txt。

  3. 如果有转换标签的需求(比如中文标签转为英文),准备一个文本,包含转换的规则,举个例子,命名为label_dict.txt。可以参考下项目里的 test/label_dict.txt 。

Installation

develop mode 安装

  1. 建议使用 Python 3.10 或更高版本的虚拟环境安装 Python Package。

    conda create --name=labelme python=3.10
    conda activate labelme
    pip install -r requirements.txt
    
  2. 克隆仓库。

    git clone git@github.com:veraposeidon/labelme2Datasets.git
    
  3. 本地安装

     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

  • 将所有的脚本都通过 Pylint
  • 中英文 README
  • 调整项目结构
  • 发布 Pypi 包

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

如果你有什么建议可以让这个项目变得更好,可以 Fork 项目并且提交 Pull Request。 也可以简单地在 issues 中开一个 issue。

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Contact

veraposeidon - veraposeidon@gmail.com

Project Link: https://github.com/veraposeidon/labelme2Datasets

(back to top)

Acknowledgments

(back to top)

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)

Source distribution for labelme2datasets 0.0.4
File Size Uploaded
labelme2datasets-0.0.4.tar.gz 16.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for labelme2datasets 0.0.4
File Interpreter ABI Platform
labelme2datasets-0.0.4-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.0.4 This release

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page