Skip to content

YOLOv8 - Classification

YOLOv8 is a popular computer vision model developed by Ultralytics. The classification variant is designed for image classification tasks, assigning a single class label to an entire image.

Overview

YOLOv8 for classification provides fast and accurate image classification. Key features include:

  • Anchor-free architecture - Simplified design optimized for classification
  • Fast inference - Real-time classification performance
  • Efficient backbone - Optimized for speed and accuracy
  • Multiple model sizes - From nano to extra-large variants
  • Easy deployment - Well-supported across multiple platforms

License

AGPL-3.0

Commercial Licensing

  • AGPL-3.0: Free for open-source projects. Requires derivative works to be open-sourced.
  • Paid Roboflow customers: Automatically get access to use any YOLOv8 models trained on or uploaded to the Roboflow platform for commercial use.
  • Free Roboflow customers: Can use YOLOv8 via the serverless hosted API, or commercially self-hosted with a paid plan.

Learn more: Roboflow Licensing | YOLOv8 License Details

Pre-trained Model IDs

YOLOv8 classification models must be trained on Roboflow or uploaded as custom weights. There are no pre-trained public model IDs available.

Custom model ID format: project-url/version (e.g., my-project-abc123/2)

Supported Backends

Backend Extras Required
onnx onnx-cpu, onnx-cu12, onnx-cu118, onnx-jp6-cu126
torch-script torch-cpu, torch-cu118, torch-cu124, torch-cu126, torch-cu128, torch-jp6-cu126
trt trt10

Roboflow Platform Compatibility

Feature Supported
Training ✅ Train custom models on Roboflow
Upload Weights ✅ Upload pre-trained weights (guide)
Serverless API (v2) Deploy via hosted API
Workflows ✅ Use in Workflows via Classification block
Edge Deployment (Jetson) ✅ Deploy on NVIDIA Jetson devices
Self-Hosting ✅ Deploy with inference-models

Installation

Install with one of the following extras depending on your backend:

  • ONNX: onnx-cpu, onnx-cu12
  • TensorRT: trt10 (requires CUDA 12.x)
  • TorchScript: torch-cpu, torch-cu118, torch-cu124, torch-cu126, torch-cu128, torch-jp6-cu126

Usage Example

import cv2
from inference_models import AutoModel

# Load your custom model (requires Roboflow API key)
model = AutoModel.from_pretrained(
    "my-project-abc123/2",
    api_key="your_roboflow_api_key"
)
image = cv2.imread("path/to/image.jpg")

# Run inference
prediction = model(image)

# Get top prediction
top_class_id = prediction.class_id[0].item()
top_class = model.class_names[top_class_id]
confidence = prediction.confidence[0][top_class_id].item()

print(f"Class: {top_class}")
print(f"Confidence: {confidence:.2f}")