export-to-yolo-obb
You need to be a Pro member to access the full content of this.
export-to-yolo-obb converts a LabelMe dataset to YOLO-OBB (oriented bounding box) format, used by YOLOv8-OBB for rotated object detection.
The opposite conversion, YOLO-OBB format → LabelMe dataset, is available as import-from-yolo-obb. Check it out.
What is YOLO-OBB format?
Like YOLO format, YOLO-OBB consists of an images directory and a labels directory. Each label file has the same name as its image but with a .txt extension.
Unlike axis-aligned YOLO, each line describes a box by its four corners:
<class_id> <x1> <y1> <x2> <y2> <x3> <y3> <x4> <y4>
where:
<class_id>: The class index (0-based).<x1> <y1> ... <x4> <y4>: The normalized coordinates of the four corners, in order.
NOTE: Only oriented_rectangle and rectangle shapes are exported. An oriented rectangle is written verbatim, and an axis-aligned rectangle is expanded to its four corners. Polygon, circle, and mask shapes are skipped with a warning, because fitting a rotated box around them would change the annotation.
Usage
Pass either a JSON file or directory of JSON files.
labelmetk export-to-yolo-obb [OPTIONS] DATASET_DIR
Options:
--class-names: Required. Specify class names as a comma-separated text (e.g., --class-names cat,dog). Use labelmetk list-labels to list the labels in a dataset.
Example: Export a Dataset
Pass the JSON file (or a directory of JSON files) and the class names to export the dataset to YOLO-OBB format.
$ labelmetk export-to-yolo-obb dogs_rectangle.json --class-names dog
Found 1 JSON files: ['dogs_rectangle.json']
[dogs_rectangle.json] Exported to dogs_rectangle.export
The exported directory will have the following structure:
dogs_rectangle.export
├── classes.txt
├── images
│ └── dogs_rectangle.jpg
└── labels
└── dogs_rectangle.txt
Each label line holds the class index followed by the four normalized corners:
0 0.17529296875 0.34375 0.41524834632873536 0.34375 0.41524834632873536 0.9040178680419921 0.17529296875 0.9040178680419921
Download an example JSON from:
dogs_rectangle.json (2.0MB)