Neural networks

SuperAnnotate suggests a one-click model training within the platform and makes it possible to integrate training and prediction calls within the Python pipeline.

Training

To run a model training:

sa.run_training(
  model_name = "Cityscapes Segmentation Model", 
  model_description = "Model Finetuned on Cityscapes", 
  task = "Instance Segmentation for Vector Projects",
  base_model = "Instance Segmentation (trained on COCO)", 
  train_data = ["Cityscapes/Batch 1", "Cityscapes/Batch 2"], 
  test_data = ["Cityscapes/Test"], 
  hyperparameters = {"base_lr": 0.02, "images_per_batch": 8},
  log = True)

Each training task is processed by refining the base_model on the train_data where the base_model can be either one of the provided pre-trained models or a custom model trained on the platform.

Check the full list of pre-trained models in the table below:

Task

Base model

Instance Segmentation for Vector Projects

Instance segmentation (trained on COCO)

Instance Segmentation for Pixel projects

Instance segmentation (trained on COCO)

Object Detection for Vector projects

Object detection (trained on COCO)

Semantic Segmentation for Pixel projects

Semantic segmentation (trained on Cityscapes)

🚧

  • The values of task and base_model are case-sensitive. Type them as they appear in the table above.
  • The values of train_data and test_data should be folders that contain at least one image with the Completed status. Don't use the same project or folder to train and test data.

Adjust the default values of the training hyperparameters based on the following table:

Parameter

Description

Default value

instance_type

The type of the devices (GPUs) that are available to train your model. You have 2 options: One T4 GPU with a 16GB memory or four GPUs of the same type.

"1 x T4 16 GB"

num_epochs

The number of times the dataset undergoes training. The epoch count ranges from 10 to 200.

12

images_per_batch

Number of images fed to the network per training iteration per GPU.

4

base_lr

The model’s initial learning step. The learning rate ranges from 0 to 1.

0.02

batch_per_image

The number of regions of interest (ROI) per image. The ROI ranges from 2 to 512 and is a power of 2. The smaller the ROI, the faster the learning rate. Image (ROIs) per batch works only with instance segmentation.

512

evaluation_period

The number of epochs to run evaluation periodically. If the epoch count is 10 and the evaluation period is 2, it means that the dataset will undergo an evaluation every 2 epochs. The user will be reported of the best model that resulted from the evaluation period.

12

gamma

Gamma is needed for the learning rate. Its value ranges from 0 to 1, and it will be multiplied with the learning rate.

0.5

steps

List of epoch counts to decrease learning rate gamma times.

[5]

Smart Prediction

To run Smart Prediction with a specific model:

raw_images = sa.search_images(
  project = "Cityscapes", 
  annotation_status = "NotStarted")

succeeded, failed = sa.run_prediction(
  project = "Cityscapes", 
  images_list = raw_images,
  model = "Cityscapes Segmentation Model")

This function logs the progress bar which shows the number of images that were predicted successfully.

Deployment

To download the trained model and its metadata:

sa.download_model(
  model = "Cityscapes Segmentation Model", 
  output_dir = "./models")

The downloaded model directory contains trained model weights and a configuration file on the model architecture.

📘

Model deployment tutorials

Check out our GitHub repository for model deployment tutorials on edge devices like Jetson Nano and OAK-D.


Did this page help you?