YOLO-Master Agent Skill
Use This Skill
Use this skill for any repository task that should drive the YOLO-Master stack end-to-end:
train,val,predict,track,export,benchmark,tune- model inspection and task detection
- LoRA save/load/merge and
yolo.lora.diagnose - PEFT comparison via
yolo.eval.peft_compare - Sparse SAHI comparison via
yolo.eval.sparse_sahi_compare - MoE diagnose/prune
- multimodal visual inference with OpenAI VLM/LLM cooperation
- multimodal batch evaluation over a dataset or image folder
solutionsworkflows- launchers for Gradio / Streamlit
- end-to-end orchestration via
yolo.pipeline.experiment
Execution Rule
First make sure the local Ultralytics framework is installed and the yolo CLI is available. Prefer the CLI over raw Python API for supported commands, and use the bundled dispatcher when you want a deterministic, structured run:
python -m pip install -e .
yolo version
python agent/scripts/run_yolo_master_skill.py --json '{"skill":"yolo.train","inputs":{"model":"yolo11n.pt","data":"coco8.yaml"},"params":{"epochs":1,"imgsz":32}}'
On Apple Silicon hosts with PyTorch MPS support, the dispatcher now defaults heavy compute modes such as train, val, benchmark, predict, and track to device=mps when no explicit device is provided. Override with runtime.device or params.device if needed.
If the CLI run is auto-selected onto MPS/CUDA and fails for a device-level runtime reason, the dispatcher will retry once on CPU and return a structured recovery record with the full attempt trail.
When you need fast coverage across many skills or requests, use the AutoTrain-style validator first:
python agent/scripts/validate_yolo_master_skill.py --suite quick --pretty --summary-only
quick is the default agent loop. It combines fast-smoke, dry-run, and contract so agents can iterate without waiting on real model inspection or CLI cold-start probes. Use all only when you explicitly want the slower full non-manual regression pass.
The case pack now lives in assets/autotrain_cases/ as skill-grouped JSON files. It includes multimodal dry-run/contract probes plus dry-run coverage for yolo.pipeline.experiment, yolo.lora.diagnose, and yolo.eval.peft_compare.
For quick regression checks, prefer the tiered suites:
python agent/scripts/validate_yolo_master_skill.py --suite quick --pretty --summary-only
python agent/scripts/validate_yolo_master_skill.py --suite fast-smoke --pretty --summary-only
python agent/scripts/validate_yolo_master_skill.py --suite cli-smoke --pretty --summary-only
python agent/scripts/validate_yolo_master_skill.py --suite deep-smoke --pretty --summary-only
python agent/scripts/validate_yolo_master_skill.py --suite extended --pretty --summary-only
python agent/scripts/validate_yolo_master_skill.py --suite dry-run --pretty --summary-only
python agent/scripts/validate_yolo_master_skill.py --suite contract --pretty --summary-only
python agent/scripts/validate_yolo_master_skill.py --suite all --pretty --summary-only
Workflow
- Inspect the request and normalize paths.
- Install/refresh the local Ultralytics package first when the
yoloCLI is missing. - Prefer
policy.dry_run=truewhile validating or evolving the skill surface. - On Apple Silicon, let the dispatcher pick
mpsby default for train/val/eval unless the request already setsdevice. - Let the dispatcher auto-complete safe runtime defaults such as
workers=0on macOS train/val paths when the request leaves them unset. - Use
yoloCLI for supported tasks; fall back to Python API only when the CLI does not cover the action. - For
predictandtrack, acceptsourcein eitherinputs.sourceorparams.source; the dispatcher will normalize it before CLI emission. - Pass all task-specific options through
paramsunchanged. - Return structured artifacts, metrics, evaluation summaries, environment reports, and next actions.
- For long jobs, set
policy.async=trueon train/tune/pipeline requests to submit a subprocess job and returnjob_id, status, stdout/stderr, manifest, and progress paths.
Multimodal Inference
yolo.multimodal.infer is an optional enhancement layer for visual reasoning. It does not replace yolo.predict: it runs YOLO first, condenses detections into reasoning evidence, then calls the OpenAI Responses API with input_text plus input_image, and optionally runs a second LLM refinement pass.
Environment variables:
OPENAI_API_KEYOPENAI_BASE_URLoptionalOPENAI_API_MODEoptional,auto,responses, orchat.completionsOPENAI_VLM_MODELoptionalOPENAI_LLM_MODELoptionalstructured_output=trueasks the VLM/LLM to return a strict JSON verdict that can be parsed intoverdictprompt_template=vlm_coco_multitaskasks the VLM to output caption, global classification, COCO-style object proposals, rough segmentation proxies, YOLO cross-checks, and fusion hintsprompt_template=vlm_open_world_detectionasks the VLM to preserve open-world objects, optional COCO mappings, rough segmentation proxies, captioning, and fusion hints for novel categoriesprompt_template=vlm_open_world_detection_compactis the compact open-world schema tuned for providers that tend to truncate long JSON, especiallyqwen-vl-plusprompt_template=vlm_open_world_detect_classify_compactfocuses on a few grounded object proposals plus scene-level classesprompt_template=vlm_open_world_caption_misses_compactfocuses on scene captioning plus the most important likely missesmax_output_tokensdefaults to3500in COCO multitask template mode; avoid lowering it below this unless you also reduce schema fieldsuse_marked_image=truedraws numbered YOLO boxes onto a lightweight marked copy before VLM inspectionvisual_search_mode=autolets the VLM request crop-and-zoom follow-ups throughvisual_search.needs_zoomandsearch_regionsfusion_mode=previewconverts parsed VLM/LLM hints into metric-safe keep/suppress/add/relabel/adjust proposals plus COCO-style prediction records; usefusion_mode=offto disable itfusion_policy=add_onlyis now the default. It only allows filtered high-confidence VLM additions that look like genuine misses; usebalancedoraggressiveonly when you explicitly want VLM-driven suppress/adjust/relabel actionsfusion_policy=open_world_assistis the opt-in exploratory path. It keeps the normal metric preview for COCO-mappable outputs, but also preserves unmapped open-world objects inmultimodal.fusion.open_world_predictions_preview- open-world normalization now tries to anchor novel labels against the bundled
LVIS 1203andV3Det 13204taxonomies, and batch reports exposetaxonomy.best,taxonomy.candidates, dataset hit counts, and unmatched totals - taxonomy matching is now intentionally conservative by default:
open_world_taxonomy_min_score=40open_world_taxonomy_require_exact_for_generic=trueThis prevents weak generic matches such asgrass -> bear grassfrom being treated as confirmed taxonomy anchors unless you explicitly loosen the policy
- open-world report aggregation now separates:
enhancement_stats: labels allowed to enter open-world enhancement statisticsreasoning_only: labels preserved for agent reasoning but filtered from aggregate enhancement stats Default filters are:open_world_filter_unmatched_taxonomy=trueopen_world_filter_generic_labels=true
open_world_assist_profilegives the agent a higher-level mode switch for open-world runs without forcing you to set every threshold by hand:strictdefault for evaluation-oriented runs: stronger taxonomy gate, generic labels filtered, unmatched labels kept as reasoning-onlybalanced: keeps generic filtering, but allows unmatched taxonomy labels to remain in enhancement statsexploratory: lowest taxonomy gate, generic/unmatched labels stay in enhancement stats for broad discovery passes Explicit param values still win over the profile defaults
- core implementation now lives in
runtime/;scripts/contains only thin executable wrappers that delegate intoruntime/cli/ - opt-in hooks now exist for:
- IoU-based open-world relabeling via
open_world_iou_relabel_enabled - WordNet hypernym fallback when taxonomy matching misses
- cross-profile verified-list merging for prompt ensemble style arbitration
- IoU-based open-world relabeling via
- When
vlm_modellooks likeqwen-vl-*andprompt_template=vlm_open_world_detection, the dispatcher now auto-switches to a compact task profile unless you explicitly request a different template path:- default:
vlm_open_world_detect_classify_compact - caption/miss emphasis:
vlm_open_world_caption_misses_compact - override with
compact_open_world_profile=detect_classify|caption_misses
- default:
Behavior:
thinking_with_image=trueattaches the image to the VLM requestenable_llm_refine=trueorOPENAI_LLM_MODELenables the refinement pass- missing
OPENAI_API_KEYreturns a structuredblockedresult - Provider-aware defaults can be externalized under
runtime/multimodal/providers/*.yaml; built-in configs currently includeopenaianddashscope. - DashScope/OpenAI-compatible chat endpoints can use
params.provider="dashscope"plusDASHSCOPE_API_KEY, or setOPENAI_BASE_URL=https://dashscope.aliyuncs.com/compatible-mode/v1withparams.openai_api_mode="chat.completions". - the manifest now preserves the
multimodalblock, including parsed verdicts, visual-search crop passes, fusion preview, and artifact paths when available - every response envelope includes
usage.tokensandcost_estimate; cost isnullwhen provider pricing is not configured.
Example:
python agent/scripts/run_yolo_master_skill.py --json '{"skill":"yolo.multimodal.infer","inputs":{"model":"yolo11n.pt","source":"ultralytics/assets/bus.jpg","prompt":"What matters most in this image?"},"params":{"thinking_with_image":true,"vlm_model":"gpt-4.1-mini","llm_model":"gpt-4.1-mini","max_reasoning_items":3,"max_reasoning_boxes":20},"policy":{"dry_run":true}}' --pretty
COCO multitask VLM prompt:
python agent/scripts/run_yolo_master_skill.py --json '{"skill":"yolo.multimodal.infer","inputs":{"model":"yolo11n.pt","source":"ultralytics/assets/bus.jpg","prompt":"Detect, classify, segment roughly, caption, and propose metric-safe fusion changes."},"params":{"thinking_with_image":true,"structured_output":true,"prompt_template":"vlm_coco_multitask","use_marked_image":true,"visual_search_mode":"auto","fusion_mode":"preview","vlm_model":"qwen-vl-plus","llm_model":"qwen-plus","openai_api_mode":"chat.completions"}}' --pretty
Open-world VLM prompt:
python agent/scripts/run_yolo_master_skill.py --json '{"skill":"yolo.multimodal.infer","inputs":{"model":"yolo11n.pt","source":"ultralytics/assets/bus.jpg","prompt":"Find visible objects, including novel categories outside COCO, and preserve them for downstream reasoning."},"params":{"thinking_with_image":true,"structured_output":true,"prompt_template":"vlm_open_world_detection","use_marked_image":true,"visual_search_mode":"auto","fusion_mode":"preview","fusion_policy":"open_world_assist","vlm_model":"qwen-vl-plus","llm_model":"qwen-plus","openai_api_mode":"chat.completions"}}' --pretty
Multimodal Batch Evaluation
Use yolo.multimodal.evaluate when the agent needs to evaluate a real image sample or dataset split with YOLO first, then VLM/LLM cross-checks.
inputs.dataselects a dataset YAML such ascoco128.yaml;params.splitdefaults tovalinputs.sourcemay point to a local image folder, image file, or image-list text fileparams.limit,offset,stride,shuffle, andseedcontrol sampling;limit=0means all resolved imagesparams.run_yolo_val=truealso runs a YOLO-only validation baseline wheninputs.datais available- Ground-truth labels are read for reporting when available; they are not added to the VLM prompt unless
include_ground_truth_in_prompt=true params.prompt_template="vlm_coco_multitask"enables VLM-side detection/classification/rough segmentation/caption output for downstream fusion experimentsparams.prompt_template="vlm_open_world_detection"enables a less conservative open-world path where novel categories are preserved even when they cannot be mapped into COCO metricsparams.use_marked_image=trueandparams.visual_search_mode=autoenable Set-of-Mark-style box grounding and crop/zoom follow-up callsparams.fusion_mode="preview"writes conservative fused prediction previews and, for batch evaluation, afusion-preview-coco-predictions.jsonartifact for downstream COCO scoring- Fusion is policy- and confidence-guarded by default:
add_onlyblocks suppress/relabel/adjust, and even in broader policies high-confidence YOLO boxes are protected while box adjustments must stay close to the original box - In
open_world_assist, unmapped novel objects are emitted toopen_world_predictions_previewinstead of being dropped; only COCO-mappable predictions participate in metric preview and guardrail selection open_world_assistnow defaults to an add-first posture: it prefers preserving novel objects and no longer enables suppress/adjust/relabel by default- When YOLO-format labels are available,
evaluation.metric_previewcompares YOLO-only vs fused predictions on the sampled images and writesfusion-metric-preview.json; treat it as a fast same-sample guardrail, not an official benchmark metric_guardrailwritesmetric-guarded-coco-predictions.json: it keeps fused predictions only when there is a material change and same-samplemap50_95shows a positive delta without recall regression; otherwise it falls back to YOLO-only predictions
Example:
python agent/scripts/run_yolo_master_skill.py --json '{"skill":"yolo.multimodal.evaluate","runtime":{"prefer_cli":true,"prefer_mps":true},"inputs":{"model":"yolo11n.pt","data":"coco128.yaml","prompt":"Cross-check detector outputs and summarize obvious false positives, misses, duplicates, and uncertainty."},"params":{"limit":5,"split":"val","imgsz":640,"batch":1,"thinking_with_image":true,"prompt_template":"vlm_coco_multitask","use_marked_image":true,"visual_search_mode":"auto","fusion_mode":"preview","vlm_model":"qwen-vl-plus","llm_model":"qwen-plus","openai_base_url":"https://dashscope.aliyuncs.com/compatible-mode/v1","openai_api_mode":"chat.completions"},"policy":{"dry_run":false}}' --pretty
AutoTrain Loop
Use the bundled validator and case pack to keep this skill honest:
- case pack:
assets/autotrain_cases/grouped by skill, withassets/autotrain_cases.jsonretained for compatibility - report:
logs/autotrain-report.json - bootstrap:
python -m pip install -e . - dispatcher supports
policy.dry_run=truefor cheap coverage before real runs yoloCLI is the preferred execution surface for supported actionsquickis the default iteration suite:fast-smoke+dry-run+contract- the validator enables a short-lived runtime cache for Torch/MPS detection so repeated subprocess cases do not re-import the stack
fast-smokeprotects bootstrap and planning paths with tight timing budgetscli-smokevalidates realyoloCLI cold-start executiondeep-smokeholds heavyweight real-model inspection and local.ptinference checksallruns every non-manual case, including slowercli-smokeanddeep-smokeextended-clicarries slower real CLI validation probes such as mini-datasetyolo trainandyolo valonmps, and is markedmanual_onlycontractverifies failure-path behavior and manifest emissioncontractnow also includes in-process recovery probes so auto device fallback semantics stay covered without adding test-only hooks to the dispatchercontractincludes single-image and batch multimodal stub probes so OpenAI-compatible request shaping, structured verdict parsing, and aggregation stay covered- CLI failures now carry categorized hints so the agent can recover instead of stopping at a raw traceback.
- Built-in dataset YAML names such as
coco128.yamlare auto-resolved against the local repository before execution. doctorreturns environment, device selection source, and agent-facing recommendations.- CLI train/val/predict/benchmark/export responses now carry environment metadata, and auto-selected runs can include a recovery trail when a device fallback occurs.
Pipeline And PEFT Tools
Use yolo.pipeline.experiment for end-to-end train/val/export/benchmark flows. It accepts either stage keys such as train, val, export, benchmark, or an explicit params.stages list, and can include inspect, lora_diagnose, moe_diagnose, and peft_compare. Real runs write progress.jsonl next to the manifest for file-tail progress monitoring.
For packaged MoE, MoA, MoT, and Latent MoE configurations, inputs.profile accepts the stable identifier printed by
yolo mixtures. Do not also pass inputs.model; profile resolution supplies the exact YAML path and task:
python agent/scripts/run_yolo_master_skill.py --json '{"skill":"yolo.pipeline.experiment","inputs":{"profile":"26/yolo26-master-mot-n","data":"coco8.yaml"},"params":{"train":{"epochs":1,"imgsz":32},"val":{"imgsz":32},"export":{"format":"onnx"}},"policy":{"dry_run":true}}' --pretty
Every skill_manifest.json is schema-versioned and preserves the redacted normalized request plus handler-specific
results such as pipeline stages, selected checkpoints, diagnostics, and plans. Profile-driven manifests also record the
catalog metadata and model YAML SHA-256. API keys, access tokens, passwords, secrets, authorization values, and common
inline credential assignments are written as <redacted>; raw stdout/stderr tails are bounded.
Use yolo.release.audit to build a read-only release bundle from a completed Agent manifest:
python agent/scripts/run_yolo_master_skill.py --json '{"skill":"yolo.release.audit","inputs":{"manifest":"runs/agent/experiment/skill_manifest.json"},"params":{"output":"runs/agent/experiment/release_bundle.json"},"policy":{"dry_run":false}}' --pretty
The audit verifies the source manifest checksum, resolves only explicit artifact references, records SHA-256 and size
for each evidence file, joins model identity with governance/export YAML, and returns publishable, experimental, or
refused. It never copies checkpoints or constructs a model. Inspect decision.missing for incomplete evidence and
decision.hard_failures for integrity, path-safety, source-stage, schema, or identity failures.
Legacy manifests without schema_version are classified as compatibility.kind=legacy_unversioned and always remain
refused until a new versioned manifest is emitted. The compatibility path consumes only explicit
environment.references.model.resolved, job.save_dir, and artifacts[*].path values; it never scans a run directory.
For a local or manual-CI threshold gate, use:
python scripts/audit_release_manifest.py runs/agent/experiment/skill_manifest.json \
--output runs/agent/experiment/release_bundle.json --fail-on experimental
--fail-on refused returns success for experimental audits; --fail-on experimental returns non-zero for both
experimental and refused.
Use yolo.lora.diagnose to inspect active or loaded adapters:
python agent/scripts/run_yolo_master_skill.py --json '{"skill":"yolo.lora.diagnose","inputs":{"model":"yolo11n.pt"},"params":{"path":"runs/train/exp/weights/lora_adapter_best","svd_max_layers":20,"spectrum_max_layers":12},"policy":{"dry_run":true}}' --pretty
Use yolo.eval.peft_compare to compare Full-SFT and PEFT variants with the same base train/val settings:
python agent/scripts/run_yolo_master_skill.py --json '{"skill":"yolo.eval.peft_compare","inputs":{"model":"yolo11n.pt","data":"coco8.yaml"},"params":{"train":{"epochs":1,"imgsz":32,"batch":1},"variants":[{"name":"full_sft","train":{"lora_r":0}},{"name":"lora_r8","train":{"lora_type":"lora","lora_r":8,"lora_alpha":16}}]},"policy":{"dry_run":true}}' --pretty
Manual Probes
Use these when you want stronger confidence than the default smoke suites without pulling slow jobs into routine validation.
Environment doctor and adaptive install probe:
python agent/scripts/run_yolo_master_skill.py --json '{"skill":"yolo.system","action":"doctor","params":{"ensure_cli":true}}' --pretty
Real CLI training and validation probes on the bundled mini dataset:
python agent/scripts/validate_yolo_master_skill.py --suite extended --pretty --summary-only
Equivalent direct CLI train command:
yolo train model=scripts/peft_validation/yolo11n.pt data=agent/assets/mini-detect/mini_detect.yaml imgsz=64 epochs=1 batch=1 device=mps workers=0 plots=False verbose=False patience=1 project=runs/agent name=train-mini-mps-manual
Equivalent direct CLI val command:
yolo val model=scripts/peft_validation/yolo11n.pt data=agent/assets/mini-detect/mini_detect.yaml imgsz=16 batch=1 device=mps workers=0 plots=False verbose=False project=runs/agent name=val-mini-mps-manual
Structured dispatcher example with automatic MPS selection:
python agent/scripts/run_yolo_master_skill.py --json '{"skill":"yolo.train","runtime":{"prefer_cli":true,"prefer_mps":true},"inputs":{"model":"scripts/peft_validation/yolo11n.pt","data":"agent/assets/mini-detect/mini_detect.yaml"},"params":{"epochs":1,"imgsz":64,"batch":1,"workers":0,"plots":false,"verbose":false,"patience":1},"artifacts":{},"policy":{"dry_run":false}}' --pretty
Regenerate the taxonomy-enriched small-batch open-world report from an existing real-run log:
python agent/scripts/regenerate_open_world_report.py \
--input agent/logs/qwen-open-world-small-batch.json \
--json-out agent/logs/qwen-open-world-small-batch-report.json \
--md-out agent/logs/qwen-open-world-small-batch-report.md
References
- Read
README.mdfor the concise directory map and maintenance boundaries. - Read
references/skill-architecture.mdfor the full architecture map, skill registry, request/response contract, and execution logic. - Read
references/thinking-with-image.mdwhen improving VLM visual reasoning, marked-image prompting, crop/zoom search, or COCO metric fusion. - Read the open-world taxonomy assets in
assets/open-world-taxonomyfor reusable class references, includingLVIS 1203andV3Det 13204category lists plus source metadata.
Guardrails
- Do not hardcode new CLI strings when a Python API exists.
- Keep
paramsas the pass-through layer for new Ultralytics arguments. - Prefer
yoloCLI for supported commands; use Python API only as fallback. - On Apple Silicon, prefer
mpsfor training and validation unless the request explicitly overrides the device. - Consume
evaluationin addition tometricswhen judging train/val runs. - Use
yolo.system doctorbefore long runs when the agent needs to confirm install state, selected device, and local repo activation. - Prefer the
recoveryfield over raw stderr when a run auto-falls back from MPS/CUDA to CPU. - Keep slow real training out of default validator suites; use the manual probe path instead.
- Treat UI launchers and research scripts as launcher-style skills, not plain sync functions.