Skip to content

Export Supervisely project in YOLOv8 format (downloadable tar archive)

Notifications You must be signed in to change notification settings

supervisely-ecosystem/export-to-yolov8

Repository files navigation

Export to YOLOv8 format for instance segmentation and pose estimation tasks

OverviewPreparationHow to RunHow to UseRelated apps

GitHub release (latest SemVer) views runs

Overview

This application is designed specifically for instance segmentation and pose estimation tasks.

It transforms datasets from the Supervisely format to the YOLOv8 segmentation format or pose estimation format. By using this application, you can effortlessly convert your dataset and download as tar archive.

Changelog:

🏃 v1.0.0 - Starting from this version application supports exporting keypoints (graph geometry) to YOLOv8 format for pose estimation tasks.

Labels Format

The YOLOv8 format is a text-based format that is used to represent object detection, instance segmentation, and pose estimation datasets.

  • Each image in the dataset has a corresponding text file with the same name as the image file and the .txt extension in the labels folder.
  • Each object is represented by a separate line in the file, containing the class-index and the coordinates of the bounding mask, normalized to the range of 0 to 1 (relative to the image dimensions).

Segmentation:

The format for a single row in the segmentation dataset output files is as follows:

<class-index> <x1> <y1> <x2> <y2> ... <xn> <yn>

In this format, <class-index> is the index of the class for the object, and <x1> <y1> <x2> <y2> ... <xn> <yn> are the bounding coordinates of the object's segmentation mask. The coordinates are separated by spaces.

Here is an example of the YOLO instance segmentation dataset format for a single image with two object instances:

0 0.6812 0.48541 0.67 0.4875 0.67656 0.487 0.675 0.489 0.66
1 0.5046 0.0 0.5015 0.004 0.4984 0.00416 0.4937 0.010 0.492 0.0104

Learn more about Yolov8 segmentation format here.

Detection:

Learn more about Yolov8 segmentation format here.

Pose:

The format for a single row in the pose estimation dataset output files is as follows:

Format with Dim = 2

<class-index> <x> <y> <width> <height> <px1> <py1> <px2> <py2> ... <pxn> <pyn>

Format with Dim = 3

<class-index> <x> <y> <width> <height> <px1> <py1> <p1-visibility> <px2> <py2> <p2-visibility> <pxn> <pyn> <p2-visibility>

In this format, is the index of the class for the object, are coordinates of bounding box, and ... are the pixel coordinates of the keypoints. The coordinates are separated by spaces.

Learn more about Yolov8 pose estimation format here.

Preparation

Supervisely project has to contain only classes with shape Polygon, Bitmap, AlphaMask for segmentation tasks or Graph for pose estimation tasks. If your project has classes with other shapes, labels with other types of shapes will be skipped. We recommend you to use Convert Class Shape app to convert class shapes (supported for segmentation tasks only).

In addition, YOLOv8 format implies the presence of train/val datasets. Thus, to split images on training and validation datasets you should assign corresponding tags (train or val) to images. If image doesn't have such tags, it will be treated as train. We recommend to use app Assign train/val tags to images.

How to Run

  1. Add app to your team from Ecosystem if it is not there.

  2. Open context menu of project -> Download as -> Export to YOLO v8 format

You can also run the application from the Ecosystem

How to Use

App creates task in workspace tasks list. Once app is finished, you will see download link to resulting tar archive.

Resulting archive is saved in :

Current Team -> Files -> /tmp/supervisely/export/Export to YOLOv8 format/<task_id>/<project_id>_<project_name>.tar.

For example our file path is the following:

/tmp/supervisely/export/Export to YOLOv8 format/32803/20600_Demo.tar.

If there are no train or val tags in project, special warning is printed. You will see all warnings in task logs.

Here is the example of data_config.yaml that you will find in archive:

names: [kiwi, lemon]            # class names
colors: [[255,1,1], [1,255,1]]  # class colors
nc: 2                           # number of classes
train: ../lemons/images/train   # path to train imgs
val: ../lemons/images/val       # path to val imgs

# Keypoints (for pose estimation tasks)
kpt_shape: [17, 3]  # number of keypoints, number of dims (2 for x,y or 3 for x,y,visible)

Related apps

  • Train YOLOv8 - app allows to create custom YOLOv8 weights through training process.

  • Serve YOLOv8 - app allows to deploy YOLOv8 model as REST API service.