For the complete documentation index, see llms.txt. This page is also available as Markdown.

Train model on the cloud

Reminder: All code and scripts for this project are executed in the cloud. Open the Google Colab Notebook and select Runtime > Run all to execute the setup.

Deep learning networks excel at automatically extracting features from large datasets, making them highly effective for tasks like object detection and image segmentation. To apply deep learning to your specific use case, you first need to understand how to train a model using known data.

Training models in the cloud

Use this workflow to train a YOLOv8 model in Ultralytics, export it to TFLite, optimize it with Vela, and download the final file.

1

Create an Ultralytics account

Open the Ultralytics platform and create an account.

2

Create a new project

Open Example project.

Select New model.

Change the model to yolov8n. On the right side there will be a dataset called COCO8, which is used for object detection to detect people, things, animals, etc.

In the same window, switch to Local Training at the bottom.

3

Open Google Colab

In Google Drive, go to New → More → Google Colaboratory.

4

Install Ultralytics and set your API key

Paste this into the first cell and run it.

import os

# Install ultralytics to get the 'yolo' command 
!pip install ultralytics

# Set your API key for this notebook session 
os.environ['ULTRALYTICS_API_KEY'] = '(YOUR_API_KEY)'
5

Start training

Paste this into a new cell.

If the original command uses export, replace it with os.environ[...].

Also add ! before yolo.

import os

# Install ultralytics to get the 'yolo' command 
!pip install ultralytics

# Set the API key using os.environ for persistence within the Python process 
os.environ['ULTRALYTICS_API_KEY'] = '(YOUR_API_KEY)' 

!yolo train \ 
  model="ul://ultralytics/yolov8/yolov8n" \ 
  data="ul://ultralytics/datasets/coco8" \ 
  task="detect" \ 
  epochs=100 \ 
  batch=-1 \ 
  imgsz=640 \ 
  project="(your-name)/example-project"

For faster training, change the Colab runtime to T4 GPU.

After you verify the command, run the cell and wait for training to finish.

6

Export the best model to TFLite

Run this cell after training completes.

Replace (your-name) with your Ultralytics username.

from ultralytics import YOLO

# Load the best trained model 
model = YOLO('runs/detect/(your-name)/example-project/train/weights/best.pt')

# Export the model to TFLite format with int8 quantization 
model.export( 
    format='tflite', 
    imgsz=192, 
    int8=True 
) 

print("Model exported to TFLite (int8) successfully!") 
print("The exported model should be in the 'runs/detect/train/weights' directory.")
7

Install Vela

Run this cell to install Arm Vela.

!pip3 install ethos-u-vela
8

Create the Vela config

Paste this into a new cell and run it.

%%writefile vela_config.ini 
; file: my_vela_cfg.ini ; 
; Vela configuration file ; 
; System Configuration 

; My_Sys_Cfg 
[System_Config.My_Sys_Cfg] 
core_clock=400e6 
axi0_port=Sram 
axi1_port=OffChipFlash 
Sram_clock_scale=1.0 
Sram_burst_length=32 
Sram_read_latency=16 
Sram_write_latency=16 
Dram_clock_scale=0.75 
Dram_burst_length=128 
Dram_read_latency=500 
Dram_write_latency=250 
OnChipFlash_clock_scale=0.25 
OffChipFlash_clock_scale=0.015625 
OffChipFlash_burst_length=32 
OffChipFlash_read_latency=64 
OffChipFlash_write_latency=64 
; ----------------------------------------------------------------------------- 
; Memory Mode 
; My_Mem_Mode_Parent 
[Memory_Mode.My_Mem_Mode_Parent] 
const_mem_area=Axi1 
arena_mem_area=Axi0 
cache_mem_area=Axi0
9

Optimize the TFLite model with Vela

Run this command in a new cell.

Replace (your-name) with your Ultralytics username.

!vela --accelerator-config ethos-u55-64 --config vela_config.ini --system-config My_Sys_Cfg --memory-mode My_Mem_Mode_Parent --output-dir /content /content/runs/detect/(your-name)/example-project/train/weights/best_int8.tflite
10

Download the final model

Run this cell to download the optimized model.

from google.colab import files 

files.download('/content/best_int8_vela.tflite')

Result

After you complete the workflow, you should have an exported and Vela-optimized model ready to download and deploy.

Your final output should be best_int8_vela.tflite.

Examples:

Example exported model output in Colab.

Example optimized model file ready for download.

Last updated