How to train models

Learn how to use Supervisely Apps to train custom AI models, deploy them on your GPU and use in the labeling toolboxes

This 5-minute tutorial is a part of introduction to Supervisely series. You can complete them one-by-one, in random order, or jump to the rest of the documentation at any moment.

To learn more about training a model on your custom data and pre-labeling (getting predictions from) your images with the trained models, watch this video tutorial.

We will provide a step-by-step guide for training a custom model, using YOLO (v8, v9) as an example. Supervisely offers a no-code solution for training, deploying and predicting with YOLO (v8, v9) models directly in your web browser, leveraging user-friendly interfaces and integrated tools.

Step 1. Prepare training data

You have several options for preparing your training data:

  • Upload your images, label them, and then train a custom neural network model.

We recommend starting experiments with several hundred images. Continuously improve your object detection neural network by adding new images, especially those where the model's accuracy is lower.

Step 2. Deploy an agent

Before you start training or running neural networks, you need to connect your PC or a cloud server with a GPU to Supervisely by running a simple command in your terminal. This connection allows you to train neural networks and run inference directly from the Supervisely web interface. You can find detailed instructions on how to do this here.

Ensure no network configuration is needed, and the connection is secure and private.

Step 3. Train a model

  1. Open the training app from your labeled data project, click the [⫶] button → Neural Networks → YOLO → Train YOLO (v8, v9).

  1. Follow the wizard to configure the main training settings, similar to those allowed by the original repository. You can:

  • Choose all or a subset of classes for training.

  • Define training and validation splits.

  • Select one of the available model architectures.

  • Configure training hyperparameters, including augmentations.

  1. Press the Train button and monitor logs, charts and visualizations in real-time.

  1. The training process generates artifacts, including model weights (checkpoints), logs, charts, additional visualizations of training batches, predictions on validation data, precision-recall curves, confusion matrices and so on. These artifacts will be automatically saved to your Team Files.

Step 4. Deploy a trained model

Once the model is trained, you probably want to try it on your data and evaluate its performance.

  1. Use the Serve YOLO (v8, v9) app to deploy your model as a REST API service so it can receive images and return predictions in response.

  2. Provide the checkpoint (model weights file in .pt format) and follow the app's instructions.

In Supervisely you can quickly deploy custom or pretrained neural network models weights on your GPU using the Serve Supervisely Applications in just a few clicks.

Step 5. Get predictions

Option 1. Integrate model in Labeling Interface

Use the NN Image Labeling app to apply your model to images or regions of interest during annotation, configure inference settings like confidence thresholds or select all or several model classes.

This approach gives you the ability to automatically pre-label images and then just manually correct model mistakes

Option 2. Apply model to all images at once

Use the Apply NN to Images Project app to pre-label all images in a project. Follow the wizard to configure settings and run batch inference (connect to the model, select model classes, configure inference settings, and preview predictions).

The app will iterate over all images in your project, apply your model in a batch manner, and save all predicted labels to a new project.

Step 6. Export weights

The trained model can be easily exported and used outside the platform. Go to the directory with training artifacts in your Team Files and download the model weights in PyTorch (.pt) format for external use.

Now you can follow the YOLOv8 documentation to get predictions on images.

Here is a Python example of inference:

from ultralytics import YOLO

# Load your model
model = YOLO("my_checkpoint.pt")

# Predict on an image
results = model("/a/b/c/my_image.jpg") 

# Process results list
for result in results:
    boxes = result.boxes  # Boxes object for bbox outputs
    masks = result.masks  # Masks object for segmentation masks outputs
    keypoints = result.keypoints  # Keypoints object for pose outputs
    

You can check the main section of the documentation on neural networks:

Starting with Neural Networks

Last updated