MCPcopy Index your code
hub / github.com/GreatV/labelme2yolo

github.com/GreatV/labelme2yolo @v0.3.3

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.3.3 ↗ · + Follow
98 symbols 186 edges 12 files 61 documented · 62%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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 Directory containing LabelMe JSON files.

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

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

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

Core symbols most depended-on inside this repo

clone
called by 31
src/types.rs
create_output_directory
called by 13
src/utils.rs
generate_collision_resistant_name
called by 8
src/utils.rs
get_base_output_dir
called by 7
src/utils.rs
create_io_thread_pool
called by 4
src/utils.rs
increment_skipped_no_image_data
called by 4
src/types.rs
process_annotation
called by 4
src/conversion.rs
process_annotation_for_coco
called by 3
src/coco_dataset.rs

Shape

Function 47
Class 24
Method 24
Enum 3

Languages

Rust100%

Modules by API surface

src/utils.rs19 symbols
src/coco.rs19 symbols
src/types.rs16 symbols
src/coco_dataset.rs13 symbols
src/config.rs10 symbols
src/conversion.rs8 symbols
src/streaming_json.rs5 symbols
src/io.rs4 symbols
src/yolo_dataset.rs2 symbols
src/labelme2yolo.rs1 symbols
src/labelme2coco.rs1 symbols

For agents

$ claude mcp add labelme2yolo \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact