nv-generate-mr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNV-Generate-MR
NV-Generate-MR
Purpose
用途
- Used for generating synthetic body MRI volumes with NV-Generate-CTMR rflow-mr. Not for paired masks or production training data.
- Use the wrapper exactly as documented; do not replace the upstream entrypoint with a handwritten implementation.
- Do not write custom inference code for normal runs. The wrapper owns config staging, output paths, and validation.
- Manifest I/O: inputs are ; outputs are
model_config_overrideandsynthetic_mr_volumes.result_json
- 用于借助NV-Generate-CTMR rflow-mr生成合成身体MRI影像体积。不适用于配对掩码或生产训练数据。
- 严格按照文档说明使用包装器;请勿用手写实现替换上游入口点。
- 常规运行时请勿编写自定义推理代码。包装器负责配置暂存、输出路径和验证工作。
- 清单输入输出:输入为;输出为
model_config_override和synthetic_mr_volumes。result_json
Instructions
使用说明
- Read before changing arguments, side effects, or validation gates.
skill_manifest.yaml - Run through the documented command below; keep outputs under a caller-provided run directory.
scripts/run_mr.py - If a host agent exposes , use
run_script; otherwise run the Bash/Python command shown below.run_script("scripts/run_mr.py", args=[...]) - Emit a single bash code block, and keep the step in that same command — the runtime may be a fresh environment without
python -m pip install -r "$NV_GENERATE_ROOT/requirements.txt"/MONAI, so dropping the install fails withnibabel.ModuleNotFoundError - Do not add ,
rm, or any cleanup ofmkdir; the wrapper creates it. Use a fresh--output-dirinstead of deleting one.--output-dir - Check the emitted JSON and paired verifier guidance before treating the run as evidence.
- 在修改参数、副作用或验证门限前,请先阅读。
skill_manifest.yaml - 通过下方文档记录的命令运行;将输出保存在调用者提供的运行目录下。
scripts/run_mr.py - 如果宿主Agent暴露接口,请使用
run_script;否则运行下方所示的Bash/Python命令。run_script("scripts/run_mr.py", args=[...]) - 输出单个bash代码块,并将步骤保留在同一命令中——运行环境可能是未安装
python -m pip install -r "$NV_GENERATE_ROOT/requirements.txt"/MONAI的全新环境,省略安装步骤会导致nibabel错误。ModuleNotFoundError - 请勿添加、
rm或任何清理mkdir的操作;包装器会创建该目录。请使用全新的--output-dir而非删除已有目录。--output-dir - 在将运行结果作为依据前,请检查输出的JSON文件及配套验证器指南。
Available Scripts
可用脚本
| Script | Purpose | Arguments |
|---|---|---|
| Primary entrypoint declared by skill_manifest.yaml. | |
| 脚本 | 用途 | 参数 |
|---|---|---|
| | |
Prerequisites
前置条件
- Runtime requirements: GPU/CUDA when declared by the manifest; Python packages listed in .
runtime.side_effects.pip_packages - Side effects: writes generated outputs under the caller's , may cache model assets under
--output-dir, and may contact~/.cache/huggingface/orhttps://huggingface.coduring setup.https://github.com - Run commands from the repository root unless an existing section below says otherwise.
- 运行时要求:清单声明需要GPU/CUDA;需安装中列出的Python包。
runtime.side_effects.pip_packages - 副作用:会在调用者指定的下写入生成的输出,可能会在
--output-dir下缓存模型资产,设置过程中可能会连接~/.cache/huggingface/或https://huggingface.co。https://github.com - 除非下方已有章节另有说明,否则请从仓库根目录运行命令。
Limitations
限制
- This is a thin wrapper. Inference, sampling, and decoding are delegated entirely to NVIDIA-Medtech/NV-Generate-CTMR's . Do not modify code under $NV_GENERATE_ROOT or the repo-local fallback at .workbench_data/upstreams/NV-Generate-CTMR.
scripts.diff_model_infer - rflow-mr generates image-only synthetic MRI volumes. It does not emit paired segmentation masks.
- The upstream README recommends instead for brain MRI synthesis; use
rflow-mr-brainfor that path.skills/nv-generate-mr-brain - NV-Generate-MR weights are listed by upstream as NVIDIA Non-Commercial. Do not use outputs as production training data without legal and quality review.
- Not for clinical deployment, clinical interpretation, autonomous diagnosis, regulatory submission.
- 这是一个轻量包装器。推理、采样和解码操作完全委托给NVIDIA-Medtech/NV-Generate-CTMR的。请勿修改$NV_GENERATE_ROOT下的代码或本地仓库缓存路径.workbench_data/upstreams/NV-Generate-CTMR中的代码。
scripts.diff_model_infer - rflow-mr仅生成纯影像的合成MRI体积,不会输出配对的分割掩码。
- 上游README文档推荐使用进行脑部MRI合成;请通过
rflow-mr-brain路径使用该工具。skills/nv-generate-mr-brain - NV-Generate-MR权重被上游标记为NVIDIA非商用。未经法律和质量审核,请勿将输出用作生产训练数据。
- 不适用于临床部署、临床解读、自动诊断或监管申报。
Troubleshooting
故障排查
| Error | Cause | Fix |
|---|---|---|
| Missing dependency or import error | Runtime package drift from | Install the packages declared in the manifest or use the documented setup command. |
| Empty or schema-invalid output | Wrong input path, unsupported modality, or upstream failure. | Re-run with a known fixture and inspect the wrapper JSON plus stderr. |
| Validation gate failure | Output violated a declared engineering invariant. | Keep the failed evidence pack and use the gate message to repair inputs or wrapper code. |
Wraps the upstream
MR image-only generation workflow. The wrapper does not reimplement diffusion
sampling or autoencoder decoding. It stages config overrides, runs the
documented command for , then
summarizes the generated NIfTI volume.
NVIDIA-Medtech/NV-Generate-CTMRpython -m scripts.diff_model_inferrflow-mr| 错误 | 原因 | 修复方案 |
|---|---|---|
| 依赖缺失或导入错误 | 运行时包与 | 安装清单中声明的包或使用文档记录的设置命令。 |
| 输出为空或不符合架构规范 | 输入路径错误、模态不支持或上游执行失败 | 使用已知的测试用例重新运行,并检查包装器的JSON输出和标准错误信息。 |
| 验证门限失败 | 输出违反了已声明的工程约束 | 保留失败的证据包,并根据门限提示修复输入或包装器代码。 |
本工具封装了上游
的纯MRI影像生成工作流。包装器未重新实现扩散采样或自动编码器解码逻辑,仅负责配置覆盖的暂存、运行对应的文档命令,然后汇总生成的NIfTI体积信息。
NVIDIA-Medtech/NV-Generate-CTMRrflow-mrpython -m scripts.diff_model_inferExact Runnable Surface
可运行的精确命令
For user run commands in a fresh benchmark environment, use this setup plus
repo-root wrapper command exactly:
bash
export NV_GENERATE_ROOT="${NV_GENERATE_ROOT:-.workbench_data/upstreams/NV-Generate-CTMR}" && \
python -m pip install -r "$NV_GENERATE_ROOT/requirements.txt" && \
python skills/nv-generate-mr/scripts/run_mr.py PATH_TO_MR_CONFIG.json --output-dir OUT_DIR --modality mri_t1 --random-seed 0Do not invent , , , or commands. must be the user's supplied request path.
generate.shinfer.pyMedical AI Skills runpython -m nv_generate_mrPATH_TO_MR_CONFIG.json在全新的基准测试环境中运行用户命令时,请严格使用以下设置命令加上仓库根目录的包装器命令:
bash
export NV_GENERATE_ROOT="${NV_GENERATE_ROOT:-.workbench_data/upstreams/NV-Generate-CTMR}" && \
python -m pip install -r "$NV_GENERATE_ROOT/requirements.txt" && \
python skills/nv-generate-mr/scripts/run_mr.py PATH_TO_MR_CONFIG.json --output-dir OUT_DIR --modality mri_t1 --random-seed 0请勿自行创建、、或等命令。必须是用户提供的请求路径。
generate.shinfer.pyMedical AI Skills runpython -m nv_generate_mrPATH_TO_MR_CONFIG.jsonPreconditions
前置准备
Clone and install the upstream repo once. In this Medical AI Skills checkout, prefer
the repo-local cache path when it exists:
bash
mkdir -p .workbench_data/upstreams
test -d .workbench_data/upstreams/NV-Generate-CTMR/.git || \
git clone https://github.com/NVIDIA-Medtech/NV-Generate-CTMR.git \
.workbench_data/upstreams/NV-Generate-CTMR
export NV_GENERATE_ROOT=.workbench_data/upstreams/NV-Generate-CTMR
pip install -r "$NV_GENERATE_ROOT/requirements.txt"Download the MR weights:
bash
cd "$NV_GENERATE_ROOT"
python -m scripts.download_model_data --version rflow-mr --root_dir ./ --model_onlyRuntime needs an NVIDIA GPU with at least 16 GB VRAM. There is no CPU
fallback in the upstream path.
The wrapper also searches if
is unset or points at a stale clone.
.workbench_data/upstreams/NV-Generate-CTMRNV_GENERATE_ROOTFor agent-generated user run commands, use the command in Usage. Do not prepend
clone or model-download setup steps when the repo-local upstream cache already
exists. In a fresh Python environment, still include
before the wrapper unless
the active environment has already proven those imports are available; cached
weights do not imply cached Python packages. If setup requires , return to the Medical AI Skills repo before invoking
.
pip install -r "$NV_GENERATE_ROOT/requirements.txt"cd "$NV_GENERATE_ROOT"skills/nv-generate-mr/scripts/run_mr.py克隆并安装上游仓库一次。在本Medical AI Skills检出目录中,优先使用本地仓库缓存路径(如果存在):
bash
mkdir -p .workbench_data/upstreams
test -d .workbench_data/upstreams/NV-Generate-CTMR/.git || \
git clone https://github.com/NVIDIA-Medtech/NV-Generate-CTMR.git \
.workbench_data/upstreams/NV-Generate-CTMR
export NV_GENERATE_ROOT=.workbench_data/upstreams/NV-Generate-CTMR
pip install -r "$NV_GENERATE_ROOT/requirements.txt"下载MR权重:
bash
cd "$NV_GENERATE_ROOT"
python -m scripts.download_model_data --version rflow-mr --root_dir ./ --model_only运行时需要至少16GB显存的NVIDIA GPU。上游路径不支持CPU fallback。
如果未设置或指向过时的克隆版本,包装器也会搜索路径。
NV_GENERATE_ROOT.workbench_data/upstreams/NV-Generate-CTMR对于Agent生成的用户运行命令,请使用“用法”部分中的命令。当本地仓库的上游缓存已存在时,请勿添加克隆或模型下载的设置步骤。在全新的Python环境中,除非当前环境已确认相关导入可用,否则仍需在运行包装器前执行;缓存的权重并不意味着缓存了Python包。如果设置步骤需要,请在调用前返回Medical AI Skills仓库目录。
pip install -r "$NV_GENERATE_ROOT/requirements.txt"cd "$NV_GENERATE_ROOT"skills/nv-generate-mr/scripts/run_mr.pyUsage
用法
bash
export NV_GENERATE_ROOT="${NV_GENERATE_ROOT:-.workbench_data/upstreams/NV-Generate-CTMR}" && \
python -m pip install -r "$NV_GENERATE_ROOT/requirements.txt" && \
python skills/nv-generate-mr/scripts/run_mr.py \
PATH_TO_MR_CONFIG.json \
--output-dir runs/nv_generate_mr_demo \
--modality mri_t1 \
--random-seed 0Replace with the user's actual request/config path.
Do not copy the fixture path from this document unless the user explicitly
asked to run that fixture. If the user says "the request is at
", that exact path is the first positional
argument to .
PATH_TO_MR_CONFIG.jsonruns/.../default_mri_t1.jsonscripts/run_mr.pySupported rflow-mr modality names are , , , and
, matching the upstream MR image-generation guide. The upstream
README recommends instead when synthesizing brain images;
use for that path.
For FOV and setup details, see .
mrimri_t1mri_t2mri_flairrflow-mr-brainskills/nv-generate-mr-brainreferences/fov-and-downloads.mdThe fixture argument is a small JSON override for
. Pass to use the
upstream defaults plus the CLI modality and random seed. Common override keys
are , , , , and
.
configs/config_maisi_diff_model_rflow-mr.jsondefaultdimspacingnum_inference_stepscfg_guidance_scalemodalityEach run records the staged config, model inventory, upstream command, output
geometry, spacing, affine, intensity range, and non-constant / finite-data
checks. Output volumes are synthetic and are not safe as production training
data without independent review.
Not for clinical interpretation, production deployment, autonomous diagnosis,
or regulatory submission.
bash
export NV_GENERATE_ROOT="${NV_GENERATE_ROOT:-.workbench_data/upstreams/NV-Generate-CTMR}" && \
python -m pip install -r "$NV_GENERATE_ROOT/requirements.txt" && \
python skills/nv-generate-mr/scripts/run_mr.py \
PATH_TO_MR_CONFIG.json \
--output-dir runs/nv_generate_mr_demo \
--modality mri_t1 \
--random-seed 0将替换为用户实际的请求/配置路径。除非用户明确要求运行测试用例,否则请勿复制本文档中的测试用例路径。如果用户表示“请求路径为”,请将该精确路径作为的第一个位置参数。
PATH_TO_MR_CONFIG.jsonruns/.../default_mri_t1.jsonscripts/run_mr.pyrflow-mr支持的模态名称包括、、和,与上游MR影像生成指南一致。上游README文档推荐在合成脑部影像时使用;请通过路径使用该工具。关于FOV和设置细节,请参阅。
mrimri_t1mri_t2mri_flairrflow-mr-brainskills/nv-generate-mr-brainreferences/fov-and-downloads.md测试用例参数是对的小型JSON覆盖。传入将使用上游默认值加上CLI指定的模态和随机种子。常见的覆盖键包括、、、和。
configs/config_maisi_diff_model_rflow-mr.jsondefaultdimspacingnum_inference_stepscfg_guidance_scalemodality每次运行都会记录暂存的配置、模型清单、上游命令、输出几何结构、间距、仿射变换、强度范围以及非恒定/有限数据检查。生成的影像体积为合成数据,未经独立审核不得作为生产训练数据使用。
不适用于临床解读、生产部署、自动诊断或监管申报。