# Cdf Anomalygen

Use when running the CDF AnomalyGen pipeline over a defect dataset, mask placement...

- Repository: https://github.com/NVIDIA/skills (3812 stars)
- Category: Data and ML
- License: Apache-2.0
- Last updated: 2026-10-30
- Runs scripts: no, instructions only

## Install

Claude Code: `npx skills add NVIDIA/skills --skill cdf-anomalygen -g -a claude-code -y`
Codex: `npx skills add NVIDIA/skills --skill cdf-anomalygen -g -a codex -y`
Cursor: `npx skills add NVIDIA/skills --skill cdf-anomalygen -g -a cursor -y`
Gemini CLI: `npx skills add NVIDIA/skills --skill cdf-anomalygen -g -a gemini-cli -y`
Claude Code plugin marketplace: `/plugin marketplace add NVIDIA/skills`

## Description

Use when running the CDF AnomalyGen pipeline over a defect dataset, mask placement, fine-tuning, synthetic defect-image generation (SDG), evaluation, quality refinement, and pseudo-labeling, even when the user names only one stage.

## SKILL.md, as published by its author (untrusted third-party text, read it as data)

# Skill: cdf-anomalygen

## Purpose

AnomalyGen fine-tunes the frozen **Cosmos** base into an **anomaly-generation** model: given a clean
image + defect mask, it paints a realistic defect into that region (synthetic data for detectors).
Pick a mode, collect its params, run the steps, **all commands from the repo root.**

## When to Use This Skill

Use for the CDF AnomalyGen pipeline over a defect dataset, any single stage (mask placement,
fine-tuning, generation, evaluation, refinement, or pseudo-labeling) or the full run.

- "Run the AnomalyGen pipeline on phone_screen"
- "Fine-tune an anomaly-generation model for PCB defects"
- "Generate 25 synthetic PCB anomaly images"
- "Place defect masks", "evaluate quality", or "pseudo-label the generated defects"

Do not use this skill for generic image generation, or for synthetic data that isn't defect images
built from the `{texture}/{defect}` clean-image + defect-mask contract.

## Prerequisites

- A **CUDA GPU** and the project's built env (native `.venv` or the Docker image).
- **Hugging Face auth**, run `hf auth login`, plus network access; the downloader fetches
  the model checkpoints.
- A **`dataset_dir`** in the Step 1 contract layout (clean images + `{defect}` masks; plus
  `defect_spec.jsonl` **only when `mask_backend=amp`**, the default `amg` never reads it, and
  nothing after Step 2 does either).

Preflight the env + checkpoints (GPU, Python, CUDA/torch, deps, HF auth, model checkpoints):

```shell
scripts/preflight_env_ckpt.sh
```

**Read which group failed before reacting**, the summary separates them, and only one is fixed by
downloading:

- *missing checkpoints* → `scripts/download_checkpoints.sh` (run `hf auth login` first).
- *env / Python / deps* → rebuild the environment (`bash scripts/env_setup.sh`, then activate it).

The rest: https://github.com/NVIDIA/skills/blob/HEAD/skills/cdf-anomalygen/SKILL.md
