Skip to main content

This script converts the JSON format output by LabelMe to the text format required by YOLO serirs.

Project description

Forked from rooneysh/Labelme2YOLO

Labelme2YOLO

PyPI - Version PyPI - Python Version

Help converting LabelMe Annotation Tool JSON format to YOLO text file format. If you've already marked your segmentation dataset by LabelMe, it's easy to use this tool to help converting to YOLO format dataset.

Parameters Explain

--json_dir LabelMe JSON files folder path.

--val_size (Optional) Validation dataset size, for example 0.2 means 20% for validation.

--test_size (Optional) Test dataset size, for example 0.2 means 20% for Test.

--json_name (Optional) Convert single LabelMe JSON file.

How to Use

1. Convert JSON files, split training, validation and test dataset by --val_size and --test_size

Put all LabelMe JSON files under labelme_json_dir, and run this python command.

python labelme2yolo.py --json_dir /home/username/labelme_json_dir/ --val_size 0.15 --test_size 0.15

Script would generate YOLO format dataset labels and images under different folders, for example,

/home/username/labelme_json_dir/YOLODataset/labels/train/
/home/username/labelme_json_dir/YOLODataset/labels/test/
/home/username/labelme_json_dir/YOLODataset/labels/val/
/home/username/labelme_json_dir/YOLODataset/images/train/
/home/username/labelme_json_dir/YOLODataset/images/test/
/home/username/labelme_json_dir/YOLODataset/images/val/

/home/username/labelme_json_dir/YOLODataset/dataset.yaml

2. Convert JSON files, split training and validation dataset by folder

If you already split train dataset and validation dataset for LabelMe by yourself, please put these folder under labelme_json_dir, for example,

/home/username/labelme_json_dir/train/
/home/username/labelme_json_dir/val/

Put all LabelMe JSON files under labelme_json_dir. Script would read train and validation dataset by folder. Run this python command.

python labelme2yolo.py --json_dir /home/username/labelme_json_dir/

Script would generate YOLO format dataset labels and images under different folders, for example,

/home/username/labelme_json_dir/YOLODataset/labels/train/
/home/username/labelme_json_dir/YOLODataset/labels/val/
/home/username/labelme_json_dir/YOLODataset/images/train/
/home/username/labelme_json_dir/YOLODataset/images/val/

/home/username/labelme_json_dir/YOLODataset/dataset.yaml

3. Convert single JSON file

Put LabelMe JSON file under labelme_json_dir. , and run this python command.

python labelme2yolo.py --json_dir /home/username/labelme_json_dir/ --json_name 2.json

Script would generate YOLO format text label and image under labelme_json_dir, for example,

/home/username/labelme_json_dir/2.text
/home/username/labelme_json_dir/2.png

Installation

pip install labelme2yolo

License

labelme2yolo is distributed under the terms of the MIT license.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

labelme2yolo-0.0.2.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

labelme2yolo-0.0.2-py3-none-any.whl (7.7 kB view details)

Uploaded Python 3

File details

Details for the file labelme2yolo-0.0.2.tar.gz.

File metadata

  • Download URL: labelme2yolo-0.0.2.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.23.0

File hashes

Hashes for labelme2yolo-0.0.2.tar.gz
Algorithm Hash digest
SHA256 789cf0599ced8d3d6517f1ec847aa71aa573965162a352303e9a5b67310b7e9c
MD5 dc3599aaf42d64ef7c70ece7a5f6353e
BLAKE2b-256 d1f733f6e0d22b4aad81bf1db9b134b0e1f3ca3053d05606c1d871b0909d9eb2

See more details on using hashes here.

File details

Details for the file labelme2yolo-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: labelme2yolo-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 7.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.23.0

File hashes

Hashes for labelme2yolo-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3602e8cb81ad7094f03fbf4662842be059793c8fe41c6cb45e49c9f0a018ce2f
MD5 0c8c87318db329ababcc04cd34b76893
BLAKE2b-256 368444a00bb2e99c1aab0d7261dae2163ec5dafe8780cd8414d77df2a29d134b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page