import-from-yolo

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

import-from-yolo is a tool that allows you to import a dataset from YOLO format.

The opposite conversion, Labelme dataset → YOLO format, is available as export-to-yolo. Check it out.

What is YOLO format?

The YOLO format consists of two directories: images and labels. The images directory contains the images, and the labels directory contains the label files. Each label file has the same name as the image file but with a .txt extension.

The label file contains the bounding box annotations in the following format:

<class_id> <center_x> <center_y> <width> <height>

where:

Usage

Pass a directory containing the YOLO dataset.

labelmetk import-from-yolo examples/small_dataset.yolo/

The YOLO dataset directory should look like this:

examples/small_dataset.yolo/
├── classes.txt
├── images
│   ├── 2011_000003.jpg
│   ├── 2011_000006.jpg
│   └── 2011_000025.jpg
└── labels
    ├── 2011_000003.txt
    ├── 2011_000006.txt
    └── 2011_000025.txt

If you want to try yourself, you can run:

labelmetk export-to-yolo small_dataset/ --class-names bottle,bus,car,chair,person,sofa

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

Example: Import a Dataset

Pass the directory containing the YOLO dataset to import it to Labelme format.

% labelmetk import-from-yolo small_dataset.yolo/
Found 6 class names: ('bottle', 'bus', 'car', 'chair', 'person', 'sofa')
Found 3 image_label_pairs
Created 'small_dataset.yolo.import/2011_000025.jpg'
Created 'small_dataset.yolo.import/2011_000025.json'
Created 'small_dataset.yolo.import/2011_000003.jpg'
Created 'small_dataset.yolo.import/2011_000003.json'
Created 'small_dataset.yolo.import/2011_000006.jpg'
Created 'small_dataset.yolo.import/2011_000006.json'

The imported directory will have the following structure:

small_dataset.yolo.import
├── 2011_000003.json
├── 2011_000003.jpg
├── 2011_000006.json
├── 2011_000006.jpg
├── 2011_000025.json
└── 2011_000025.jpg

You can open and edit the imported dataset with Labelme annotation app:

labelme small_dataset.yolo.import

Download an example dataset from:

small_dataset.zip (389KB)