[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7BK3QEDGA7NVWM7GZ8HSA64":3,"skill-same:01M7BK3QEDGA7NVWM7GZ8HSA64":106},{"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":34,"commitSha":35,"skillDirectory":36,"forksCount":14,"repositoryHtmlUrl":37,"repositoryHomepageUrl":38,"ownerHtmlUrl":39,"ownerBlogUrl":6,"ownerDescription":40,"updatedAt":41,"install":42,"resources":55},"01M7BK3QEDGA7NVWM7GZ8HSA64","nv-generate-mr-brain-finetune",null,"Used for finetuning NV-Generate-CTMR MR-brain diffusion UNet from a NIfTI datalist. Not for clinical or production data approval.","YYC-Cube\u002FYYC3-AI-Agent-Archive","YYC-Cube","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F235006543?v=4","01M79J2PH4SWD2X0825X6PN748","yyc3","01M79K9J2WD44BBY4662XKNZRB",2,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Fskills-hub\u002Fai-ml\u002Fnvidia-skills\u002Fskills\u002Fnv-generate-mr-brain-finetune\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: nv-generate-mr-brain-finetune\ndescription: Used for finetuning NV-Generate-CTMR MR-brain diffusion UNet from a NIfTI datalist. Not for clinical or production data approval.\ncategory: development-code\nversion: 1.0.0\nlicense: Apache-2.0\nallowed-tools: Bash\nmetadata:\n  author: NVIDIA MedTech Team\n  tags:\n    - MedTech\n    - MRI\n    - brain\n    - finetune\n---\n\n# NV-Generate-MR-Brain-Finetune\n\n## Purpose\n- Used for finetuning the NV-Generate-CTMR `rflow-mr-brain` diffusion UNet from user-supplied NIfTI training volumes.\n- Not for clinical interpretation, regulatory use, or approving synthetic data for production training.\n- The wrapper stages the config glue locally and delegates execution to existing upstream scripts: `scripts.diff_model_create_training_data`, `scripts.diff_model_train`, and optionally `scripts.diff_model_infer`. It does not execute the notebook.\n- Manifest I\u002FO: inputs are `datalist` and `data_base_dir`; outputs are `finetuned_checkpoint`, optional `inference_outputs`, and `result_json`.\n- The underlying training contract is the upstream config\u002Fenv JSON (the same one driven from cell `[10]` of `train_diff_unet_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_mr_brain_finetune.py` from the Medical AI Skills repo root.\n- If a host agent exposes `run_script`, use `run_script(\"scripts\u002Frun_mr_brain_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:-.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR}\" && \\\npython skills\u002Fnv-generate-mr-brain-finetune\u002Fscripts\u002Frun_mr_brain_finetune.py \\\n  INPUT_BUNDLE\u002Fpreflight_datalist.json \\\n  --data-base-dir INPUT_BUNDLE\u002Fpreflight_dataset \\\n  --output-dir OUT_DIR \\\n  --modality mri_t1 \\\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_mr_brain_finetune.py` | Primary entrypoint declared by `skill_manifest.yaml`. | `DATALIST.json --data-base-dir DATA_DIR --output-dir OUT_DIR [--epochs N] [--modality mri_t1] [--num-gpus N] [--no-amp] [--model-config FILE] [--run-inference] [--preflight]` |\n\n## Prerequisites\n- `NV_GENERATE_ROOT` may point to a current checkout of `https:\u002F\u002Fgithub.com\u002FNVIDIA-Medtech\u002FNV-Generate-CTMR` containing `scripts\u002Fdiff_model_create_training_data.py`, `scripts\u002Fdiff_model_train.py`, and `scripts\u002Fdiff_model_infer.py`.\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`, and downloaded MR-brain weights.\n- Side effects: writes staged configs, embeddings, checkpoints, optional inference images, and logs under the caller-provided `--output-dir`; may write model caches under the upstream checkout and `~\u002F.cache\u002Fhuggingface\u002F`; may contact `https:\u002F\u002Fhuggingface.co` for model assets and `https:\u002F\u002Fgithub.com` for the upstream checkout.\n- The datalist is a MONAI-style JSON object with `training[].image` paths relative to `--data-base-dir`. `training[].modality` is optional and defaults to `mri_t1`.\n\n## 1. Config and environment JSON (adapt to your data)\n\nThis is a thin wrapper around the upstream `train_diff_unet_tutorial.ipynb` flow. Each run performs four steps, delegating the heavy lifting to the model author's scripts:\n\n1. **Stage configs** — copy the three config JSONs and rewrite only the run-specific paths and `n_epochs` (notebook cell 15).\n2. `python -m scripts.diff_model_create_training_data` → latent `*_emb.nii.gz` embeddings (cell 17).\n3. **Write embedding sidecars** — a `\u003Cemb>.nii.gz.json` per embedding with `spacing`\u002F`modality` (and body-region indices when the model uses them). This is the one piece of glue that lives in the notebook (cell 19), not in upstream `scripts\u002F`, and `diff_model_train` requires it; the skill owns it.\n4. `python -m scripts.diff_model_train` (cell 21), optionally `python -m scripts.diff_model_infer`.\n\n**Tune by editing the config JSON, not by adding flags.** All training\u002Finference hyperparameters (`lr`, `batch_size`, `cache_rate`, inference `dim`\u002F`spacing`\u002F`num_inference_steps`\u002F`cfg_guidance_scale`, …) live in `config_maisi_diff_model_rflow-mr-brain.json`. Edit the upstream copy, or pass your own with `--model-config FILE` (and `--env-config` \u002F `--model-def` for the other two). The wrapper only ever rewrites the fields below.\n\nEnvironment JSON (`environment_maisi_diff_model_rflow-mr-brain.json`) — fields the wrapper rewrites per run:\n\n| Field | Set from | Notes |\n|---|---|---|\n| `data_base_dir` | `--data-base-dir` | Root for relative `training[].image` paths. |\n| `json_data_list` | your datalist | Staged copy with per-entry `modality` filled in. |\n| `embedding_base_dir`, `model_dir`, `output_dir` | `--output-dir` | Latent embeddings, checkpoints, inference images. |\n| `modality_mapping_path` | upstream | Maps modality name → integer code. |\n| `model_filename` | `--model-filename` | Output checkpoint name (default `diff_unet_3d_rflow-mr-brain_v0.pt`). |\n| `existing_ckpt_filepath` | upstream weights \u002F `--existing-ckpt-filepath` | Starting checkpoint; cleared by `--train-from-scratch`. |\n| `trained_autoencoder_path` | upstream weights \u002F `--trained-autoencoder-path` | VAE used to encode\u002Fdecode latents. |\n\nModel config (`config_maisi_diff_model_rflow-mr-brain.json`) — the only fields the wrapper touches:\n\n| Field | Set from | Default | Notes |\n|---|---|---|---|\n| `diffusion_unet_train.n_epochs` | `--epochs` | `2` (upstream config ships `1000`) | Convenience override (cell 15 does the same); wrapper default is small for verification. |\n| `diffusion_unet_inference.modality` | `--modality` | from `modality_mapping.json` | Kept consistent with the training modality for optional `--run-inference`. |\n\nEverything else in that file (`lr`, `batch_size`, `cache_rate`, the rest of `diffusion_unet_inference`) is left exactly as written — edit the JSON to change it.\n\nRuntime flags (not config fields): `--num-gpus N` (`>1` launches `torch.distributed.run`), `--no-amp` (disable mixed precision, passed through to `diff_model_train`).\n\n`--modality` selects the integer code from `configs\u002Fmodality_mapping.json`. Supported brain values: `mri` (8), `mri_t1` (9, default), `mri_t2` (10), `mri_flair` (11), `mri_swi` (20), and their `*_skull_stripped` variants (29\u002F30\u002F31\u002F32). Per-case `training[].modality` overrides `--modality`. The modality also feeds the step-3 embedding sidecars.\n\nFor an end-to-end reference including example data download and checkpoint loading, see the upstream tutorial `train_diff_unet_tutorial.ipynb`.\n\n## 2. Usage (one-line training)\n\nPreflight only:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR}\" && \\\npython skills\u002Fnv-generate-mr-brain-finetune\u002Fscripts\u002Frun_mr_brain_finetune.py \\\n  PATH_TO_DATALIST.json \\\n  --data-base-dir PATH_TO_DATA_ROOT \\\n  --output-dir runs\u002Fnv_generate_mr_brain_finetune_preflight \\\n  --preflight\n```\n\nPreflight bundle input:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR}\" && \\\npython skills\u002Fnv-generate-mr-brain-finetune\u002Fscripts\u002Frun_mr_brain_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_mr_brain_finetune_preflight \\\n  --preflight\n```\n\nGPU finetuning:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR}\" && \\\npython -m pip install -r \"$NV_GENERATE_ROOT\u002Frequirements.txt\" && \\\npython skills\u002Fnv-generate-mr-brain-finetune\u002Fscripts\u002Frun_mr_brain_finetune.py \\\n  PATH_TO_DATALIST.json \\\n  --data-base-dir PATH_TO_DATA_ROOT \\\n  --output-dir runs\u002Fnv_generate_mr_brain_finetune \\\n  --epochs 2 \\\n  --modality mri_t1 \\\n  --run-inference\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\n`scripts.diff_model_train` writes TensorBoard event files under the staged `model_dir` (`OUT_DIR\u002Fartifacts\u002Fmodels`). Launch TensorBoard against the output directory and watch the loss curve:\n\n```bash\npython -m pip install tensorboard && \\\ntensorboard --logdir runs\u002Fnv_generate_mr_brain_finetune\u002Fartifacts\n```\n\nThe run summary is written to `OUT_DIR\u002Fartifacts\u002Fworkflow_summary.json` (checkpoint path, embedding sidecars, inference outputs); the JSON the wrapper prints to stdout mirrors the same paths plus `exit_code` and a `stderr_tail` for quick triage.\n\n## 4. Hyperparameter tuning and common pitfalls\n\n- **Loss not decreasing \u002F unstable** — lower `diffusion_unet_train.lr` (default `1e-5`) in the model-config JSON, or keep AMP on (default); `--no-amp` is slower but more numerically stable on older GPUs.\n- **Out-of-memory** — keep `diffusion_unet_train.batch_size` at `1` and `cache_rate` at `0` in the config JSON, and confirm the autoencoder\u002FUNet fit your GPU before scaling. Multi-GPU (`--num-gpus N`) shards the batch via `torch.distributed.run`.\n- **Few cases \u002F quick check** — keep `--epochs` small (the wrapper default `2` is for verification, not convergence; the upstream config ships `1000`).\n- **Wrong modality conditioning** — set `--modality` or per-case `training[].modality` to a value present in `configs\u002Fmodality_mapping.json`; a mismatch produces a clear error rather than silently mislabeling latents.\n- **Slow startup on first run** — `diff_model_create_training_data` precomputes latent embeddings once; reuse the same `--output-dir` to avoid recomputing them.\n\n## 5. Evaluate the finetuned model\n\nUse the staged checkpoint (`OUT_DIR\u002Fartifacts\u002Fmodels\u002F\u003Cmodel_filename>`) as the diffusion UNet for generation, then inspect the synthesized volumes:\n\n- Pass `--run-inference` here for a quick built-in sanity render, or\n- Point the [`nv-generate-mr-brain`](..\u002Fnv-generate-mr-brain\u002FSKILL.md) inference skill at the finetuned checkpoint to generate fresh brain MRI volumes for qualitative review.\n\nThis skill gates file accounting and command provenance only — anatomical realism and downstream utility must be judged by a domain expert on the generated images.\n\n## Limitations\n- Requires a current upstream `NV-Generate-CTMR` checkout with the existing diffusion training scripts. The skill itself stages the required config and datalist glue locally and does not depend on the notebook or PR #33.\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 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| `diffusion training scripts 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| `missing datalist image` | `training[].image` paths are not relative to `--data-base-dir` or files are absent. | Fix the datalist or pass the correct data root. |\n| CUDA or MONAI import failure | Runtime environment lacks upstream dependencies. | Install `\"$NV_GENERATE_ROOT\u002Frequirements.txt\"` in the selected environment. |\n","# NV-Generate-MR-Brain-Finetune\n\n## Purpose\n- Used for finetuning the NV-Generate-CTMR `rflow-mr-brain` diffusion UNet from user-supplied NIfTI training volumes.\n- Not for clinical interpretation, regulatory use, or approving synthetic data for production training.\n- The wrapper stages the config glue locally and delegates execution to existing upstream scripts: `scripts.diff_model_create_training_data`, `scripts.diff_model_train`, and optionally `scripts.diff_model_infer`. It does not execute the notebook.\n- Manifest I\u002FO: inputs are `datalist` and `data_base_dir`; outputs are `finetuned_checkpoint`, optional `inference_outputs`, and `result_json`.\n- The underlying training contract is the upstream config\u002Fenv JSON (the same one driven from cell `[10]` of `train_diff_unet_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_mr_brain_finetune.py` from the Medical AI Skills repo root.\n- If a host agent exposes `run_script`, use `run_script(\"scripts\u002Frun_mr_brain_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:-.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR}\" && \\\npython skills\u002Fnv-generate-mr-brain-finetune\u002Fscripts\u002Frun_mr_brain_finetune.py \\\n  INPUT_BUNDLE\u002Fpreflight_datalist.json \\\n  --data-base-dir INPUT_BUNDLE\u002Fpreflight_dataset \\\n  --output-dir OUT_DIR \\\n  --modality mri_t1 \\\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_mr_brain_finetune.py` | Primary entrypoint declared by `skill_manifest.yaml`. | `DATALIST.json --data-base-dir DATA_DIR --output-dir OUT_DIR [--epochs N] [--modality mri_t1] [--num-gpus N] [--no-amp] [--model-config FILE] [--run-inference] [--preflight]` |\n\n## Prerequisites\n- `NV_GENERATE_ROOT` may point to a current checkout of `https:\u002F\u002Fgithub.com\u002FNVIDIA-Medtech\u002FNV-Generate-CTMR` containing `scripts\u002Fdiff_model_create_training_data.py`, `scripts\u002Fdiff_model_train.py`, and `scripts\u002Fdiff_model_infer.py`.\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`, and downloaded MR-brain weights.\n- Side effects: writes staged configs, embeddings, checkpoints, optional inference images, and logs under the caller-provided `--output-dir`; may write model caches under the upstream checkout and `~\u002F.cache\u002Fhuggingface\u002F`; may contact `https:\u002F\u002Fhuggingface.co` for model assets and `https:\u002F\u002Fgithub.com` for the upstream checkout.\n- The datalist is a MONAI-style JSON object with `training[].image` paths relative to `--data-base-dir`. `training[].modality` is optional and defaults to `mri_t1`.\n\n## 1. Config and environment JSON (adapt to your data)\n\nThis is a thin wrapper around the upstream `train_diff_unet_tutorial.ipynb` flow. Each run performs four steps, delegating the heavy lifting to the model author's scripts:\n\n1. **Stage configs** — copy the three config JSONs and rewrite only the run-specific paths and `n_epochs` (notebook cell 15).\n2. `python -m scripts.diff_model_create_training_data` → latent `*_emb.nii.gz` embeddings (cell 17).\n3. **Write embedding sidecars** — a `\u003Cemb>.nii.gz.json` per embedding with `spacing`\u002F`modality` (and body-region indices when the model uses them). This is the one piece of glue that lives in the notebook (cell 19), not in upstream `scripts\u002F`, and `diff_model_train` requires it; the skill owns it.\n4. `python -m scripts.diff_model_train` (cell 21), optionally `python -m scripts.diff_model_infer`.\n\n**Tune by editing the config JSON, not by adding flags.** All training\u002Finference hyperparameters (`lr`, `batch_size`, `cache_rate`, inference `dim`\u002F`spacing`\u002F`num_inference_steps`\u002F`cfg_guidance_scale`, …) live in `config_maisi_diff_model_rflow-mr-brain.json`. Edit the upstream copy, or pass your own with `--model-config FILE` (and `--env-config` \u002F `--model-def` for the other two). The wrapper only ever rewrites the fields below.\n\nEnvironment JSON (`environment_maisi_diff_model_rflow-mr-brain.json`) — fields the wrapper rewrites per run:\n\n| Field | Set from | Notes |\n|---|---|---|\n| `data_base_dir` | `--data-base-dir` | Root for relative `training[].image` paths. |\n| `json_data_list` | your datalist | Staged copy with per-entry `modality` filled in. |\n| `embedding_base_dir`, `model_dir`, `output_dir` | `--output-dir` | Latent embeddings, checkpoints, inference images. |\n| `modality_mapping_path` | upstream | Maps modality name → integer code. |\n| `model_filename` | `--model-filename` | Output checkpoint name (default `diff_unet_3d_rflow-mr-brain_v0.pt`). |\n| `existing_ckpt_filepath` | upstream weights \u002F `--existing-ckpt-filepath` | Starting checkpoint; cleared by `--train-from-scratch`. |\n| `trained_autoencoder_path` | upstream weights \u002F `--trained-autoencoder-path` | VAE used to encode\u002Fdecode latents. |\n\nModel config (`config_maisi_diff_model_rflow-mr-brain.json`) — the only fields the wrapper touches:\n\n| Field | Set from | Default | Notes |\n|---|---|---|---|\n| `diffusion_unet_train.n_epochs` | `--epochs` | `2` (upstream config ships `1000`) | Convenience override (cell 15 does the same); wrapper default is small for verification. |\n| `diffusion_unet_inference.modality` | `--modality` | from `modality_mapping.json` | Kept consistent with the training modality for optional `--run-inference`. |\n\nEverything else in that file (`lr`, `batch_size`, `cache_rate`, the rest of `diffusion_unet_inference`) is left exactly as written — edit the JSON to change it.\n\nRuntime flags (not config fields): `--num-gpus N` (`>1` launches `torch.distributed.run`), `--no-amp` (disable mixed precision, passed through to `diff_model_train`).\n\n`--modality` selects the integer code from `configs\u002Fmodality_mapping.json`. Supported brain values: `mri` (8), `mri_t1` (9, default), `mri_t2` (10), `mri_flair` (11), `mri_swi` (20), and their `*_skull_stripped` variants (29\u002F30\u002F31\u002F32). Per-case `training[].modality` overrides `--modality`. The modality also feeds the step-3 embedding sidecars.\n\nFor an end-to-end reference including example data download and checkpoint loading, see the upstream tutorial `train_diff_unet_tutorial.ipynb`.\n\n## 2. Usage (one-line training)\n\nPreflight only:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR}\" && \\\npython skills\u002Fnv-generate-mr-brain-finetune\u002Fscripts\u002Frun_mr_brain_finetune.py \\\n  PATH_TO_DATALIST.json \\\n  --data-base-dir PATH_TO_DATA_ROOT \\\n  --output-dir runs\u002Fnv_generate_mr_brain_finetune_preflight \\\n  --preflight\n```\n\nPreflight bundle input:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR}\" && \\\npython skills\u002Fnv-generate-mr-brain-finetune\u002Fscripts\u002Frun_mr_brain_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_mr_brain_finetune_preflight \\\n  --preflight\n```\n\nGPU finetuning:\n\n```bash\nexport NV_GENERATE_ROOT=\"${NV_GENERATE_ROOT:-.workbench_data\u002Fupstreams\u002FNV-Generate-CTMR}\" && \\\npython -m pip install -r \"$NV_GENERATE_ROOT\u002Frequirements.txt\" && \\\npython skills\u002Fnv-generate-mr-brain-finetune\u002Fscripts\u002Frun_mr_brain_finetune.py \\\n  PATH_TO_DATALIST.json \\\n  --data-base-dir PATH_TO_DATA_ROOT \\\n  --output-dir runs\u002Fnv_generate_mr_brain_finetune \\\n  --epochs 2 \\\n  --modality mri_t1 \\\n  --run-inference\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\n`scripts.diff_model_train` writes TensorBoard event files under the staged `model_dir` (`OUT_DIR\u002Fartifacts\u002Fmodels`). Launch TensorBoard against the output directory and watch the loss curve:\n\n```bash\npython -m pip install tensorboard && \\\ntensorboard --logdir runs\u002Fnv_generate_mr_brain_finetune\u002Fartifacts\n```\n\nThe run summary is written to `OUT_DIR\u002Fartifacts\u002Fworkflow_summary.json` (checkpoint path, embedding sidecars, inference outputs); the JSON the wrapper prints to stdout mirrors the same paths plus `exit_code` and a `stderr_tail` for quick triage.\n\n## 4. Hyperparameter tuning and common pitfalls\n\n- **Loss not decreasing \u002F unstable** — lower `diffusion_unet_train.lr` (default `1e-5`) in the model-config JSON, or keep AMP on (default); `--no-amp` is slower but more numerically stable on older GPUs.\n- **Out-of-memory** — keep `diffusion_unet_train.batch_size` at `1` and `cache_rate` at `0` in the config JSON, and confirm the autoencoder\u002FUNet fit your GPU before scaling. Multi-GPU (`--num-gpus N`) shards the batch via `torch.distributed.run`.\n- **Few cases \u002F quick check** — keep `--epochs` small (the wrapper default `2` is for verification, not convergence; the upstream config ships `1000`).\n- **Wrong modality conditioning** — set `--modality` or per-case `training[].modality` to a value present in `configs\u002Fmodality_mapping.json`; a mismatch produces a clear error rather than silently mislabeling latents.\n- **Slow startup on first run** — `diff_model_create_training_data` precomputes latent embeddings once; reuse the same `--output-dir` to avoid recomputing them.\n\n## 5. Evaluate the finetuned model\n\nUse the staged checkpoint (`OUT_DIR\u002Fartifacts\u002Fmodels\u002F\u003Cmodel_filename>`) as the diffusion UNet for generation, then inspect the synthesized volumes:\n\n- Pass `--run-inference` here for a quick built-in sanity render, or\n- Point the [`nv-generate-mr-brain`](..\u002Fnv-generate-mr-brain\u002FSKILL.md) inference skill at the finetuned checkpoint to generate fresh brain MRI volumes for qualitative review.\n\nThis skill gates file accounting and command provenance only — anatomical realism and downstream utility must be judged by a domain expert on the generated images.\n\n## Limitations\n- Requires a current upstream `NV-Generate-CTMR` checkout with the existing diffusion training scripts. The skill itself stages the required config and datalist glue locally and does not depend on the notebook or PR #33.\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 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| `diffusion training scripts 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| `missing datalist image` | `training[].image` paths are not relative to `--data-base-dir` or files are absent. | Fix the datalist or pass the correct data root. |\n| CUDA or MONAI import failure | Runtime environment lacks upstream dependencies. | Install `\"$NV_GENERATE_ROOT\u002Frequirements.txt\"` in the selected environment. |\n",{"name":5,"license":15,"version":24,"category":25,"metadata":26,"description":7,"allowed-tools":33},"1.0.0","development-code",{"tags":27,"author":32},[28,29,30,31],"MedTech","MRI","brain","finetune","NVIDIA MedTech Team","Bash","main","d591030ef9fb1bbcebed3454aa5c2dcb8d608f69","skills-hub\u002Fai-ml\u002Fnvidia-skills\u002Fskills\u002Fnv-generate-mr-brain-finetune","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive","https:\u002F\u002Fai-agent.yyc3.vip\u002F","https:\u002F\u002Fgithub.com\u002FYYC-Cube","万象归元于云枢 | 深栈智启新纪元","2026-11-13 22:26:14",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add YYC-Cube\u002FYYC3-AI-Agent-Archive --skill nv-generate-mr-brain-finetune",{"tool":48,"command":49},"bunx","bunx skills add YYC-Cube\u002FYYC3-AI-Agent-Archive --skill nv-generate-mr-brain-finetune",{"tool":51,"command":52},"pnpm","pnpm dlx skills add YYC-Cube\u002FYYC3-AI-Agent-Archive --skill nv-generate-mr-brain-finetune","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Fskills-hub\u002Fai-ml\u002Fnvidia-skills\u002Fskills\u002Fnv-generate-mr-brain-finetune\u002FSKILL.md",true,[56,62,66,70,74,78,84,88,92,98,102],{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"BENCHMARK.md","REFERENCE","参考文档",4492,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Fskills-hub\u002Fai-ml\u002Fnvidia-skills\u002Fskills\u002Fnv-generate-mr-brain-finetune\u002FBENCHMARK.md",{"path":63,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":64,"sourceHtmlUrl":65},"evals\u002Fevals.json",1228,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Fskills-hub\u002Fai-ml\u002Fnvidia-skills\u002Fskills\u002Fnv-generate-mr-brain-finetune\u002Fevals\u002Fevals.json",{"path":67,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":68,"sourceHtmlUrl":69},"fixtures\u002Fpreflight_datalist.json",130,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Fskills-hub\u002Fai-ml\u002Fnvidia-skills\u002Fskills\u002Fnv-generate-mr-brain-finetune\u002Ffixtures\u002Fpreflight_datalist.json",{"path":71,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":72,"sourceHtmlUrl":73},"fixtures\u002Fpreflight_dataset\u002FimagesTr\u002Fplaceholder_mri_t1.txt",133,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Fskills-hub\u002Fai-ml\u002Fnvidia-skills\u002Fskills\u002Fnv-generate-mr-brain-finetune\u002Ffixtures\u002Fpreflight_dataset\u002FimagesTr\u002Fplaceholder_mri_t1.txt",{"path":75,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":76,"sourceHtmlUrl":77},"fixtures\u002FREADME.md",228,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Fskills-hub\u002Fai-ml\u002Fnvidia-skills\u002Fskills\u002Fnv-generate-mr-brain-finetune\u002Ffixtures\u002FREADME.md",{"path":79,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":82,"sourceHtmlUrl":83},"scripts\u002Frun_mr_brain_finetune.py","SCRIPT","脚本",27467,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Fskills-hub\u002Fai-ml\u002Fnvidia-skills\u002Fskills\u002Fnv-generate-mr-brain-finetune\u002Fscripts\u002Frun_mr_brain_finetune.py",{"path":85,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":86,"sourceHtmlUrl":87},"skill_manifest.yaml",6150,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Fskills-hub\u002Fai-ml\u002Fnvidia-skills\u002Fskills\u002Fnv-generate-mr-brain-finetune\u002Fskill_manifest.yaml",{"path":89,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":90,"sourceHtmlUrl":91},"skill-card.md",3741,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Fskills-hub\u002Fai-ml\u002Fnvidia-skills\u002Fskills\u002Fnv-generate-mr-brain-finetune\u002Fskill-card.md",{"path":93,"resourceType":94,"resourceTypeDesc":95,"sizeBytes":96,"sourceHtmlUrl":97},"skill.oms.sig","OTHER","其他",6329,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Fskills-hub\u002Fai-ml\u002Fnvidia-skills\u002Fskills\u002Fnv-generate-mr-brain-finetune\u002Fskill.oms.sig",{"path":99,"resourceType":80,"resourceTypeDesc":81,"sizeBytes":100,"sourceHtmlUrl":101},"tests\u002Ftest_run_mr_brain_finetune.py",6761,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Fskills-hub\u002Fai-ml\u002Fnvidia-skills\u002Fskills\u002Fnv-generate-mr-brain-finetune\u002Ftests\u002Ftest_run_mr_brain_finetune.py",{"path":103,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":104,"sourceHtmlUrl":105},"validators\u002Foutput_schema.json",3842,"https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Fskills-hub\u002Fai-ml\u002Fnvidia-skills\u002Fskills\u002Fnv-generate-mr-brain-finetune\u002Fvalidators\u002Foutput_schema.json",[107,115,122,129,136,144],{"skillNo":108,"name":109,"nameZh":6,"description":110,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":111,"licenseFileUrl":6,"sourceHtmlUrl":112,"categories":113,"keywords":114,"publishedAt":19},"01M7BTB92RE8MT5YE706QBNDTQ","yingmi-skill","当用户需要查询基金、策略、公告、财经资讯，做资产配置、组合诊断、风险回测、现金流分析，或生成图表、PDF 时，优先使用本 Skill 获取真实数据与可执行能力。","MIT","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Ftools-hub\u002Fcode-ide\u002Fskills-marketplace\u002Fskills\u002Fyingmi-skill\u002FSKILL.md",[],[],{"skillNo":116,"name":117,"nameZh":6,"description":118,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":111,"licenseFileUrl":6,"sourceHtmlUrl":119,"categories":120,"keywords":121,"publishedAt":19},"01M7BT7ZYR091HPJYEFNWVTEJJ","web-access","所有联网操作必须通过此 skill 处理，包括：搜索、网页抓取、登录后操作、网络交互等。","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Ftools-hub\u002Fcode-ide\u002Fskills-marketplace\u002Fskills\u002Fweb-access\u002FSKILL.md",[],[],{"skillNo":123,"name":124,"nameZh":6,"description":125,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":111,"licenseFileUrl":6,"sourceHtmlUrl":126,"categories":127,"keywords":128,"publishedAt":19},"01M7BT4NKS0DNP8A53M1BGGZR2","tencentmap-map-assistant","腾讯位置服务·地图助手 Skill，一句自然语言调用腾讯地图全套能力，无需开发者账号、开箱即用。提供 AI 旅游攻略、地点搜索（含评分\u002F人均\u002F营业时间）、关键词提示、路线规划（驾车\u002F步行\u002F公交\u002F骑行）、地址解析与逆解析、行政区划、IP 定位、距离计算、天气查询，并可将行程或多 POI 渲染成网页地图。涉及找地点、规划路线、旅游行程、查天气、坐标转换等出行场景时使用。","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Ftools-hub\u002Fcode-ide\u002Fskills-marketplace\u002Fskills\u002Ftencentmap-map-assistant\u002FSKILL.md",[],[],{"skillNo":130,"name":131,"nameZh":6,"description":132,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":111,"licenseFileUrl":6,"sourceHtmlUrl":133,"categories":134,"keywords":135,"publishedAt":19},"01M7BSWKV1T5XYYRGV4W4JP88C","skill-scanner","Scan any agent skill for security risks before you install or use it. Powered by Tencent Zhuque Lab A.I.G (AI-Infra-Guard). 100% local static analysis — no file contents or credentials leave your device. Compatible with CodeBuddy, Cursor, Windsurf, Claude Code, OpenClaw and more. Triggers on: 这个 skill 安全吗, skill 安全扫描, 检查 skill 安全, audit skill, scan skill, check skill safety, analyze skill, inspect skill, verify skill, skill security, skill supply chain. Do NOT trigger for general agent usage, full system health checks, project debugging, or normal development.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Ftools-hub\u002Fcode-ide\u002Fskills-marketplace\u002Fskills\u002Fskill-scanner\u002FSKILL.md",[],[],{"skillNo":137,"name":138,"nameZh":6,"description":139,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":140,"sourceHtmlUrl":141,"categories":142,"keywords":143,"publishedAt":19},"01M7BSWGTCFW7F123S4BM4XY6W","skill-creator","Guide for creating effective skills. This skill should be used when users want to create a new skill (or update an existing skill) that extends agent capabilities with specialized knowledge, workflows, or tool integrations.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Ftools-hub\u002Fcode-ide\u002Fskills-marketplace\u002Fskills\u002Fskill-creator\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Ftools-hub\u002Fcode-ide\u002Fskills-marketplace\u002Fskills\u002Fskill-creator\u002FSKILL.md",[],[],{"skillNo":145,"name":146,"nameZh":6,"description":147,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":111,"licenseFileUrl":6,"sourceHtmlUrl":148,"categories":149,"keywords":150,"publishedAt":19},"01M7BSVV4DH8JK2ZMQSCW25VCD","shader-dev","Comprehensive GLSL shader techniques for creating stunning visual effects — ray marching, SDF modeling, fluid simulation, particle systems, procedural generation, lighting, post-processing, and more.","https:\u002F\u002Fgithub.com\u002FYYC-Cube\u002FYYC3-AI-Agent-Archive\u002Fblob\u002Fmain\u002Ftools-hub\u002Fcode-ide\u002Fskills-marketplace\u002Fskills\u002Fshader-dev\u002FSKILL.md",[],[]]