Ultralytics YOLO Vision Tools
Ultralytics YOLO is a state-of-the-art computer vision framework supporting multiple tasks including object detection, instance segmentation, image classification, pose estimation, and oriented bounding box detection. This skill provides comprehensive guidance for using YOLO effectively.
Latest Model: YOLO26 (released January 2026) features end-to-end NMS-free inference and optimized edge deployment. For stable production workloads, both YOLO26 and YOLO11 are recommended.
Quick Start
1. Installation & Environment Check
CODEBLOCK0
The yolo checks command validates Python version, PyTorch, CUDA, GPU availability, and all dependencies. For detailed environment troubleshooting, see Environment Check or use the provided environment check script: python scripts/check_environment.py.
2. Basic Usage Examples
Python Interface
CODEBLOCK1
CLI Interface
CODEBLOCK2
3. Model Selection
For quick start, use these default models:
- - Detection:
yolo26n.pt (nano), yolo26s.pt (small), yolo26m.pt (medium) - Segmentation:
yolo26n-seg.pt, yolo26s-seg.pt, INLINECODE7 - Classification:
yolo26n-cls.pt, yolo26s-cls.pt, INLINECODE10 - Pose Estimation:
yolo26n-pose.pt, yolo26s-pose.pt, INLINECODE13 - Oriented Detection:
yolo26n-obb.pt, yolo26s-obb.pt, INLINECODE16
For complete model list and selection guidance: Model Names | Model Selection
Core Workflow
Step 1: Understand YOLO Tasks
YOLO supports five main computer vision tasks. Choose the right task for your application:
- - Detection: Identify and localize objects with bounding boxes
- Segmentation: Generate pixel-level masks for objects
- Classification: Categorize entire images
- Pose Estimation: Detect keypoints for pose analysis
- Oriented Detection: Detect rotated objects with angle parameter
Detailed comparison: Task Types
Step 2: Select Appropriate Model
Consider these factors when selecting a model:
- - Speed vs. Accuracy: Nano (fastest) → X (most accurate)
- Hardware Constraints: GPU memory, CPU performance
- Application Requirements: Real-time vs. batch processing
Guidance: Model Selection
Step 3: Configure Parameters
Common configuration parameters:
- -
conf: Confidence threshold (default: 0.25) - INLINECODE18 : IoU threshold for NMS (default: 0.7)
- INLINECODE19 : Input image size (default: 640)
- INLINECODE20 : Device ID (
0 for first GPU, cpu for CPU) - INLINECODE23 : Save results to disk
- INLINECODE24 : Display results in real-time
Complete examples: Configuration Samples
Step 4: Process Results
YOLO returns
Results objects containing:
- -
boxes: Bounding boxes, confidence scores, class labels - INLINECODE27 : Segmentation masks (for segmentation tasks)
- INLINECODE28 : Pose keypoints (for pose estimation)
- INLINECODE29 : Classification probabilities (for classification)
- INLINECODE30 : Oriented bounding boxes (for OBB tasks)
Advanced Topics
Training Custom Models
CODEBLOCK3
Training guide: Training Basics | Dataset Preparation
Installation Options
Multiple installation methods available:
- - pip: INLINECODE31
- Conda: INLINECODE32
- Docker: Pre-built images for GPU/CPU environments
- From Source: For development and customization
Detailed instructions: Installation Guide
Performance Optimization
- - Streaming Mode: Use
stream=True for videos/long sequences to reduce memory - Batch Processing: Process multiple images together for efficiency
- Hardware Acceleration: Configure CUDA, TensorRT, or OpenVINO for optimal performance
Reference Documentation
All installation methods (pip, Conda, Docker, source) |
|
Task Types | Detailed comparison of YOLO tasks and use cases |
|
Model Names | Complete YOLO26 model list with specifications |
|
Model Selection | Strategy for choosing models based on requirements |
|
Configuration Samples | Parameter configuration examples for various scenarios |
|
Dataset Preparation | Guide for preparing custom datasets for training |
|
Training Basics | Fundamentals of training YOLO models on custom data |
|
Parameter Reference | Complete reference for all YOLO configuration parameters |
Utility Scripts
To save token usage and provide ready-to-use tools, the following Python scripts are available in the scripts/ directory:
| Script | Description | Usage Example |
|---|
| checkenvironment.py | Comprehensive environment diagnostics | INLINECODE35 |
| configtemplates.py |
Ready-to-use configuration templates |
from scripts.config_templates import get_production_config |
|
dataset_tools.py | Dataset preparation and conversion tools |
from scripts.dataset_tools import coco_to_yolo |
|
training_helpers.py | Training, evaluation, and model management |
from scripts.training_helpers import evaluate_model |
|
quick_tests.py | Quick functionality tests |
python scripts/quick_tests.py --test environment |
|
model_utils.py | Model selection and validation utilities |
from scripts.model_utils import select_model |
Benefits of using scripts:
- - Save tokens: Large code blocks are extracted from documentation
- Ready-to-use: No need to copy-paste code from documentation
- Modular: Import only what you need
- Maintainable: Scripts can be updated independently
Troubleshooting
Common Issues
Q: yolo command not found after installation?
A: Try python -m ultralytics yolo or check Python environment PATH.
Q: How to use specific GPU?
A: Set device=0 (first GPU) or device=cpu for CPU-only mode.
Q: Model downloads slowly?
A: Set ULTRALYTICS_HOME environment variable to control cache location.
Q: How to filter specific classes?
A: Use classes parameter: classes=[0, 2, 5] (class indices).
Q: Memory issues with long videos?
A: Use stream=True to process videos as generators.
Q: Real-time webcam support?
A: Yes, use source=0 (default camera) with show=True for live display.
Getting Help
- - Run
yolo checks to diagnose environment issues - Check official documentation: https://docs.ultralytics.com
- Review configuration reference: https://docs.ultralytics.com/usage/cfg/
Output Directory Convention
Default Output Location
When processing images or videos with YOLO, if the user does not specify an output directory, all generated files will be saved to the workspace's
yolo-vision folder.
File Organization
The
yolo-vision folder will be organized as follows:
CODEBLOCK4
Automatic Folder Creation
The skill will automatically:
- 1. Create the
yolo-vision folder if it doesn't exist - Create all subdirectories as needed
- Organize files by date and task type
- Generate timestamp-based filenames for easy tracking
Example Usage
CODEBLOCK5
Benefits
- 1. Consistency: All YOLO outputs in one predictable location
- Organization: Files automatically categorized by type
- Backup: Input files are preserved for reference
- Reproducibility: Easy to find and compare previous analyses
- Clean Workspace: Prevents clutter in the main workspace directory
User Override
Users can still specify custom output directories when needed:
- - By providing a
save_dir parameter in Python code - By using the
--project flag in CLI commands - By setting the
ULTRALYTICS_PROJECT environment variable
License Note: Ultralytics YOLO is available under AGPL-3.0 for open source use and Enterprise License for commercial applications. Review licensing at https://ultralytics.com/license.
Ultralytics YOLO 视觉工具
Ultralytics YOLO 是一个最先进的计算机视觉框架,支持多种任务,包括目标检测、实例分割、图像分类、姿态估计和定向边界框检测。本技能为有效使用YOLO提供全面指导。
最新模型:YOLO26(2026年1月发布)具有端到端无NMS推理和优化的边缘部署特性。对于稳定的生产工作负载,推荐使用YOLO26和YOLO11。
快速开始
1. 安装与环境检查
bash
安装/更新Ultralytics
pip install -U ultralytics
验证安装并检查环境
yolo checks
yolo checks命令会验证Python版本、PyTorch、CUDA、GPU可用性以及所有依赖项。有关详细的环境故障排除,请参阅环境检查或使用提供的环境检查脚本:python scripts/check_environment.py。
2. 基本使用示例
Python接口
python
from ultralytics import YOLO
加载模型(YOLO会自动从模型推断任务)
model = YOLO(yolo26n.pt) # 或您的自定义模型路径
对各种来源进行预测
默认情况下,输出保存到workspace/yolo-vision文件夹
results = model(image.jpg) # 图像文件 → 保存到yolo-vision/outputs/images/
results = model(video.mp4, stream=True) # 视频流式处理 → 保存到yolo-vision/outputs/videos/
results = model(https://example.com/image.jpg) # URL → 保存到yolo-vision/outputs/images/
results = model(0, show=True) # 摄像头实时显示 → 保存到yolo-vision/outputs/videos/
自定义输出目录(可选)
results = model(image.jpg, project=/custom/path) # 保存到自定义目录
CLI接口
bash
基本语法:yolo TASK MODE ARGS
默认情况下,输出保存到workspace/yolo-vision文件夹
yolo predict model=yolo26n.pt source=image.jpg # → 保存到yolo-vision/runs/detect/predict/
任务特定示例
yolo detect predict model=yolo26n.pt source=video.mp4 # → 保存到yolo-vision/runs/detect/predict/
yolo segment predict model=yolo26n-seg.pt source=image.jpg # → 保存到yolo-vision/runs/segment/predict/
yolo pose predict model=yolo26n-pose.pt source=image.jpg # → 保存到yolo-vision/runs/pose/predict/
自定义输出目录(可选)
yolo predict model=yolo26n.pt source=image.jpg project=/custom/path # 保存到自定义目录
3. 模型选择
快速开始请使用以下默认模型:
- - 检测:yolo26n.pt(超小)、yolo26s.pt(小)、yolo26m.pt(中)
- 分割:yolo26n-seg.pt、yolo26s-seg.pt、yolo26m-seg.pt
- 分类:yolo26n-cls.pt、yolo26s-cls.pt、yolo26m-cls.pt
- 姿态估计:yolo26n-pose.pt、yolo26s-pose.pt、yolo26m-pose.pt
- 定向检测:yolo26n-obb.pt、yolo26s-obb.pt、yolo26m-obb.pt
完整模型列表和选择指南:模型名称 | 模型选择
核心工作流程
步骤1:了解YOLO任务
YOLO支持五种主要的计算机视觉任务。为您的应用选择正确的任务:
- - 检测:使用边界框识别和定位物体
- 分割:为物体生成像素级掩码
- 分类:对整张图像进行分类
- 姿态估计:检测关键点进行姿态分析
- 定向检测:检测带有角度参数的旋转物体
详细比较:任务类型
步骤2:选择合适的模型
选择模型时考虑以下因素:
- - 速度与精度:超小(最快)→ X(最准确)
- 硬件限制:GPU内存、CPU性能
- 应用需求:实时处理 vs. 批量处理
指南:模型选择
步骤3:配置参数
常见配置参数:
- - conf:置信度阈值(默认:0.25)
- iou:NMS的IoU阈值(默认:0.7)
- imgsz:输入图像尺寸(默认:640)
- device:设备ID(0表示第一个GPU,cpu表示CPU)
- save:将结果保存到磁盘
- show:实时显示结果
完整示例:配置样本
步骤4:处理结果
YOLO返回包含以下内容的Results对象:
- - boxes:边界框、置信度分数、类别标签
- masks:分割掩码(用于分割任务)
- keypoints:姿态关键点(用于姿态估计)
- probs:分类概率(用于分类)
- obb:定向边界框(用于OBB任务)
高级主题
训练自定义模型
python
from ultralytics import YOLO
加载模型
model = YOLO(yolo26n.pt)
在自定义数据集上训练
results = model.train(data=dataset.yaml, epochs=100, imgsz=640)
训练指南:训练基础 | 数据集准备
安装选项
提供多种安装方法:
- - pip:pip install -U ultralytics
- Conda:conda install -c conda-forge ultralytics
- Docker:适用于GPU/CPU环境的预构建镜像
- 源码安装:用于开发和自定义
详细说明:安装指南
性能优化
- - 流式模式:对视频/长序列使用stream=True以减少内存占用
- 批量处理:同时处理多张图像以提高效率
- 硬件加速:配置CUDA、TensorRT或OpenVINO以获得最佳性能
参考文档
所有安装方法(pip、Conda、Docker、源码) |
|
任务类型 | YOLO任务和用例的详细比较 |
|
模型名称 | 完整的YOLO26模型列表及规格 |
|
模型选择 | 根据需求选择模型的策略 |
|
配置样本 | 各种场景的参数配置示例 |
|
数据集准备 | 准备自定义数据集进行训练的指南 |
|
训练基础 | 在自定义数据上训练YOLO模型的基础知识 |
|
参数参考 | 所有YOLO配置参数的完整参考 |
实用脚本
为节省令牌使用并提供即用工具,scripts/目录中提供以下Python脚本:
| 脚本 | 描述 | 使用示例 |
|---|
| checkenvironment.py | 全面的环境诊断 | python scripts/checkenvironment.py |
| configtemplates.py |
即用型配置模板 | from scripts.configtemplates import get
productionconfig |
|
datasettools.py | 数据集准备和转换工具 | from scripts.datasettools import coco
toyolo |
|
traininghelpers.py | 训练、评估和模型管理 | from scripts.traininghelpers import evaluate_model |
|
quicktests.py | 快速功能测试 | python scripts/quicktests.py --test environment |
|
modelutils.py | 模型选择和验证工具 | from scripts.modelutils import select_model |
使用脚本的好处:
- - 节省令牌:大型代码块从文档中提取
- 即用型:无需从文档复制粘贴代码
- 模块化:只导入所需内容
- 可维护:脚本可以独立更新
故障排除
常见问题
问:安装后找不到y