labelme-to-yolo
Convert LabelMe polygon annotations to Ultralytics YOLO format for instance segmentation — one command, ready-to-train dataset.
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
.jsonannotation files from a folder - Normalizes polygon coordinates to the
[0, 1]range expected by YOLO - Copies images and writes
.txtlabel files into the YOLO folder structure - Automatically splits your dataset into train / val / test sets
- Generates the
project.ymlconfiguration 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.
- Fork the repository
- Create a branch:
git checkout -b my-feature - Commit your changes following Conventional Commits
- Run the tests:
uv run poe test - 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.
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.
Metadata
Release files for labelme-to-yolo 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| labelme_to_yolo-0.2.1.tar.gz | 129.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| labelme_to_yolo-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 135.8 kB
Release files / labelme_to_yolo-0.2.1.tar.gz
| Download URL | labelme_to_yolo-0.2.1.tar.gz |
|---|---|
| Size | 129.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3e19e8deb87752521ae52fb73f7acf69f4f612bbd58d98490c8da815abb21d82
|
|
BLAKE2b-256 checksum How to use checksums |
9dd644020cd352d302b1ac46fa7862a78d9486fce99907ab8e2b14a799620269
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / labelme_to_yolo-0.2.1-py3-none-any.whl
| Download URL | labelme_to_yolo-0.2.1-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
637a053c350627445f97c376755ab8f1a40750f1b82dfde61ee47cb6d3b881da
|
|
BLAKE2b-256 checksum How to use checksums |
e80b1bf6c0476e8aa602c1410309f118840e337128994b756ddc65c21b0bc84b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|