Skip to main content

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

Project description

Labelme2YOLO

PyPI - Version PyPI - Downloads PyPI - Python Version Codacy Badge

Labelme2YOLO is a powerful tool for converting LabelMe's JSON format to YOLOv5 dataset format. This tool can also be used for YOLOv5/YOLOv8 segmentation datasets, if you have already made your segmentation dataset with LabelMe, it is easy to use this tool to help convert to YOLO format dataset.

New Features

  • export data as yolo polygon annotation (for YOLOv5 & YOLOV8 segmentation)
  • Now you can choose the output format of the label text. The two available alternatives are polygon and bounding box (bbox).

Installation

pip install labelme2yolo

Arguments

--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.1 means 10% for Test.

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

--output_format (Optional) The output format of label.

--label_list (Optional) The pre-assigned category labels.

How to Use

1. Converting JSON files and splitting training, validation datasets

You may need to place all LabelMe JSON files under labelme_json_dir and then run the following command:

labelme2yolo --json_dir /path/to/labelme_json_dir/

This tool will generate dataset labels and images with YOLO format in different folders, such as

/path/to/labelme_json_dir/YOLODataset/labels/train/
/path/to/labelme_json_dir/YOLODataset/labels/val/
/path/to/labelme_json_dir/YOLODataset/images/train/
/path/to/labelme_json_dir/YOLODataset/images/val/
/path/to/labelme_json_dir/YOLODataset/dataset.yaml

2. Converting JSON files and splitting training, validation, and test datasets with --val_size and --test_size

You may need to place all LabelMe JSON files under labelme_json_dir and then run the following command:

labelme2yolo --json_dir /path/to/labelme_json_dir/ --val_size 0.15 --test_size 0.15

This tool will generate dataset labels and images with YOLO format in different folders, such as

/path/to/labelme_json_dir/YOLODataset/labels/train/
/path/to/labelme_json_dir/YOLODataset/labels/test/
/path/to/labelme_json_dir/YOLODataset/labels/val/
/path/to/labelme_json_dir/YOLODataset/images/train/
/path/to/labelme_json_dir/YOLODataset/images/test/
/path/to/labelme_json_dir/YOLODataset/images/val/
/path/to/labelme_json_dir/YOLODataset/dataset.yaml

How to build package/wheel

  1. install hatch
  2. Run the following command:
hatch build

License

Forked from rooneysh/Labelme2YOLO

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.1.6.tar.gz (16.1 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.1.6-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for labelme2yolo-0.1.6.tar.gz
Algorithm Hash digest
SHA256 f4b4e3ec4d7f9a07447291b262f25259f37550a0588213124a389e2b95c85a4f
MD5 27be99d81086291d58217f5ac49731bb
BLAKE2b-256 6baf94439fb2cb96b495abc940bf3de763f01ed1c63d9025fb7095bd577d3635

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for labelme2yolo-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1f85306533325321e8aece54f531ab16e12b41d5a7d3c1bff89181d1d4483ff4
MD5 27b1a259dceb87e2feb85d2d7712959c
BLAKE2b-256 3628e3d9f8b6f170fac5e5bec1e7fd83dc08d29145e3819f09c7e2e073daee2c

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