nv-segment-ctmr
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNV-Segment-CTMR
NV-Segment-CTMR
Purpose
用途
- Used for running NV-Segment-CTMR on CT or MRI NIfTI volumes and recording label-map evidence. Not for clinical interpretation.
- Use the wrapper exactly as documented; do not replace the upstream entrypoint with a handwritten implementation.
- Manifest I/O: inputs are ; outputs are
ct_or_mr_volumeandlabel_map.result_json
- 用于在CT或MRI NIfTI影像上运行NV-Segment-CTMR并记录标签映射证据。不用于临床解读。
- 严格按照文档说明使用该封装程序;请勿用手写实现替换上游入口点。
- 清单输入输出:输入为;输出为
ct_or_mr_volume和label_map。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_ctmr.py - If a host agent exposes , use
run_script; otherwise run the Bash/Python command shown below.run_script("scripts/run_ctmr.py", args=[...]) - Check the emitted JSON and paired verifier guidance before treating the run as evidence.
- 在修改参数、副作用或验证门之前,请先阅读。
skill_manifest.yaml - 通过以下文档记录的命令运行;将输出存储在调用者指定的运行目录下。
scripts/run_ctmr.py - 如果宿主Agent暴露接口,请使用
run_script;否则运行下方所示的Bash/Python命令。run_script("scripts/run_ctmr.py", args=[...]) - 在将运行结果视为有效证据之前,请检查生成的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 segmentation outputs under the caller's , may cache model assets under
--output-dir, and may contact~/.cache/huggingface/orhttps://github.comduring setup.https://huggingface.co - 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://github.com。https://huggingface.co - 除非下方现有章节另有说明,否则请从仓库根目录运行命令。
Limitations
局限性
- This is a thin wrapper. Inference, preprocessing, and postprocessing are delegated entirely to the upstream MONAI bundle under $NV_SEGMENT_CTMR_ROOT or the repo-local fallback at .workbench_data/upstreams/NV-Segment-CTMR/NV-Segment-CTMR.
- The default wrapper path runs automatic "segment everything" inference for CT_BODY, MRI_BODY, or MRI_BRAIN. MRI_BRAIN inputs must already follow the upstream brain preprocessing requirements.
- Label names are loaded from upstream configs when available. If a label dictionary is absent, the wrapper still records label IDs and marks only negative IDs as invalid.
- No clinical, diagnostic, regulatory, or treatment-planning claims.
- Not for clinical deployment, clinical interpretation, autonomous diagnosis, regulatory submission.
- 这是一个轻量封装程序。推理、预处理和后处理完全委托给位于$NV_SEGMENT_CTMR_ROOT的上游MONAI bundle,或仓库本地的备用路径.workbench_data/upstreams/NV-Segment-CTMR/NV-Segment-CTMR。
- 默认封装路径会针对CT_BODY、MRI_BODY或MRI_BRAIN自动执行“全分割”推理。MRI_BRAIN输入必须已符合上游脑部预处理要求。
- 标签名称会在可用时从上游配置加载。如果缺少标签字典,封装程序仍会记录标签ID,并仅将负ID标记为无效。
- 不提供临床、诊断、监管或治疗规划相关声明。
- 不用于临床部署、临床解读、自主诊断或监管申报。
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
CT/MRI segmentation bundle. The wrapper does not reimplement VISTA3D
inference. It shells out to the documented
entry point, then inspects the produced NIfTI label map.
NVIDIA-Medtech/NV-Segment-CTMRpython -m monai.bundle run| 错误 | 原因 | 修复方法 |
|---|---|---|
| 依赖缺失或导入错误 | 运行时包与 | 安装清单中声明的包,或使用文档记录的设置命令。 |
| 输出为空或不符合模式规范 | 输入路径错误、模态不支持或上游执行失败。 | 使用已知的测试用例重新运行,并检查封装程序的JSON输出及标准错误信息。 |
| 验证门执行失败 | 输出违反了已声明的工程约束。 | 保留失败的证据包,并使用验证门提示信息修复输入或封装程序代码。 |
该程序封装了上游的 CT/MRI分割bundle。封装程序未重新实现VISTA3D推理,而是调用文档记录的入口点,然后检查生成的NIfTI标签映射。
NVIDIA-Medtech/NV-Segment-CTMRpython -m monai.bundle runExact Runnable Surface
可运行命令规范
For CT body segmentation user runs and benchmark answers, use this
fresh-environment-safe repo-root command shape exactly:
bash
export NV_SEGMENT_CTMR_ROOT="${NV_SEGMENT_CTMR_ROOT:-.workbench_data/upstreams/NV-Segment-CTMR/NV-Segment-CTMR}" && \
python -m pip install "monai>=1.5,<1.6" "numpy<2" nibabel scipy typer PyYAML fire huggingface_hub pytorch-ignite einops && \
python skills/nv-segment-ctmr/scripts/run_ctmr.py PATH_TO_IMAGE.nii.gz --modality CT_BODY --output-dir OUT_DIRDo not invent , , or commands. must be the user's supplied input path.
For benchmark/user run answers, the bash block is invalid if it includes
, , ,
, , or any other command that
creates, downloads into, or moves files inside the shared upstream checkout.
python -m nv_segment_ctmrinfer.pyMedical AI Skills runPATH_TO_IMAGE.nii.gzmkdir -p .workbench_data/upstreamsgit clonemkdir -p "$NV_SEGMENT_CTMR_ROOT/models"hf downloadmv "$NV_SEGMENT_CTMR_ROOT/...对于CT体部分割的用户运行和基准测试,需严格使用以下适用于全新环境的仓库根目录命令格式:
bash
export NV_SEGMENT_CTMR_ROOT="${NV_SEGMENT_CTMR_ROOT:-.workbench_data/upstreams/NV-Segment-CTMR/NV-Segment-CTMR}" && \
python -m pip install "monai>=1.5,<1.6" "numpy<2" nibabel scipy typer PyYAML fire huggingface_hub pytorch-ignite einops && \
python skills/nv-segment-ctmr/scripts/run_ctmr.py PATH_TO_IMAGE.nii.gz --modality CT_BODY --output-dir OUT_DIR请勿自行创建、或等命令。必须是用户提供的输入路径。对于基准测试/用户运行结果,如果bash命令块包含、、、、或任何其他在共享上游检出目录内创建、下载或移动文件的命令,则该命令块无效。
python -m nv_segment_ctmrinfer.pyMedical AI Skills runPATH_TO_IMAGE.nii.gzmkdir -p .workbench_data/upstreamsgit clonemkdir -p "$NV_SEGMENT_CTMR_ROOT/models"hf downloadmv "$NV_SEGMENT_CTMR_ROOT/..."Preconditions
初始化设置
One-time maintainer setup only; do not include these commands in user answers
or benchmark commands. The benchmark environment already provides the
repo-local upstream cache and model files.
Clone and install the upstream bundle 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-Segment-CTMR/.git || \
git clone https://github.com/NVIDIA-Medtech/NV-Segment-CTMR.git \
.workbench_data/upstreams/NV-Segment-CTMR
export NV_SEGMENT_CTMR_ROOT=.workbench_data/upstreams/NV-Segment-CTMR/NV-Segment-CTMR
python -m pip install "monai>=1.5,<1.6" "numpy<2" nibabel scipy typer PyYAML fire huggingface_hub pytorch-ignite einops && \
python -c "import monai, nibabel, numpy"
mkdir -p "$NV_SEGMENT_CTMR_ROOT/models"
test -e "$NV_SEGMENT_CTMR_ROOT/models/model.pt" || \
hf download nvidia/NV-Segment-CTMR --local-dir "$NV_SEGMENT_CTMR_ROOT/models/"
test -e "$NV_SEGMENT_CTMR_ROOT/models/model.pt" || \
mv "$NV_SEGMENT_CTMR_ROOT/models/vista3d_pretrained_model/model.pt" \
"$NV_SEGMENT_CTMR_ROOT/models/model.pt"The wrapper also searches
if is unset or points at a stale clone.
.workbench_data/upstreams/NV-Segment-CTMR/NV-Segment-CTMRNV_SEGMENT_CTMR_ROOTFor agent-generated user run commands, use the command in Usage. Do not copy
the one-time Preconditions block into the answer: do not create or write under
, do not run , and do not move files in the
shared upstream checkout during a benchmark or user run. Do not prepend
in a Python 3.12
environment; the upstream requirements pin NumPy 1.24.4, which does not build
cleanly there. In a fresh Python environment, install the minimal compatible
runtime shown above (, , , , ,
, , , , ) before the
wrapper. Cached models do not imply cached Python packages.
$NV_SEGMENT_CTMR_ROOThf downloadpip install -r "$NV_SEGMENT_CTMR_ROOT/requirements.txt"monai>=1.5,<1.6numpy<2nibabelscipytyperPyYAMLfirehuggingface_hubpytorch-igniteeinopsRuntime needs an NVIDIA GPU with CUDA. The upstream bundle may import on
CPU-only hosts, but this skill is declared as CUDA-required because the
published workflow is a 3D CT/MRI foundation model inference path.
仅需一次性维护者设置;请勿将这些命令包含在用户答案或基准测试命令中。基准测试环境已提供仓库本地的上游缓存和模型文件。
克隆并安装上游bundle一次。在该Medical AI Skills检出目录中,当仓库本地缓存路径存在时,优先使用该路径:
bash
mkdir -p .workbench_data/upstreams
test -d .workbench_data/upstreams/NV-Segment-CTMR/.git || \
git clone https://github.com/NVIDIA-Medtech/NV-Segment-CTMR.git \
.workbench_data/upstreams/NV-Segment-CTMR
export NV_SEGMENT_CTMR_ROOT=.workbench_data/upstreams/NV-Segment-CTMR/NV-Segment-CTMR
python -m pip install "monai>=1.5,<1.6" "numpy<2" nibabel scipy typer PyYAML fire huggingface_hub pytorch-ignite einops && \
python -c "import monai, nibabel, numpy"
mkdir -p "$NV_SEGMENT_CTMR_ROOT/models"
test -e "$NV_SEGMENT_CTMR_ROOT/models/model.pt" || \
hf download nvidia/NV-Segment-CTMR --local-dir "$NV_SEGMENT_CTMR_ROOT/models/"
test -e "$NV_SEGMENT_CTMR_ROOT/models/model.pt" || \
mv "$NV_SEGMENT_CTMR_ROOT/models/vista3d_pretrained_model/model.pt" \
"$NV_SEGMENT_CTMR_ROOT/models/model.pt"如果未设置或指向已过期的克隆版本,封装程序也会搜索路径。
NV_SEGMENT_CTMR_ROOT.workbench_data/upstreams/NV-Segment-CTMR/NV-Segment-CTMR对于Agent生成的用户运行命令,请使用“使用方法”中的命令。请勿将一次性的“初始化设置”块复制到答案中:在基准测试或用户运行期间,请勿在下创建或写入内容,请勿运行,也请勿在共享上游检出目录内移动文件。在Python 3.12环境中,请勿添加命令;上游依赖要求固定NumPy 1.24.4,该版本在Python 3.12环境中无法正常构建。在全新Python环境中,请先安装上述列出的最小兼容运行时包(、、、、、、、、、),再运行封装程序。缓存的模型并不意味着缓存了Python包。
$NV_SEGMENT_CTMR_ROOThf downloadpip install -r "$NV_SEGMENT_CTMR_ROOT/requirements.txt"monai>=1.5,<1.6numpy<2nibabelscipytyperPyYAMLfirehuggingface_hubpytorch-igniteeinops运行时需要配备CUDA的NVIDIA GPU。上游bundle可能可在仅CPU的主机上导入,但该技能被声明为需要CUDA,因为已发布的工作流是3D CT/MRI基础模型推理路径。
Usage
使用方法
From Medical AI Skills repo root:
bash
export NV_SEGMENT_CTMR_ROOT="${NV_SEGMENT_CTMR_ROOT:-.workbench_data/upstreams/NV-Segment-CTMR/NV-Segment-CTMR}" && \
python -m pip install "monai>=1.5,<1.6" "numpy<2" nibabel scipy typer PyYAML fire huggingface_hub pytorch-ignite einops && \
python skills/nv-segment-ctmr/scripts/run_ctmr.py PATH_TO_IMAGE.nii.gz \
--modality CT_BODY \
--output-dir runs/nv_segment_ctmr_demoReplace with the user's actual input path. Do not copy
the example fixture path into a user run. If the user provides an explicit
input path under , that path must be the first positional argument to
.
PATH_TO_IMAGE.nii.gzruns/scripts/run_ctmr.pySupported automatic segmentation modalities are , , and
. For , the upstream README requires brain-specific
preprocessing before bundle inference; pass an already preprocessed image to
this wrapper.
CT_BODYMRI_BODYMRI_BRAINMRI_BRAINPass to request specific upstream class IDs instead
of only the modality-level "segment everything" set. The evidence output
records input geometry, output mask path, observed label IDs, unexpected
labels, per-class voxel counts, per-class physical volumes from the mask
header spacing, runtime, upstream command, model inventory, and geometry
checks.
--label-prompts "3,14"Pass to record a reference label-map path under
. The skill does not compute Dice; that is the
paired verifier's job.
--ground-truth PATHinput.ground_truth_pathAnatomy plausibility and optional per-class Dice/IoU against the recorded
ground truth can be checked by for
CT-body outputs.
verifiers/ct_segmentation_quality_v1Not for clinical interpretation, production deployment, autonomous diagnosis,
or regulatory submission.
从Medical AI Skills仓库根目录运行:
bash
export NV_SEGMENT_CTMR_ROOT="${NV_SEGMENT_CTMR_ROOT:-.workbench_data/upstreams/NV-Segment-CTMR/NV-Segment-CTMR}" && \
python -m pip install "monai>=1.5,<1.6" "numpy<2" nibabel scipy typer PyYAML fire huggingface_hub pytorch-ignite einops && \
python skills/nv-segment-ctmr/scripts/run_ctmr.py PATH_TO_IMAGE.nii.gz \
--modality CT_BODY \
--output-dir runs/nv_segment_ctmr_demo将替换为用户实际的输入路径。请勿将示例测试用例路径复制到用户运行命令中。如果用户提供下的明确输入路径,该路径必须作为的第一个位置参数。
PATH_TO_IMAGE.nii.gzruns/scripts/run_ctmr.py支持的自动分割模态包括、和。对于,上游README要求在bundle推理前进行脑部特定预处理;请将已预处理的图像传入该封装程序。
CT_BODYMRI_BODYMRI_BRAINMRI_BRAIN传递以请求特定的上游类别ID,而不仅仅是模态级别的“全分割”集合。证据输出会记录输入几何信息、输出掩码路径、观测到的标签ID、意外标签、每类体素计数、来自掩码头间距的每类物理体积、运行时间、上游命令、模型清单和几何检查结果。
--label-prompts "3,14"传递以在下记录参考标签映射路径。该技能不计算Dice系数;这是配套验证器的工作。
--ground-truth PATHinput.ground_truth_path对于CT体部输出,可通过检查解剖结构合理性及可选的每类Dice/IoU(与记录的真实标签对比)。
verifiers/ct_segmentation_quality_v1不用于临床解读、生产部署、自主诊断或监管申报。