import-from-yolo-obb

You need to be a Pro member to access the full content of this.

import-from-yolo-obb imports a dataset from YOLO-OBB (oriented bounding box) format, used by YOLOv8-OBB, into LabelMe format. Each box is imported as an oriented_rectangle shape.

The opposite conversion, LabelMe dataset → YOLO-OBB format, is available as export-to-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.

Usage

Pass a directory containing the YOLO-OBB dataset.

labelmetk import-from-yolo-obb DATASET_DIR

The YOLO-OBB dataset directory should look like this:

dogs_rectangle.export/
├── classes.txt
├── images
│   └── dogs_rectangle.jpg
└── labels
    └── dogs_rectangle.txt

If you want to try yourself, you can run:

labelmetk export-to-yolo-obb dogs_rectangle.json --class-names dog

To create a YOLO-OBB format dataset to try importing it back with import-from-yolo-obb.

Download an example JSON from:

dogs_rectangle.json (2.0MB)

Example: Import a Dataset

Pass the directory containing the YOLO-OBB dataset to import it to LabelMe format.

$ labelmetk import-from-yolo-obb dogs_rectangle.export/
Found 1 class names: ('dog',)
Found 1 image_label_pairs
Created 'dogs_rectangle.export.import/dogs_rectangle.jpg'
Created 'dogs_rectangle.export.import/dogs_rectangle.json'

The imported directory will have the following structure:

dogs_rectangle.export.import
├── dogs_rectangle.json
└── dogs_rectangle.jpg

Each box is imported as an oriented_rectangle shape. You can open and edit the imported dataset with the LabelMe annotation app:

labelme dogs_rectangle.export.import