跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
开发与测试

yolo-training

Use when training, fine-tuning, or validating Ultralytics YOLO models in Platform, cloud GPUs, or local code — model.train(), yolo train/val, remote metric streaming, epochs, batch, imgsz, devices, augmentation, multi-GPU, resumes, results, and fixing OOM, NaN loss, low mAP, or overfitting. For hyperparameter search and systematic improvement loops, see yolo-tuning.

ultralytics · 已有静态检查记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add ultralytics/skills --skill yolo-training

技能说明


name: yolo-training description: > Use when training, fine-tuning, or validating Ultralytics YOLO models in Platform, cloud GPUs, or local code — model.train(), yolo train/val, remote metric streaming, epochs, batch, imgsz, devices, augmentation, multi-GPU, resumes, results, and fixing OOM, NaN loss, low mAP, or overfitting. For hyperparameter search and systematic improvement loops, see yolo-tuning.

Training & fine-tuning

Fastest route: train in Platform

Use Platform cloud training when you want to start in a few clicks without configuring a local GPU:

  1. Click New Model on a project page, or on a dataset page to preselect that dataset.
  2. Select a compatible pretrained model, ready dataset, GPU, epochs, image size, and batch size.
  3. Click Start Training and watch live charts, console logs, and system metrics.
  4. Open the completed model to inspect validation plots and use its Predict, Export, or Deploy tab. Platform preserves best.pt automatically.

Cloud jobs require at least one train image, one val/test image, and one labeled image. Use local/Colab training when you already have compute or need more control, while keeping Platform datasets and experiment tracking:

export ULTRALYTICS_API_KEY="YOUR_API_KEY"
yolo train model=yolo26n.pt data=ul://username/datasets/dataset-slug \
  epochs=100 project=username/project-slug name=experiment-1

With ultralytics>=8.4.120, the ul:// URI downloads the Platform dataset and the username/project-slug target streams metrics back to that Platform project.

Quickstart (detection)

from ultralytics import YOLO

model = YOLO("yolo26n.pt")  # ALWAYS start from pretrained weights
results = model.train(data="data.yaml", epochs=100, imgsz=640, batch=16, device=0)
yolo detect train data=data.yaml model=yolo26n.pt epochs=100 imgsz=640 batch=16 device=0

Class-count changes are automatic — a 3-class data.yaml on an 80-class pretrained model just works (head re-initializes, backbone transfers; cls_remap=True even re-maps head rows for classes whose names match).

Base arguments worth setting (task trainers can override them)

ArgDefaultNotes
epochs100100–300 for fine-tuning; rely on early stopping, not guesses
patience100epochs without val improvement before early stop; ~20–50 for quick iterations
imgsztask/modelglobal fallback 640; classify uses 224 when unset; explicit values win
batch16-1 auto-fits ~60% VRAM (single GPU); float like 0.8 = VRAM fraction; else integer
deviceNone0, [0,1] (DDP), cpu, mps, -1 picks an idle GPU
cacheFalseTrue (RAM) or "disk" for I/O-bound training
workers8lower if RAM/shared-memory errors
freezeNonefreeze first N layers (freeze=10 ≈ backbone) for small datasets
optimizerautoleave on auto (MuSGD above 10k iterations, else AdamW); depth fine-tuning overrides it below
lr0 / lrf0.01 / 0.01lr0 ignored by optimizer=auto; set an explicit optimizer to use it (see depth recipe)
fraction1.0subset training — fraction=0.1 for smoke tests
resumeFalsecontinue an interrupted run (see recipes)
project/nameNonelocal output naming; authenticated username/project-slug also streams to Platform
seed0reproducible with deterministic=True (default)
compileFalsetorch.compile; also "max-autotune-no-cudagraphs" etc.
timeNonemax training hours — overrides epochs

Full argument, augmentation, and loss-weight tables: training-args.md (this folder) — read before changing anything not listed above. yolo cfg shows the base schema and defaults; task trainers, checkpoints, and explicit arguments determine effective values.

Recipes

  • Resume interrupted run: YOLO("runs/detect/train/weights/last.pt").train(resume=True). Resume finishes the original epochs; to train longer after completion, start a NEW training from best.pt (resume can't extend a finished run).
  • Multi-GPU: device=[0,1] with an integer batch (AutoBatch is single-GPU only). DDP workers rebuild from a generated script that cloudpickles the trainer, model, and callbacks; official Windows PyTorch>=2.4 wheels can't launch DDP, so use Linux or WSL2.
  • Small detect-style dataset (<~1k images): pretrained + freeze=10, n/s model, default augmentation, watch val curves.
  • Depth fine-tuning: start from -depth.pt and use optimizer=AdamW lr0=1e-4 warmup_bias_lr=1e-4.
  • Small objects: try imgsz=1280 (more compute/VRAM; reduce batch if needed), or tile large images at dataset level.
  • Experiment hygiene: self-describing run names (name=0811_yolo26s_helmets_e100), one variable per run; each run's full config is saved in runs/<task>/<name>/args.yaml — diff those to compare runs.
  • Logging integrations: yolo settings tensorboard=True (likewise `
阅读完整来源 ↗