[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M78D38W1HDK0K5HC28VDBAX3":3,"skill-same:01M78D38W1HDK0K5HC28VDBAX3":109},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":33,"commitSha":34,"skillDirectory":35,"forksCount":14,"repositoryHtmlUrl":36,"repositoryHomepageUrl":37,"ownerHtmlUrl":38,"ownerBlogUrl":39,"ownerDescription":40,"updatedAt":41,"install":42,"resources":55},"01M78D38W1HDK0K5HC28VDBAX3","nv-generate-vae-finetune",null,"Used for finetuning the NV-Generate-CTMR MAISI VAE from CT\u002FMRI NIfTI datalists. Not for clinical or production data approval.","Solizardking\u002Fskillhub-main","Solizardking","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F108096810?v=4","01M786KDB10AYV042N0F9BD5B5","Clawd","01M786NYYXSZK1D05WM8JQPC48",0,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: nv-generate-vae-finetune\ndescription: Used for finetuning the NV-Generate-CTMR MAISI VAE from CT\u002FMRI NIfTI datalists. Not for clinical or production data approval.\nlicense: Apache-2.0\nallowed-tools: Bash\nmetadata:\n  author: NVIDIA MedTech Team\n  tags:\n    - MedTech\n    - CT\n    - MRI\n    - VAE\n    - finetune\n---\n\n# NV-Generate-VAE-Finetune\n\n## Purpose\n- Used for finetuning the NV-Generate-CTMR MAISI VAE\u002Fautoencoder from user-supplied CT or MRI NIfTI training volumes.\n- Not for clinical interpretation, regulatory use, or approving synthetic data for production training.\n- Upstream currently documents VAE training in `train_vae_tutorial.ipynb` and provides configs\u002Fhelpers, but not a `scripts.train_vae` CLI. This skill does not execute the notebook; it stages the required config\u002Fdatalist glue locally and uses upstream helper APIs.\n- Manifest I\u002FO: inputs are `datalist` and `data_base_dir`; outputs are `autoencoder_checkpoint`, `discriminator_checkpoint`, and `result_json`.\n- The underlying training contract is the upstream config\u002Fenv JSON (`config_maisi_vae_train.json` + `environment_maisi_vae_train.json`, as used in `train_vae_tutorial.ipynb`). The wrapper stages those JSON files for you and exposes the most-tuned fields as CLI flags; the sections below document the fields, their defaults, and how to monitor\u002Ftune a run.\n\n## Instructions\n- Read `skill_manifest.yaml` before changing arguments, side effects, or validation gates.\n- Run `scripts\u002Frun_vae_finetune.py` from the Medical AI Skills repo root.\n- If a host agent exposes `run_script`, use `run_script(\"scripts\u002Frun_vae_finetune.py\", args=[...])`; otherwise run the Bash\u002FPython command below.\n- Use `--preflight` first when checking a new datalist; remove `--preflight` only when the user explicitly wants to launch GPU finetuning.\n- For a staged preflight input bundle directory, use `BUNDLE\u002Fpreflight_datalist.json` as the datalist and `BUNDLE\u002Fpreflight_dataset` as `--data-base-dir` when those files are present.\n\n## Examples\n\nValidate and stage a preflight finetune check from an input bundle (the recommended first step — no GPU, no training). This is the single canonical command; replace `INPUT_BUNDLE` and `OUT_DIR` with your paths:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7}\" && \\\npython skills\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py \\\n  INPUT_BUNDLE\u002Fpreflight_datalist.json \\\n  --data-base-dir INPUT_BUNDLE\u002Fpreflight_dataset \\\n  --output-dir OUT_DIR \\\n  --modality mri \\\n  --preflight\n```\n\nFor real GPU finetuning and other variations, see [Usage](#2-usage-one-line-training) below.\n\n## Available Scripts\n| Script | Purpose | Arguments |\n|---|---|---|\n| `scripts\u002Frun_vae_finetune.py` | Primary entrypoint declared by `skill_manifest.yaml`. | `DATALIST.json --data-base-dir DATA_DIR --output-dir OUT_DIR [--epochs N] [--modality mri] [--patch-size 64,64,64] [--preflight]` |\n\n## Prerequisites\n- An explicit `NV_GENERATE_ROOT` may point to the caller's local checkout and\n  must contain `configs\u002Fconfig_maisi_vae_train.json`, `scripts\u002Ftransforms.py`,\n  and `scripts\u002Futils.py`. The result records its current commit.\n- If `NV_GENERATE_ROOT` is unset, the wrapper searches `.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR`.\n- `CUDA_VISIBLE_DEVICES` is optional and can be used to select the GPU for real training.\n- Runtime requirements: NVIDIA CUDA GPU for real training, Python packages from the upstream `requirements.txt`, `lpips`, and downloaded VAE weights unless using `--train-from-scratch`.\n- Side effects: writes staged configs, checkpoints, TensorBoard logs, and run summaries under the caller-provided `--output-dir`; may write model caches under the upstream checkout, `~\u002F.cache\u002Fhuggingface\u002F`, and `~\u002F.cache\u002Ftorch\u002F`; may contact `https:\u002F\u002Fhuggingface.co`, `https:\u002F\u002Fgithub.com`, and `https:\u002F\u002Fdownload.pytorch.org`.\n- The datalist is a MONAI-style JSON object with non-empty `training[]` and `validation[]` or `testing[]`. Each entry has an `image` path relative to `--data-base-dir` and optional `class` or `modality` of `ct` or `mri`.\n\nWhen no local checkout is supplied, create the recommended pinned default\ncheckout once:\n\n```bash\nif [ -z \"${NV_GENERATE_ROOT:-}\" ]; then\n  export NV_GENERATE_COMMIT=61c4ec709b84cad468852243c48e250bec732074\n  export NV_GENERATE_ROOT=\"$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7\"\n  if [ ! -d \"$NV_GENERATE_ROOT\u002F.git\" ]; then\n    git clone https:\u002F\u002Fgithub.com\u002FNVIDIA-Medtech\u002FNV-Generate-CTMR.git \"$NV_GENERATE_ROOT\"\n    git -C \"$NV_GENERATE_ROOT\" checkout --detach \"$NV_GENERATE_COMMIT\"\n  fi\nfi\n```\n\n## 1. Config and environment JSON (adapt to your data)\n\nThe wrapper copies the upstream VAE config\u002Fenv JSON from `$NV_GENERATE_ROOT\u002Fconfigs`, rewrites the fields below, and writes the staged copies under `OUT_DIR\u002Fworkflow\u002Fconfigs\u002F`. You normally only set your datalist and data root; the listed CLI flags override individual fields when you need to.\n\nEnvironment JSON (`environment_maisi_vae_train.json`):\n\n| Field | Set from | Notes |\n|---|---|---|\n| `model_dir` | `--output-dir` | Where `autoencoder.pt`\u002F`discriminator.pt` and best checkpoints are saved. |\n| `tfevent_path` | `--output-dir` | TensorBoard event directory. |\n| `finetune` | `--train-from-scratch` | `true` (default) loads `trained_autoencoder_path`; the flag sets it `false`. |\n| `trained_autoencoder_path` | upstream weights \u002F `--trained-autoencoder-path` | Starting VAE checkpoint when finetuning. |\n\nTraining fields (`config_maisi_vae_train.json`):\n\n| Field | Flag | Type | Default | Notes |\n|---|---|---|---|---|\n| `autoencoder_train.n_epochs` | `--epochs` | int | `1` | |\n| `autoencoder_train.batch_size` | `--batch-size` | int | `1` | Per-GPU (single-GPU runner). |\n| `autoencoder_train.patch_size` | `--patch-size` | int,int,int | `64,64,64` | Training crop. |\n| `autoencoder_train.val_batch_size` | `--val-batch-size` | int | `1` | |\n| `autoencoder_train.val_sliding_window_patch_size` | `--val-sliding-window-patch-size` | int,int,int | `96,96,64` | Sliding-window validation ROI. |\n| `autoencoder_train.lr` | `--lr` | float | `1e-4` | |\n| `autoencoder_train.perceptual_weight` | `--perceptual-weight` | float | `0.3` | LPIPS term. |\n| `autoencoder_train.kl_weight` | `--kl-weight` | float | `1e-7` | KL term. |\n| `autoencoder_train.adv_weight` | `--adv-weight` | float | `0.1` | Adversarial term. |\n| `autoencoder_train.recon_loss` | `--recon-loss` | `l1`\\|`l2` | `l1` | |\n| `autoencoder_train.val_interval` | `--val-interval` | int | `1` | Epochs between validation passes. |\n| `autoencoder_train.cache` | `--cache-rate` | float | `0.0` | MONAI `CacheDataset` fraction. |\n| `autoencoder_train.amp` | `--no-amp` | flag | on | Mixed precision; flag disables it. |\n| `data_option.random_aug` | `--no-random-aug` | flag | on | Random augmentation; flag disables it. |\n| `data_option.spacing_type` | `--spacing-type` | `original`\\|`fixed`\\|`rand_zoom` | `original` | |\n| `data_option.spacing` | `--spacing` | float,float,float | unset | Required when `spacing_type` is `fixed`\u002F`rand_zoom`. |\n| `data_option.select_channel` | `--select-channel` | int | `0` | Channel for multi-channel inputs. |\n\n`--modality` (`ct` or `mri`, default `mri`) fills the per-entry `class` for datalist items missing one. Validation\u002Ftesting entries are required because the training loop runs a validation pass.\n\nFor an end-to-end reference including example data download, see the upstream tutorial `train_vae_tutorial.ipynb`.\n\n## 2. Usage (one-line training)\n\nPreflight only:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7}\" && \\\npython skills\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py \\\n  PATH_TO_DATALIST.json \\\n  --data-base-dir PATH_TO_DATA_ROOT \\\n  --output-dir runs\u002Fnv_generate_vae_finetune_preflight \\\n  --preflight\n```\n\nPreflight bundle input:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7}\" && \\\npython skills\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py \\\n  PATH_TO_INPUT_BUNDLE\u002Fpreflight_datalist.json \\\n  --data-base-dir PATH_TO_INPUT_BUNDLE\u002Fpreflight_dataset \\\n  --output-dir runs\u002Fnv_generate_vae_finetune_preflight \\\n  --preflight\n```\n\nGPU finetuning:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7}\" && \\\npython -m pip install -r \"$NV_GENERATE_ROOT\u002Frequirements.txt\" && \\\npython -m pip install lpips tensorboard && \\\npython skills\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py \\\n  PATH_TO_DATALIST.json \\\n  --data-base-dir PATH_TO_DATA_ROOT \\\n  --output-dir runs\u002Fnv_generate_vae_finetune \\\n  --epochs 1 \\\n  --modality mri \\\n  --patch-size 64,64,64 \\\n  --download-model-data\n```\n\nReplace `PATH_TO_DATALIST.json` and `PATH_TO_DATA_ROOT` with the user's actual paths. Do not use the fixture datalist for real training; it is a preflight-only placeholder.\n\n## 3. Monitor training (TensorBoard)\n\nThe runner writes TensorBoard scalars (per-iteration and per-epoch `recons_loss`, `kl_loss`, `p_loss`, adversarial\u002Freal\u002Ffake losses, and a validation `scale_factor`) under `OUT_DIR\u002Fartifacts\u002Ftfevent\u002Fautoencoder`. Launch TensorBoard against the output directory:\n\n```bash\npython -m pip install tensorboard && \\\ntensorboard --logdir runs\u002Fnv_generate_vae_finetune\u002Fartifacts\u002Ftfevent\n```\n\nThe same per-epoch loss history is also captured in `OUT_DIR\u002Fartifacts\u002Fworkflow_summary.json` and echoed in the JSON the wrapper prints to stdout (`loss_history`, best-checkpoint paths, `exit_code`, `stderr_tail`).\n\n## 4. Hyperparameter tuning and common pitfalls\n\n- **Reconstructions blurry** — raise `--perceptual-weight` (default `0.3`); try `--recon-loss l2` if edges look washed out.\n- **Posterior collapse \u002F over-regularized latents** — `--kl-weight` is intentionally tiny (`1e-7`); increasing it too much degrades reconstruction.\n- **Adversarial training unstable** — lower `--adv-weight` (default `0.1`) or `--lr`; a warmup schedule already ramps the LR over the first 20 epochs.\n- **Out-of-memory** — reduce `--patch-size` (e.g. `48,48,48`) and `--val-sliding-window-patch-size`, keep `--batch-size 1`, and lower `--cache-rate`.\n- **`datalist must include non-empty validation[] or testing[]`** — the validation loop is mandatory; add `validation[]` (or `testing[]`) entries.\n- **Single-GPU only** — the runner asserts exactly one CUDA GPU; set `CUDA_VISIBLE_DEVICES` to pick which one.\n\n## 5. Evaluate the finetuned VAE\n\nValidation reconstruction loss (lowest-`val_weighted_loss` epoch) is tracked automatically and the best autoencoder is saved as `autoencoder_epochN.pt` under `OUT_DIR\u002Fartifacts\u002Fmodels`. To evaluate downstream:\n\n- Compare validation `recons_loss`\u002F`p_loss` curves across runs in TensorBoard, and\n- Plug the finetuned autoencoder into a diffusion finetune\u002Fgeneration run (e.g. [`nv-generate-mr-brain-finetune`](..\u002Fnv-generate-mr-brain-finetune\u002FSKILL.md) via `--trained-autoencoder-path`) to confirm latents still decode to usable volumes.\n\nThis skill gates file accounting and reconstruction bookkeeping only — image quality and downstream utility must be judged by a domain expert.\n\n## Limitations\n- Requires a current upstream `NV-Generate-CTMR` checkout with VAE configs and helper APIs. The skill owns the runner glue and does not depend on the notebook.\n- Full training can be expensive and is not deterministic across hardware, CUDA, and package versions.\n- The wrapper gates file accounting and command provenance, not anatomical realism, reconstruction quality, or downstream model utility.\n- Not for clinical deployment, clinical interpretation, autonomous diagnosis, regulatory submission, or production training-data approval.\n\n## Troubleshooting\n| Error | Cause | Fix |\n|---|---|---|\n| `VAE configs\u002Fhelpers were not found` | `NV_GENERATE_ROOT` does not point at a current NV-Generate-CTMR checkout. | Clone or update `https:\u002F\u002Fgithub.com\u002FNVIDIA-Medtech\u002FNV-Generate-CTMR` and set `NV_GENERATE_ROOT`. |\n| `datalist must include non-empty validation[] or testing[]` | VAE training requires validation data for the configured validation loop. | Add `validation[]` or `testing[]` entries with relative image paths. |\n| CUDA, MONAI, or LPIPS import failure | Runtime environment lacks upstream dependencies. | Install `\"$NV_GENERATE_ROOT\u002Frequirements.txt\"` plus `lpips tensorboard` in the selected environment. |\n","# NV-Generate-VAE-Finetune\n\n## Purpose\n- Used for finetuning the NV-Generate-CTMR MAISI VAE\u002Fautoencoder from user-supplied CT or MRI NIfTI training volumes.\n- Not for clinical interpretation, regulatory use, or approving synthetic data for production training.\n- Upstream currently documents VAE training in `train_vae_tutorial.ipynb` and provides configs\u002Fhelpers, but not a `scripts.train_vae` CLI. This skill does not execute the notebook; it stages the required config\u002Fdatalist glue locally and uses upstream helper APIs.\n- Manifest I\u002FO: inputs are `datalist` and `data_base_dir`; outputs are `autoencoder_checkpoint`, `discriminator_checkpoint`, and `result_json`.\n- The underlying training contract is the upstream config\u002Fenv JSON (`config_maisi_vae_train.json` + `environment_maisi_vae_train.json`, as used in `train_vae_tutorial.ipynb`). The wrapper stages those JSON files for you and exposes the most-tuned fields as CLI flags; the sections below document the fields, their defaults, and how to monitor\u002Ftune a run.\n\n## Instructions\n- Read `skill_manifest.yaml` before changing arguments, side effects, or validation gates.\n- Run `scripts\u002Frun_vae_finetune.py` from the Medical AI Skills repo root.\n- If a host agent exposes `run_script`, use `run_script(\"scripts\u002Frun_vae_finetune.py\", args=[...])`; otherwise run the Bash\u002FPython command below.\n- Use `--preflight` first when checking a new datalist; remove `--preflight` only when the user explicitly wants to launch GPU finetuning.\n- For a staged preflight input bundle directory, use `BUNDLE\u002Fpreflight_datalist.json` as the datalist and `BUNDLE\u002Fpreflight_dataset` as `--data-base-dir` when those files are present.\n\n## Examples\n\nValidate and stage a preflight finetune check from an input bundle (the recommended first step — no GPU, no training). This is the single canonical command; replace `INPUT_BUNDLE` and `OUT_DIR` with your paths:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7}\" && \\\npython skills\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py \\\n  INPUT_BUNDLE\u002Fpreflight_datalist.json \\\n  --data-base-dir INPUT_BUNDLE\u002Fpreflight_dataset \\\n  --output-dir OUT_DIR \\\n  --modality mri \\\n  --preflight\n```\n\nFor real GPU finetuning and other variations, see [Usage](#2-usage-one-line-training) below.\n\n## Available Scripts\n| Script | Purpose | Arguments |\n|---|---|---|\n| `scripts\u002Frun_vae_finetune.py` | Primary entrypoint declared by `skill_manifest.yaml`. | `DATALIST.json --data-base-dir DATA_DIR --output-dir OUT_DIR [--epochs N] [--modality mri] [--patch-size 64,64,64] [--preflight]` |\n\n## Prerequisites\n- An explicit `NV_GENERATE_ROOT` may point to the caller's local checkout and\n  must contain `configs\u002Fconfig_maisi_vae_train.json`, `scripts\u002Ftransforms.py`,\n  and `scripts\u002Futils.py`. The result records its current commit.\n- If `NV_GENERATE_ROOT` is unset, the wrapper searches `.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR`.\n- `CUDA_VISIBLE_DEVICES` is optional and can be used to select the GPU for real training.\n- Runtime requirements: NVIDIA CUDA GPU for real training, Python packages from the upstream `requirements.txt`, `lpips`, and downloaded VAE weights unless using `--train-from-scratch`.\n- Side effects: writes staged configs, checkpoints, TensorBoard logs, and run summaries under the caller-provided `--output-dir`; may write model caches under the upstream checkout, `~\u002F.cache\u002Fhuggingface\u002F`, and `~\u002F.cache\u002Ftorch\u002F`; may contact `https:\u002F\u002Fhuggingface.co`, `https:\u002F\u002Fgithub.com`, and `https:\u002F\u002Fdownload.pytorch.org`.\n- The datalist is a MONAI-style JSON object with non-empty `training[]` and `validation[]` or `testing[]`. Each entry has an `image` path relative to `--data-base-dir` and optional `class` or `modality` of `ct` or `mri`.\n\nWhen no local checkout is supplied, create the recommended pinned default\ncheckout once:\n\n```bash\nif [ -z \"${NV_GENERATE_ROOT:-}\" ]; then\n  export NV_GENERATE_COMMIT=61c4ec709b84cad468852243c48e250bec732074\n  export NV_GENERATE_ROOT=\"$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7\"\n  if [ ! -d \"$NV_GENERATE_ROOT\u002F.git\" ]; then\n    git clone https:\u002F\u002Fgithub.com\u002FNVIDIA-Medtech\u002FNV-Generate-CTMR.git \"$NV_GENERATE_ROOT\"\n    git -C \"$NV_GENERATE_ROOT\" checkout --detach \"$NV_GENERATE_COMMIT\"\n  fi\nfi\n```\n\n## 1. Config and environment JSON (adapt to your data)\n\nThe wrapper copies the upstream VAE config\u002Fenv JSON from `$NV_GENERATE_ROOT\u002Fconfigs`, rewrites the fields below, and writes the staged copies under `OUT_DIR\u002Fworkflow\u002Fconfigs\u002F`. You normally only set your datalist and data root; the listed CLI flags override individual fields when you need to.\n\nEnvironment JSON (`environment_maisi_vae_train.json`):\n\n| Field | Set from | Notes |\n|---|---|---|\n| `model_dir` | `--output-dir` | Where `autoencoder.pt`\u002F`discriminator.pt` and best checkpoints are saved. |\n| `tfevent_path` | `--output-dir` | TensorBoard event directory. |\n| `finetune` | `--train-from-scratch` | `true` (default) loads `trained_autoencoder_path`; the flag sets it `false`. |\n| `trained_autoencoder_path` | upstream weights \u002F `--trained-autoencoder-path` | Starting VAE checkpoint when finetuning. |\n\nTraining fields (`config_maisi_vae_train.json`):\n\n| Field | Flag | Type | Default | Notes |\n|---|---|---|---|---|\n| `autoencoder_train.n_epochs` | `--epochs` | int | `1` | |\n| `autoencoder_train.batch_size` | `--batch-size` | int | `1` | Per-GPU (single-GPU runner). |\n| `autoencoder_train.patch_size` | `--patch-size` | int,int,int | `64,64,64` | Training crop. |\n| `autoencoder_train.val_batch_size` | `--val-batch-size` | int | `1` | |\n| `autoencoder_train.val_sliding_window_patch_size` | `--val-sliding-window-patch-size` | int,int,int | `96,96,64` | Sliding-window validation ROI. |\n| `autoencoder_train.lr` | `--lr` | float | `1e-4` | |\n| `autoencoder_train.perceptual_weight` | `--perceptual-weight` | float | `0.3` | LPIPS term. |\n| `autoencoder_train.kl_weight` | `--kl-weight` | float | `1e-7` | KL term. |\n| `autoencoder_train.adv_weight` | `--adv-weight` | float | `0.1` | Adversarial term. |\n| `autoencoder_train.recon_loss` | `--recon-loss` | `l1`\\|`l2` | `l1` | |\n| `autoencoder_train.val_interval` | `--val-interval` | int | `1` | Epochs between validation passes. |\n| `autoencoder_train.cache` | `--cache-rate` | float | `0.0` | MONAI `CacheDataset` fraction. |\n| `autoencoder_train.amp` | `--no-amp` | flag | on | Mixed precision; flag disables it. |\n| `data_option.random_aug` | `--no-random-aug` | flag | on | Random augmentation; flag disables it. |\n| `data_option.spacing_type` | `--spacing-type` | `original`\\|`fixed`\\|`rand_zoom` | `original` | |\n| `data_option.spacing` | `--spacing` | float,float,float | unset | Required when `spacing_type` is `fixed`\u002F`rand_zoom`. |\n| `data_option.select_channel` | `--select-channel` | int | `0` | Channel for multi-channel inputs. |\n\n`--modality` (`ct` or `mri`, default `mri`) fills the per-entry `class` for datalist items missing one. Validation\u002Ftesting entries are required because the training loop runs a validation pass.\n\nFor an end-to-end reference including example data download, see the upstream tutorial `train_vae_tutorial.ipynb`.\n\n## 2. Usage (one-line training)\n\nPreflight only:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7}\" && \\\npython skills\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py \\\n  PATH_TO_DATALIST.json \\\n  --data-base-dir PATH_TO_DATA_ROOT \\\n  --output-dir runs\u002Fnv_generate_vae_finetune_preflight \\\n  --preflight\n```\n\nPreflight bundle input:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7}\" && \\\npython skills\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py \\\n  PATH_TO_INPUT_BUNDLE\u002Fpreflight_datalist.json \\\n  --data-base-dir PATH_TO_INPUT_BUNDLE\u002Fpreflight_dataset \\\n  --output-dir runs\u002Fnv_generate_vae_finetune_preflight \\\n  --preflight\n```\n\nGPU finetuning:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-$HOME\u002F.cache\u002Fnvidia-skills\u002Fupstreams\u002FNV-Generate-CTMR-61c4ec7}\" && \\\npython -m pip install -r \"$NV_GENERATE_ROOT\u002Frequirements.txt\" && \\\npython -m pip install lpips tensorboard && \\\npython skills\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py \\\n  PATH_TO_DATALIST.json \\\n  --data-base-dir PATH_TO_DATA_ROOT \\\n  --output-dir runs\u002Fnv_generate_vae_finetune \\\n  --epochs 1 \\\n  --modality mri \\\n  --patch-size 64,64,64 \\\n  --download-model-data\n```\n\nReplace `PATH_TO_DATALIST.json` and `PATH_TO_DATA_ROOT` with the user's actual paths. Do not use the fixture datalist for real training; it is a preflight-only placeholder.\n\n## 3. Monitor training (TensorBoard)\n\nThe runner writes TensorBoard scalars (per-iteration and per-epoch `recons_loss`, `kl_loss`, `p_loss`, adversarial\u002Freal\u002Ffake losses, and a validation `scale_factor`) under `OUT_DIR\u002Fartifacts\u002Ftfevent\u002Fautoencoder`. Launch TensorBoard against the output directory:\n\n```bash\npython -m pip install tensorboard && \\\ntensorboard --logdir runs\u002Fnv_generate_vae_finetune\u002Fartifacts\u002Ftfevent\n```\n\nThe same per-epoch loss history is also captured in `OUT_DIR\u002Fartifacts\u002Fworkflow_summary.json` and echoed in the JSON the wrapper prints to stdout (`loss_history`, best-checkpoint paths, `exit_code`, `stderr_tail`).\n\n## 4. Hyperparameter tuning and common pitfalls\n\n- **Reconstructions blurry** — raise `--perceptual-weight` (default `0.3`); try `--recon-loss l2` if edges look washed out.\n- **Posterior collapse \u002F over-regularized latents** — `--kl-weight` is intentionally tiny (`1e-7`); increasing it too much degrades reconstruction.\n- **Adversarial training unstable** — lower `--adv-weight` (default `0.1`) or `--lr`; a warmup schedule already ramps the LR over the first 20 epochs.\n- **Out-of-memory** — reduce `--patch-size` (e.g. `48,48,48`) and `--val-sliding-window-patch-size`, keep `--batch-size 1`, and lower `--cache-rate`.\n- **`datalist must include non-empty validation[] or testing[]`** — the validation loop is mandatory; add `validation[]` (or `testing[]`) entries.\n- **Single-GPU only** — the runner asserts exactly one CUDA GPU; set `CUDA_VISIBLE_DEVICES` to pick which one.\n\n## 5. Evaluate the finetuned VAE\n\nValidation reconstruction loss (lowest-`val_weighted_loss` epoch) is tracked automatically and the best autoencoder is saved as `autoencoder_epochN.pt` under `OUT_DIR\u002Fartifacts\u002Fmodels`. To evaluate downstream:\n\n- Compare validation `recons_loss`\u002F`p_loss` curves across runs in TensorBoard, and\n- Plug the finetuned autoencoder into a diffusion finetune\u002Fgeneration run (e.g. [`nv-generate-mr-brain-finetune`](..\u002Fnv-generate-mr-brain-finetune\u002FSKILL.md) via `--trained-autoencoder-path`) to confirm latents still decode to usable volumes.\n\nThis skill gates file accounting and reconstruction bookkeeping only — image quality and downstream utility must be judged by a domain expert.\n\n## Limitations\n- Requires a current upstream `NV-Generate-CTMR` checkout with VAE configs and helper APIs. The skill owns the runner glue and does not depend on the notebook.\n- Full training can be expensive and is not deterministic across hardware, CUDA, and package versions.\n- The wrapper gates file accounting and command provenance, not anatomical realism, reconstruction quality, or downstream model utility.\n- Not for clinical deployment, clinical interpretation, autonomous diagnosis, regulatory submission, or production training-data approval.\n\n## Troubleshooting\n| Error | Cause | Fix |\n|---|---|---|\n| `VAE configs\u002Fhelpers were not found` | `NV_GENERATE_ROOT` does not point at a current NV-Generate-CTMR checkout. | Clone or update `https:\u002F\u002Fgithub.com\u002FNVIDIA-Medtech\u002FNV-Generate-CTMR` and set `NV_GENERATE_ROOT`. |\n| `datalist must include non-empty validation[] or testing[]` | VAE training requires validation data for the configured validation loop. | Add `validation[]` or `testing[]` entries with relative image paths. |\n| CUDA, MONAI, or LPIPS import failure | Runtime environment lacks upstream dependencies. | Install `\"$NV_GENERATE_ROOT\u002Frequirements.txt\"` plus `lpips tensorboard` in the selected environment. |\n",{"name":5,"license":15,"metadata":24,"description":7,"allowed-tools":32},{"tags":25,"author":31},[26,27,28,29,30],"MedTech","CT","MRI","VAE","finetune","NVIDIA MedTech Team","Bash","main","be3de0244dc1a57e323d8160787ebb40fb64930e","skills\u002Fnvidia\u002Fnv-generate-vae-finetune","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main","https:\u002F\u002Fskills.x402.wtf","https:\u002F\u002Fgithub.com\u002FSolizardking","https:\u002F\u002Fmusebook.trade","Got a mile high and never came down","2026-10-08 23:20:13",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add Solizardking\u002Fskillhub-main --skill nv-generate-vae-finetune",{"tool":48,"command":49},"bunx","bunx skills add Solizardking\u002Fskillhub-main --skill nv-generate-vae-finetune",{"tool":51,"command":52},"pnpm","pnpm dlx skills add Solizardking\u002Fskillhub-main --skill nv-generate-vae-finetune","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002FSKILL.md",true,[56,62,66,70,74,77,81,87,91,95,101,105],{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"BENCHMARK.md","REFERENCE","参考文档",4047,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002FBENCHMARK.md",{"path":63,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":64,"sourceHtmlUrl":65},"evals\u002Fevals.json",1182,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002Fevals\u002Fevals.json",{"path":67,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":68,"sourceHtmlUrl":69},"fixtures\u002Fpreflight_datalist.json",221,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002Ffixtures\u002Fpreflight_datalist.json",{"path":71,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":72,"sourceHtmlUrl":73},"fixtures\u002Fpreflight_dataset\u002FimagesTr\u002Fplaceholder_mri_train.txt",37,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002Ffixtures\u002Fpreflight_dataset\u002FimagesTr\u002Fplaceholder_mri_train.txt",{"path":75,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":72,"sourceHtmlUrl":76},"fixtures\u002Fpreflight_dataset\u002FimagesVal\u002Fplaceholder_mri_val.txt","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002Ffixtures\u002Fpreflight_dataset\u002FimagesVal\u002Fplaceholder_mri_val.txt",{"path":78,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":79,"sourceHtmlUrl":80},"fixtures\u002FREADME.md",232,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002Ffixtures\u002FREADME.md",{"path":82,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":85,"sourceHtmlUrl":86},"scripts\u002Frun_vae_finetune.py","SCRIPT","脚本",32915,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002Fscripts\u002Frun_vae_finetune.py",{"path":88,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":89,"sourceHtmlUrl":90},"skill_manifest.yaml",6385,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002Fskill_manifest.yaml",{"path":92,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":93,"sourceHtmlUrl":94},"skill-card.md",4121,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002Fskill-card.md",{"path":96,"resourceType":97,"resourceTypeDesc":98,"sizeBytes":99,"sourceHtmlUrl":100},"skill.oms.sig","OTHER","其他",6597,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002Fskill.oms.sig",{"path":102,"resourceType":83,"resourceTypeDesc":84,"sizeBytes":103,"sourceHtmlUrl":104},"tests\u002Ftest_run_vae_finetune.py",5742,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002Ftests\u002Ftest_run_vae_finetune.py",{"path":106,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":107,"sourceHtmlUrl":108},"validators\u002Foutput_schema.json",4061,"https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fnvidia\u002Fnv-generate-vae-finetune\u002Fvalidators\u002Foutput_schema.json",[110,118,125,132,139,147],{"skillNo":111,"name":112,"nameZh":6,"description":113,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":114,"licenseFileUrl":6,"sourceHtmlUrl":115,"categories":116,"keywords":117,"publishedAt":19},"01M78E0TGCAMNPS207BA3G07S7","zkrouter","Self-hosted OpenAI-compatible LLM router — smart tier-based routing, ZK-stamped routing decisions, mode overrides, free OpenRouter at install via the Birth bot. Save 60-80% on inference costs by routing to the cheapest capable model across 12+ OpenRouter models.","MIT","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fzkrouter\u002FSKILL.md",[],[],{"skillNo":119,"name":120,"nameZh":6,"description":121,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":114,"licenseFileUrl":6,"sourceHtmlUrl":122,"categories":123,"keywords":124,"publishedAt":19},"01M78E0R1Z8BDT6EDTHY17MTNB","zk","For custom ZK Solana programs and privacy-preserving applications to prevent double spending. Guide to integrate rent-free nullifier PDAs for double-spend prevention.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fzk\u002FSKILL.md",[],[],{"skillNo":126,"name":127,"nameZh":6,"description":128,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":114,"licenseFileUrl":6,"sourceHtmlUrl":129,"categories":130,"keywords":131,"publishedAt":19},"01M78E0P3ZTZ1YWF8MD5MM23QE","zk-omni-messaging","Zero-knowledge omnichain messaging between Robinhood Chain and Solana using CheshireZkOmniMessenger (msgType 4) with nullifier anti-replay and the zk-omni-relayer service.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fzk-omni-messaging\u002FSKILL.md",[],[],{"skillNo":133,"name":134,"nameZh":6,"description":135,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":114,"licenseFileUrl":6,"sourceHtmlUrl":136,"categories":137,"keywords":138,"publishedAt":19},"01M78E0JXZ2PNB1896VXAGDBWD","zerion-wallet-data","Use when the user asks to check a wallet's portfolio, token balances, DeFi positions, PnL, transaction history, or NFTs. Provides interpreted on-chain data across 40+ EVM chains and Solana via x402 pay-per-request or API key — no raw RPC decoding needed.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fzerion-wallet-data\u002FSKILL.md",[],[],{"skillNo":140,"name":141,"nameZh":6,"description":142,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":114,"licenseFileUrl":143,"sourceHtmlUrl":144,"categories":145,"keywords":146,"publishedAt":19},"01M78E0G14FH9GRRTQYMKD5E59","youtube-clipper","YouTube 视频智能剪辑工具。下载视频和字幕，AI 分析生成精细章节（几分钟级别）， 用户选择片段后自动剪辑、翻译字幕为中英双语、烧录字幕到视频，并生成总结文案。 使用场景：当用户需要剪辑 YouTube 视频、生成短视频片段、制作双语字幕版本时。 关键词：视频剪辑、YouTube、字幕翻译、双语字幕、视频下载、clip video","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fyoutube-clipper\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fyoutube-clipper\u002FSKILL.md",[],[],{"skillNo":148,"name":149,"nameZh":6,"description":150,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":114,"licenseFileUrl":6,"sourceHtmlUrl":151,"categories":152,"keywords":153,"publishedAt":19},"01M78E0C2ZYA99CFFDNB7ZMK5S","yield-optimization","Multi-chain yield optimization via yield.xyz (StakeKit). Discover 2,988+ yield opportunities across 75+ blockchains, build deposit\u002Fwithdrawal transactions with shell scripts, and sign them with a MoonPay wallet. Use when the user wants to earn yield, find the best lending or staking rate, enter\u002Fexit a position, or check portfolio balances.","https:\u002F\u002Fgithub.com\u002FSolizardking\u002Fskillhub-main\u002Fblob\u002Fmain\u002Fskills\u002Fyield-optimization\u002FSKILL.md",[],[]]