nvidia-tao/tao-skill-bank/tao-generate-anomalies
Claude Code and agent skill by nvidia-tao/tao-skill-bank
- community
Checking that the SKILL.md file is still in the repository.
Full PAIDF AnomalyGen pipeline — fine-tune on a new anomaly dataset, generate synthetic anomaly images (SDG), evaluate quality (nn_score), and search per-sample (guidance, crop_ratio) parameters. Three modes: full (Phase 0→7: finetune then generate), finetune_only (Phase 0→1: train only), inference_only (Phase 0, 2→7: generate from an existing checkpoint). Use when the user asks to "fine-tune AnomalyGen", "generate anomaly images", "run PAIDF SDG", "evaluate SDG output quality", "run per-sample search", or run any part of the AnomalyGen pipeline, even if they only mention one phase.
Install
npx vskill@latest install nvidia-tao/tao-skill-bank/tao-generate-anomaliesSKILL.md
TAO Generate Anomalies
Standalone install? If this session was not initialized by the TAO skill bank plugin, run thetao-setupskill first (host preflight, credentials, cross-skill discovery).
Multi-phase pipeline (0–7); the mode flag selects which phases run.
| Phase | What runs | Mode(s) | |
|---|---|---|---|
| 0 | Verify / download pretrained checkpoints | all | |
| 1 | Fine-tune on dataset_dir | full, finetune_only | |
| 2 | Prepare inference JSONL (AMP routing) | full, inference_only | |
| 3 | SDG — generate synthetic anomaly images → original/ | full, inference_only | |
| 4 | Eval original/ — emit per_sample.csv + eval.log, merge nn_score into SDG_result.csv | full, inference_only | |
| 5 | Per-sample (guidance, crop_ratio) search rounds → rounds/round_NN/ (each round runs SDG + eval) | full, inference_only | |
| 6 | Assemble best-of-rounds into searched/ (stitch only), plus rounds/search_summary.csv | full, inference_only | |
| 7 | Filter searched/ by nn_threshold (default 0.4), regen dropped samples, then canonical bucket eval → searched/{per_sample.csv, eval.log} | full, inference_only |
Run every phase through to completion without mid-run pauses. Collect all required parameters up front, and run every command from the repo root.
Shell setup. All ${ANOMALYGEN_SCRIPTS} references resolve to the packaged helper-script directory. Inside the container this is preset (ENV ANOMALYGEN_SCRIPTS=<dir>/scripts/utilities); on the host, export it once per shell:
python3 -m scripts.utilities.<name> invocations work from any CWD inside the container (PYTHONPATH is preset) and from the repo root on the host. When inside a product container (ANOMALYGEN_PRODUCT_MODE=1), invoke anomalygen-guard before any GPU work; if it reports BLOCKED, fix the listed issues before continuing.
Quick Start
The pipeline runs inside the metropolis_sdg.paidf_anomalygen container (declared in versions.yaml) or any host with the cosmos-predict2 conda env active. All phase commands assume that environment, at the repo root, with ANOMALYGEN_SCRIPTS exported.
Minimal end-to-end run (mode=full):
For mode=inference_only (reuse a checkpoint) also set CKPT/STEP and skip Phase 1. For mode=finetune_only run only Phases 0–1.
Running in Docker — container launch, mounts & permissions
The paidf-anomalygen image runs as a non-root baked-in user (USER anomalygen, uid=10000), independent of your host uid. Docker does not remap uids on bind mounts, so a host directory owned by your uid is not writable by uid 10000 and the container fails the instant it tries to create a file there. Run with the full host identity: --user "$(id -u):$(id -g)", matching USER/LOGNAME, HOME=/tmp, and read-only /etc/passwd+/etc/group mounts, plus the cache redirects. Run the fail-fast write preflight before Phase 0. See references/docker.md for the full docker run command, the load-bearing-flag table, the preflight snippet, and the uid-10000 chown/chmod fallback.
Reference files — read before executing phases
Read `references/finetune.md` before Phase 0/1 and `references/inference.md` before any of Phases 2–7; for mode=full read both before starting. The remaining references below are on-demand — read when troubleshooting or needing full detail for a specific phase.
| File | Read when | |
|---|---|---|
references/finetune.md | Before Phase 0/1: env check, checkpoint download, dataset validation, config generation, training commands, best-checkpoint selection | |
references/finetune-commands.md | Exact Phase 1 Step 1–4 commands and CKPT/STEP derivation | |
references/inference-commands.md | Exact Phase 5 run_round.sh and Phase 7 filter_with_regen commands | |
references/inference.md | Before Phases 2–7: AMP routing, JSONL validation, SDG flags, eval interpretation, search loop, filtering | |
references/setup.md | Checkpoint download fails; first-time setup; HF_TOKEN / disk issues | |
references/datasets.md | User needs to prepare or obtain a UC1 / UC2 / UC3 dataset; dataset_dir doesn't exist yet | |
references/prep-testcase.md | AMP fails; need full param table, helper script descriptions, allocation invariant | |
references/sdg-inference.md | NCCL hang; checkpoint validation error; multi-GPU VRAM question; full step list | |
references/eval.md | Unexpected scores; FID column order confusion; eval output format reference | |
references/sdg-refine.md | draws.json alignment; re-AMP heuristics; search output layout | |
references/guard-and-custom-counts.md | Full guard preflight command; --per-defect-counts example | |
references/docker.md | Container launch command, mount-permission flags, write preflight, uid-10000 fallback | |
references/output-layout.md | Full results/<name>/ directory tree with per-file annotations; post-run Verification checklist | |
references/error-handling.md | Pipeline-level failure modes: missing mask dirs, short/empty AMP, mid-round resume, off-boundary step |
Required parameters
num_SDG allocation depends on prep_testcase.sh --mode: inference (default, Phase 2) is uniform across defect types, override per-defect via --per-defect-counts; validation (Phase 1's validation JSONL) is proportional to training mask counts (largest-remainder rounding) and enforces ≥1 per defect. See references/prep-testcase.md for the full mode table.
| Parameter | Description | |
|---|---|---|
mode | full (Phase 0→7), inference_only (skip Phase 1), or finetune_only (Phase 0→1 only). | |
name | Experiment label. | |
dataset_dir | Training/reference dataset root. Drives mask-count allocation, AMP submask templates, and holds semantic_segmentation_labels.json for cad defects. | |
defect_spec | JSONL tagging each defect spatial_dependency as free/text/cad. text entries need roi_prompt_defect_location. Template: assets/defect_spec_template.jsonl. | |
num_SDG | Total output samples per bucket. (Ignored when `mode=finetune_only`.) |
Conditionally required
| Parameter | Required when | Description | |
|---|---|---|---|
checkpoint_dir / step | mode=inference_only | Pre-existing fine-tuned model. In mode=full these are auto-derived after Phase 1; passing them is an error. In mode=finetune_only silently ignored — Phase 1 always trains from scratch (no resume-from-checkpoint support). Both must be present together — supplying only one is an error. |
Optional parameters
| Parameter | Default | Description | |
|---|---|---|---|
clean_dir | dataset_dir | Clean images. Set only when they live outside the training dataset. Forwarded as --clean-dir to prep-testcase and --clean-image-path to finetune. | |
validation_jsonl | auto-generated | Pre-built validation JSONL for Phase 1. When supplied, preflight verifies every defect_spec type appears and paths exist. | |
num_search_run | 3 | Per-sample search budget for Phase 5. 0 skips search (only original/). (Ignored when `mode=finetune_only`.) | |
nn_threshold | 0.4 | nn_score cutoff for Phase 7 (DINOv2 correspondence to real defects — key KPI). Samples below are regenerated; final searched/ always has num_SDG. 0 disables filtering. | |
max_iter | 75000 | Phase 1 only. Total fine-tune iterations. | |
save_iter | 5000 | Phase 1 only. Checkpoint save interval. | |
validation_iter | 5000 | Phase 1 only. Validation (nn_score) logging interval. | |
num_gpus | 1 | Forwarded to Phase 1 (finetune) and Phase 3 (SDG). Eval and search rounds stay single-GPU. | |
model_size | 2b | 2b or 14b. Used by finetune and SDG. On-disk checkpoint path encodes in upper-case (2b→2B, 14b→14B). | |
lr | 0.02 | Phase 1 only. Learning rate. | |
batch_size | 2 | Phase 1 only. Per-GPU batch size. | |
image_size | 512 | Phase 1 only. Training resolution (square). | |
guidance_range | 1.5 10.0 | Phase 5 search draw range for guidance. | |
crop_ratio_range | 1.5 10.0 | Phase 5 search draw range for crop_ratio. |
Mode validation (fail fast before any phase)
modeunset → halt: "`mode` is required (`full` | `inference_only` | `finetune_only`)."mode=inference_onlymissing eithercheckpoint_dirorstep→ halt: "inference_only requires both `checkpoint_dir` and `step`."mode=fullwithcheckpoint_dirorstepsupplied → halt: "full mode runs finetune; use `mode=inference_only` to reuse an existing checkpoint."
Shared variables
Set once before Phase 0:
Guard preflight (product mode only)
When ANOMALYGEN_PRODUCT_MODE=1, run .agents/skills/anomalygen-guard/scripts/preflight.py before any GPU work and fix any BLOCKED issues. --validation-jsonl is forwarded only when the user supplied one; for MODE=finetune_only omit --num-sdg if not supplied. See references/guard-and-custom-counts.md for the full preflight command with all forwarded flags and the validation-JSONL / allocate_samples.py 0-entry checks.
Phase 0 — checkpoints
Read references/finetune.md §Phase 0 for HF_TOKEN requirements and what gets downloaded. Both scripts default to the 2B base + t5-large (~40 GB); pass --model-sizes ${MODEL_SIZE^^} so the chain checks and fetches the base size this run actually uses (2b→2B, 14b→14B) — otherwise a 14b run silently passes the 2B-only check and never downloads its checkpoint. Verify first; download only what is missing.
Phase 1 — fine-tune (skip when MODE=inference_only)
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 90 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingskills/data/tao-generate-anomalies/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/nvidia-tao/tao-skill-bank/tao-generate-anomalies)