YOLOv8 Object Detection Tutorial
Build a real-time object detection system using YOLOv8 and deploy it to edge devices with Cliff.
Overview
YOLOv8 is a state-of-the-art object detection model that can identify and locate objects in images and video streams. In this tutorial, we'll deploy YOLOv8 to an edge device for real-time inference.
Prerequisites
- Python 3.8+
- Basic knowledge of Python
- A Cliff account and registered device
- Camera or video source (optional)
Step 1: Prepare Your Model
Option A: Use Pre-trained Model
Download a pre-trained YOLOv8 model:
from ultralytics import YOLO
# Load a pre-trained model
model = YOLO('yolov8n.pt') # nano version (fastest)
# or
model = YOLO('yolov8s.pt') # small version
# or
model = YOLO('yolov8m.pt') # medium versionOption B: Train Your Own
Train on custom data:
from ultralytics import YOLO
model = YOLO('yolov8n.pt')
results = model.train(data='path/to/dataset.yaml', epochs=100)Step 2: Export to ONNX
Convert your model to ONNX format for deployment:
from ultralytics import YOLO
model = YOLO('yolov8n.pt')
model.export(format='onnx', simplify=True)This creates a yolov8n.onnx file ready for deployment.
Step 3: Upload to Cliff
- Go to the Models page in your dashboard
- Click Upload Model
- Select your
yolov8n.onnxfile - Set framework to "ONNX"
- Add metadata and upload
Step 4: Deploy to Edge Device
- Select your YOLOv8 model
- Click Deploy
- Choose your edge device
- Configure deployment:
- Set input size (e.g., 640x640)
- Configure confidence threshold
- Enable GPU if available
- Deploy
Step 5: Test Your Deployment
Once deployed, you can test with:
- Image files
- Video streams
- Camera feeds
- Real-time inference API
Performance Optimization
Model Quantization
Reduce model size and improve speed:
from ultralytics import YOLO
model = YOLO('yolov8n.pt')
model.export(format='onnx', simplify=True, int8=True)Input Size
Smaller input sizes = faster inference:
- 320x320: Fastest, lower accuracy
- 640x640: Balanced (recommended)
- 1280x1280: Slower, higher accuracy
Use Cases
- Security monitoring
- Traffic analysis
- Quality control
- Inventory management
- Wildlife monitoring
Next Steps
- Experiment with different YOLOv8 variants
- Fine-tune on your specific use case
- Set up continuous monitoring
- Integrate with your application
