What is YOLO?
You Only Look Once (YOLO) is a state-of-the-art, real-time object detection algorithm .
What makes YOLO popular?
Speed
Detection accuracy
Good generalization
Open-source
Google Colab is an excellent platform for running deep learning models due to its free access to GPUs and ease of use. This guide will walk you through the process of running the latest version, YOLOv10, on Google Colab.
Before You Start
To make sure that you have access to GPU. You can use nvidia-smi command to do that. In case of any problems navigate to Edit -> Notebook settings -> Hardware accelerator, set it to GPU, and then click Save.
Install Required Packages
Clone the GitHub repository.
Upload Data To Colab
Step 1: Mount Google Drive
drive.mount(‘/content/drive’)
Step 2: Upload Files Directly
uploaded = files.upload()
Step 3: Organize Data for YOLOv10
Images:
The images directory contains subdirectories for train and val (validation) sets.
Each subdirectory contains the corresponding images for training and validation.
Labels:
The labels directory mirrors the images directory structure.
Each text file in the labels/train and labels/val subdirectories contains the annotations for the corresponding images.
Annotations Format:
/images
/train
image1.jpg
image2.jpg
…
/val
image1.jpg
image2.jpg
…
/labels
/train
image1.txt
image2.txt
…
/val
image1.txt
image2.txt
…
data.yaml
Data Configuration File (data.yaml):
val: /content/my_dataset/images/val
nc: N # N for number of classes
names: [‘class1’, ‘class2’, …, ‘classN’]
Download Pre-trained Weights
import urllib.request
# Create a directory for the weights in the current working directory
weights_dir = os.path.join(os.getcwd(), “weights”)
os.makedirs(weights_dir, exist_ok=True)
# URLs of the weight files
urls = [
“https://github.com/jameslahm/yolov10/releases/download/v1.0/yolov10n.pt”,
“https://github.com/jameslahm/yolov10/releases/download/v1.0/yolov10s.pt”,
“https://github.com/jameslahm/yolov10/releases/download/v1.0/yolov10m.pt”,
“https://github.com/jameslahm/yolov10/releases/download/v1.0/yolov10b.pt”,
“https://github.com/jameslahm/yolov10/releases/download/v1.0/yolov10x.pt”,
“https://github.com/jameslahm/yolov10/releases/download/v1.0/yolov10l.pt”
]
# Download each file
for url in urls:
file_name = os.path.join(weights_dir, os.path.basename(url))
urllib.request.urlretrieve(url, file_name)
print(f”Downloaded {file_name}”)
Train Custom Model
Inference on Image
Inference on Video
Summary
This guide covers running YOLOv10 on Google Colab by setting up the environment, installing necessary libraries, and running inference with pre-trained weights. It also explains how to upload and organize data in Colab for YOLOv8, including the required directory structure and configuration files. These steps enable efficient training and inference for object detection models using Colab’s resources.