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. Repeat the flag to convert multiple directories in one run (requires --output_dir).

-o, --output_dir <OUTPUT_DIR> Output directory for the converted dataset [default: <json_dir>/YOLODataset]. Required when multiple --json_dir values are given.

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

3. Converting multiple directories into one dataset

Pass --json_dir multiple times to combine several source directories. An explicit --output_dir is required in this case:

labelme2yolo -d /path/to/src-a/ -d /path/to/src-b/ -o /path/to/output/

Files with the same name in different source directories are kept apart automatically.

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.4.0.tar.gz (44.3 kB view details)

Uploaded Source

Built Distributions

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

labelme2yolo-0.4.0-py3-none-win_amd64.whl (2.9 MB view details)

Uploaded Python 3Windows x86-64

labelme2yolo-0.4.0-py3-none-win32.whl (2.6 MB view details)

Uploaded Python 3Windows x86

labelme2yolo-0.4.0-py3-none-musllinux_1_2_x86_64.whl (3.8 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

labelme2yolo-0.4.0-py3-none-musllinux_1_2_i686.whl (3.8 MB view details)

Uploaded Python 3musllinux: musl 1.2+ i686

labelme2yolo-0.4.0-py3-none-musllinux_1_2_armv7l.whl (3.6 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARMv7l

labelme2yolo-0.4.0-py3-none-musllinux_1_2_aarch64.whl (3.6 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

labelme2yolo-0.4.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (3.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

labelme2yolo-0.4.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl (3.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ s390x

labelme2yolo-0.4.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl (4.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ppc64le

labelme2yolo-0.4.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (3.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

labelme2yolo-0.4.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (3.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARMv7l

labelme2yolo-0.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (3.6 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

labelme2yolo-0.4.0-py3-none-macosx_11_0_arm64.whl (3.2 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

labelme2yolo-0.4.0-py3-none-macosx_10_12_x86_64.whl (3.4 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: labelme2yolo-0.4.0.tar.gz
  • Upload date:
  • Size: 44.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for labelme2yolo-0.4.0.tar.gz
Algorithm Hash digest
SHA256 350af28128534e7cb3313f2e036e463b9ec54a538a96b46ce9e0b532958d1b3e
MD5 41c414f4ed32d9df8fba4c56ee789c6b
BLAKE2b-256 894aa72548f448f4a9657f3095b6a540b7ffc4ce01afd8193df47b66fc7065b5

See more details on using hashes here.

File details

Details for the file labelme2yolo-0.4.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for labelme2yolo-0.4.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 6753f469363bbdc3f1fd8d2a62900a5534d626e1f16a16357405abd6c049236d
MD5 3a76c16c8951476e6c7ca0507eca8a83
BLAKE2b-256 d3321fb14b2cd26ae5e9aa746184ce59dee3320b0e159335c92145e5c2d0e91d

See more details on using hashes here.

File details

Details for the file labelme2yolo-0.4.0-py3-none-win32.whl.

File metadata

  • Download URL: labelme2yolo-0.4.0-py3-none-win32.whl
  • Upload date:
  • Size: 2.6 MB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for labelme2yolo-0.4.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 a94ae65789cf297d131c09aa5c705dff53e5cb77acabb5ee5800696bb8cde79d
MD5 46c7c425ae46e23b036cff14da7c9565
BLAKE2b-256 67d711663554687ff24c1ed91414550c7271353dd03933d9e14305fa7275ba0b

See more details on using hashes here.

File details

Details for the file labelme2yolo-0.4.0-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for labelme2yolo-0.4.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 89b80cab4332e1e1627aa8fde705b0b269893259a7a0b2270c412abdf8eea970
MD5 ac41580b2588b3768a6c9b10ea5b77b4
BLAKE2b-256 dcca719db129a38e76d301801d8fbf8bbf75ddf900a11f587b7ae9c6bdd457db

See more details on using hashes here.

File details

Details for the file labelme2yolo-0.4.0-py3-none-musllinux_1_2_i686.whl.

File metadata

File hashes

Hashes for labelme2yolo-0.4.0-py3-none-musllinux_1_2_i686.whl
Algorithm Hash digest
SHA256 642180946c84fdedaae22312a8c8352580946a9c02ee2dc93b540c0700ce389b
MD5 c8382d2ad7b2e2bc9672da83ef9ee4d0
BLAKE2b-256 5f93fb16a5f683658c144eb5088e7cffd75edeb1ec1704009b6b1f6d6d5a0241

See more details on using hashes here.

File details

Details for the file labelme2yolo-0.4.0-py3-none-musllinux_1_2_armv7l.whl.

File metadata

File hashes

Hashes for labelme2yolo-0.4.0-py3-none-musllinux_1_2_armv7l.whl
Algorithm Hash digest
SHA256 ca7e33faf0b055a4efe87d093f80287b2a6497056412e3249cb4df879cba7dc6
MD5 eb11ae71640514a2ee4a4edd5fd35a86
BLAKE2b-256 c6dfc366168f08e288c856183c19ecdc802e837fc57ad8793231d273df758607

See more details on using hashes here.

File details

Details for the file labelme2yolo-0.4.0-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for labelme2yolo-0.4.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 fb650bb5a3cf737cefb60f98e352aa92231bd7ba211349916f25026d062f6a21
MD5 297a8af28ba589f9530559f81e8fa3f8
BLAKE2b-256 9c1e6a83288100f4a13e6512f4dd1c2e0508e6eb6e4ca6086e9d251e09fce4e9

See more details on using hashes here.

File details

Details for the file labelme2yolo-0.4.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for labelme2yolo-0.4.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 317f96f817d2d035ee782b3b72208f6d4b753a697dca44ee94f8550b06350baa
MD5 f973eef5589b9980a287574a3e052763
BLAKE2b-256 dfe5d444eb5e5d587587b1af1a013e23f3295af6742fa3c4c7642b14b4ac0d70

See more details on using hashes here.

File details

Details for the file labelme2yolo-0.4.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl.

File metadata

File hashes

Hashes for labelme2yolo-0.4.0-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl
Algorithm Hash digest
SHA256 950ca24bee84d755beeb1e5dc2b9ce5df09f6e535e1812699a8b52f41d0800c5
MD5 977617d01205c8fefb6ad05b27277996
BLAKE2b-256 8eda33f62163b137d98e83b2886b6a96f21604dfb42419eb51b77d2978c3e7e9

See more details on using hashes here.

File details

Details for the file labelme2yolo-0.4.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl.

File metadata

File hashes

Hashes for labelme2yolo-0.4.0-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl
Algorithm Hash digest
SHA256 d0954db92d0f40c045c6615e867a681e411db8e100be31cf1d5a7829b03e6176
MD5 97f695180f7e23d3979c1f47325e07dd
BLAKE2b-256 610f52e0aba46e0f0c05833c9f03c7d8fe72ef9870ae8bd40d34d664c362561e

See more details on using hashes here.

File details

Details for the file labelme2yolo-0.4.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for labelme2yolo-0.4.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 72557f3d64fefce95d77ed5e4f4d8db603f0920bed26a60095d0dbd8bc124af9
MD5 3b6eb832a785d59cc99422d0b401a789
BLAKE2b-256 c4181c1915c06e21961e91bdf737cf44d705aeb38c37440ba59929b36e0b6c11

See more details on using hashes here.

File details

Details for the file labelme2yolo-0.4.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl.

File metadata

File hashes

Hashes for labelme2yolo-0.4.0-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl
Algorithm Hash digest
SHA256 45c5e3e3b739ef9a8c90291346f6e0b988f7c3b2f7d3d41a126f1fd7c75e91e9
MD5 702d7bf331b3151b84f09ee9ab5e3b7e
BLAKE2b-256 e893650bb7bb2199ad0f6cfcfbab2531cf23cfabc6c4f03345bcff9f6770619a

See more details on using hashes here.

File details

Details for the file labelme2yolo-0.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for labelme2yolo-0.4.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 014c3fb2a40bbfdf62436d16a1f8d478387606a51313213135dc4f929fb5533d
MD5 06425f260fd0f7975811e255f9d74c07
BLAKE2b-256 9377abda1396b18418a22d0b37bf91c02d85cad42da1d101c36ddf6eb92fa238

See more details on using hashes here.

File details

Details for the file labelme2yolo-0.4.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for labelme2yolo-0.4.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6a007b597770d27a892854bfb0b2f3baba2d2abef3cac643c07a4957f4bcc9f2
MD5 7b01ef8801d4ed8a3eb2b9b9799d32bc
BLAKE2b-256 c301596abd039527dd89f6dcba530952f87cc69cd7b786de0836f9c7809d08ce

See more details on using hashes here.

File details

Details for the file labelme2yolo-0.4.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for labelme2yolo-0.4.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 8757b30a7ecbeecad8944fbc63f7df6c8048e4fb299a3f9e5ed8b17dccfb5139
MD5 cfc8efb876a76bc071a8586c16d18d39
BLAKE2b-256 cf424f497051dd451970b1b2aca7978d515c944b10095912e0e1e9d2600275ef

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