Skip to main content

labelme-to-yolo

Convert LabelMe polygon annotations to Ultralytics YOLO format for instance segmentation — one command, ready-to-train dataset.

PyPI Downloads Stars License: MIT Python 3.10+

This project is the active continuation of the archived labelme2yolov7segmentation repository. All future development happens here.


The Problem

You annotated your dataset with LabelMe — drawing polygons, assigning labels, exporting JSON files. Now you want to train a YOLO model and you discover that YOLO expects a completely different format: normalized coordinates, one .txt per image, a specific folder structure, and a project.yml config file.

Converting by hand is tedious and error-prone. labelme-to-yolo does it in a single command.


What it does

  • Reads all LabelMe .json annotation files from a folder
  • Normalizes polygon coordinates to the [0, 1] range expected by YOLO
  • Copies images and writes .txt label files into the YOLO folder structure
  • Automatically splits your dataset into train / val / test sets
  • Generates the project.yml configuration file ready to pass to Ultralytics

Quickstart

Install from PyPI:

pip install labelme-to-yolo

No install required (via pipx):

pipx run labelme-to-yolo --source-path /labelme/dataset --output-path /yolo/dataset

Run the conversion:

labelme2yolo --source-path /labelme/dataset --output-path /yolo/dataset

Usage

labelme2yolo --source-path PATH --output-path PATH
Option Description
--source-path Folder containing LabelMe .json files and their matching images
--output-path Destination folder for the YOLO dataset

Both relative and absolute paths are supported.

Expected output

Running:

labelme2yolo --source-path /labelme/dataset --output-path /yolo/datasets

Produces:

datasets/
├── images/
│   ├── train/
│   │   ├── img_1.jpg
│   │   └── img_2.jpg
│   ├── val/
│   │   └── img_3.jpg
│   └── test/
│       └── img_4.jpg
├── labels/
│   ├── train/
│   │   ├── img_1.txt
│   │   └── img_2.txt
│   ├── val/
│   │   └── img_3.txt
│   └── test/
│       └── img_4.txt
├── train.txt
├── val.txt
├── test.txt
└── project.yml

The generated project.yml can be passed directly to Ultralytics YOLO:

from ultralytics import YOLO

model = YOLO("yolov8n-seg.pt")
model.train(data="/yolo/datasets/project.yml", epochs=100)

Installation from source

git clone https://github.com/Tlaloc-Es/labelme-to-yolo.git
cd labelme-to-yolo
pip install -e .

Contributing

Contributions are welcome.

  1. Fork the repository
  2. Create a branch: git checkout -b my-feature
  3. Commit your changes following Conventional Commits
  4. Run the tests: uv run poe test
  5. Push your branch and open a pull request

⭐ If this saved you time, a star helps others find it

Stars help labelme-to-yolo appear when developers search for LabelMe and YOLO conversion tools. It takes 2 seconds.

⭐ Star on GitHub


License

MIT. See LICENSE.

Donation

If you want to support the project you can make a donation at https://www.buymeacoffee.com/tlaloc — thanks in advance.

Download files

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

Source Distribution

labelme_to_yolo-0.2.1.tar.gz (129.5 kB view details)

Uploaded Source

Built Distribution

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

labelme_to_yolo-0.2.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file labelme_to_yolo-0.2.1.tar.gz.

File metadata

  • Download URL: labelme_to_yolo-0.2.1.tar.gz
  • Upload date:
  • Size: 129.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for labelme_to_yolo-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3e19e8deb87752521ae52fb73f7acf69f4f612bbd58d98490c8da815abb21d82
MD5 05e0be7a72b5ee6970a944e8b2ca29ae
BLAKE2b-256 9dd644020cd352d302b1ac46fa7862a78d9486fce99907ab8e2b14a799620269

See more details on using hashes here.

File details

Details for the file labelme_to_yolo-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: labelme_to_yolo-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for labelme_to_yolo-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 637a053c350627445f97c376755ab8f1a40750f1b82dfde61ee47cb6d3b881da
MD5 5e033b5b4ba25c9851ec0a732a57627e
BLAKE2b-256 e80b1bf6c0476e8aa602c1410309f118840e337128994b756ddc65c21b0bc84b

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

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