Ultralytics (YOLO) Skill
Expert system for Ultralytics YOLO models (Object Detection, Segmentation, Classification).
When to Use This Skill
This skill should be triggered when:
- •Training YOLO models (v8, v9, v10, v11)
- •Running inference (detection, segmentation, pose estimation)
- •Exporting models to ONNX, TensorRT, CoreML, etc.
- •Configuring datasets (COCO, custom YAML)
- •Configuring datasets (COCO, custom YAML)
- •Debugging training pipelines or performance issues
- •Training Config Requests: "Set batch size to 128", "Train on CPU", "Use optimizer SGD"
Logic Flow & Decision Tree
0. Configuration Gatekeeper (The OOM Stopper)
When: User proposes specific training parameters (Batch Size, Device, Image Size). Action:
- •PAUSE. Perform a "Mental Simulation" of resource usage.
- •Calculate (Heuristic):
- •
YOLOv8x+Batch 128≈ 40GB+ VRAM Needed. - •
CPU Training+Large Model= Extremely Slow (Days).
- •
- •BLOCK/WARN:
"Training YOLOv8x with Batch 128 requires ~40GB VRAM (A100 class). Your environment (Laptop GPU/CPU) will crash (OOM). Recommendation: Batch 4 or 8."
Pre-Flight Checks (Mandatory)
Before starting any training run, you MUST:
- •
Check GPU Resources (CUDA/ROCm):
- •Verify device availability:
torch.cuda.is_available() - •Check VRAM capacity:
nvidia-smiortorch.cuda.get_device_properties(0).total_memory - •Auto-Batch Suggestion:
- •< 6GB VRAM:
batch=4orbatch=8 - •6GB - 12GB VRAM:
batch=16 - •
12GB VRAM:
batch=32+ - •Tip: Use
batch=-1for YOLOv8's auto-batch feature if unsure.
- •< 6GB VRAM:
- •Verify device availability:
- •
Verify Data Leakage:
- •Ensure NO overlap between Train and Val image files.
Quick Reference
Common Patterns
Pattern 1: Train Model (CLI)
yolo detect train data=coco128.yaml model=yolov8n.pt epochs=100 imgsz=640
Pattern 2: Predict (CLI)
yolo detect predict model=yolov8n.pt source='https://ultralytics.com/images/bus.jpg'
Pattern 3: Export Model
yolo export model=yolov8n.pt format=onnx
Pattern 4: Train (Python)
from ultralytics import YOLO
model = YOLO("yolov8n.pt")
results = model.train(data="coco8.yaml", epochs=100, imgsz=640)
Pattern 5: Predict (Python)
from ultralytics import YOLO
model = YOLO("yolov8n.pt")
results = model("path/to/image.jpg")
Pattern 6: Segmentation Training
model = YOLO("yolov8n-seg.pt")
model.train(data="coco8-seg.yaml", epochs=100)
Reference Files
This skill includes comprehensive documentation in references/:
- •guides.md - Step-by-step guides for common tasks.
- •models.md - Details on available model architectures.
- •datasets.md - How to format and use datasets.
- •tasks.md - Explanation of tasks (Detect, Segment, Classify, Pose, OBB).
- •modes.md - Modes of operation (Train, Val, Predict, Export, Track).
- •detect.md - Specifics for object detection.
Use view_file to read these files for in-depth information.
usage
For Beginners
Start with references/tasks.md to understand the capabilities (Detect, Segment, etc.) and references/modes.md for the workflow (Train -> Val -> Predict).
For Custom Training
Refer to references/datasets.md to ensure your data YAML and directory structure are correct before starting training.
For Deployment
Check references/guides.md (or export documentation) for details on optimizing models for different hardware using yolo export.