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 - Downloads

Labelme2YOLO efficiently converts LabelMe's JSON format to the YOLOv5 dataset format. It also supports YOLOv5/YOLOv8 segmentation datasets, making it simple to convert existing LabelMe segmentation datasets to YOLO format.

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).

Performance

Labelme2YOLO is implemented in Rust, which makes it significantly faster than equivalent Python implementations. In fact, it can be up to 100 times faster, allowing you to process large datasets more efficiently.

Installation

pip install labelme2yolo

Arguments

[LABEL_LIST]... Comma-separated list of labels in the dataset.

Options

-d, --json_dir <JSON_DIR> Directory containing LabelMe JSON files.

--val_size <VAL_SIZE> Proportion of the dataset to use for validation (between 0.0 and 1.0) [default: 0.2].

--test_size <TEST_SIZE> Proportion of the dataset to use for testing (between 0.0 and 1.0) [default: 0].

--output_format <OUTPUT_FORMAT> Output format for YOLO annotations: 'bbox' or 'polygon' [default: bbox] [aliases: format] [possible values: polygon, bbox].

--seed Seed for random shuffling [default: 42].

-h, --help Print help.

-V, --version Print version.

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

pip install maturin
maturin develop

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.2.5.tar.gz (14.2 kB view hashes)

Uploaded Source

Built Distributions

labelme2yolo-0.2.5-py3-none-win_amd64.whl (1.1 MB view hashes)

Uploaded Python 3 Windows x86-64

labelme2yolo-0.2.5-py3-none-win32.whl (969.9 kB view hashes)

Uploaded Python 3 Windows x86

labelme2yolo-0.2.5-py3-none-musllinux_1_2_x86_64.whl (1.4 MB view hashes)

Uploaded Python 3 musllinux: musl 1.2+ x86-64

labelme2yolo-0.2.5-py3-none-musllinux_1_2_i686.whl (1.4 MB view hashes)

Uploaded Python 3 musllinux: musl 1.2+ i686

labelme2yolo-0.2.5-py3-none-musllinux_1_2_armv7l.whl (1.3 MB view hashes)

Uploaded Python 3 musllinux: musl 1.2+ ARMv7l

labelme2yolo-0.2.5-py3-none-musllinux_1_2_aarch64.whl (1.4 MB view hashes)

Uploaded Python 3 musllinux: musl 1.2+ ARM64

labelme2yolo-0.2.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ x86-64

labelme2yolo-0.2.5-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl (1.5 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ s390x

labelme2yolo-0.2.5-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (1.4 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ ppc64le

labelme2yolo-0.2.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (1.4 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ i686

labelme2yolo-0.2.5-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (1.3 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ ARMv7l

labelme2yolo-0.2.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.3 MB view hashes)

Uploaded Python 3 manylinux: glibc 2.17+ ARM64

labelme2yolo-0.2.5-py3-none-macosx_11_0_arm64.whl (1.2 MB view hashes)

Uploaded Python 3 macOS 11.0+ ARM64

labelme2yolo-0.2.5-py3-none-macosx_10_12_x86_64.whl (1.3 MB view hashes)

Uploaded Python 3 macOS 10.12+ x86-64

Supported by

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