Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion NV-Segment-CT/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ pip install -r requirements.txt;
cd ..;
mkdir NV-Segment-CT/models;
# download from huggingface link
wget -O NV-Segment-CT/models/model.pt https://huggingface.co/nvidia/NV-Segment-CT/resolve/main/vista3d_pretrained_model/model.pt
hf download nvidia/NV-Segment-CT vista3d_pretrained_model/model.pt --local-dir NV-Segment-CT/models/ && \
mv NV-Segment-CT/models/vista3d_pretrained_model/model.pt NV-Segment-CT/models/model.pt && \
rmdir NV-Segment-CT/models/vista3d_pretrained_model

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rmdir may fail if extra files are present

rmdir only succeeds on empty directories. Depending on the version of huggingface_hub, the --local-dir download may also create additional metadata files (e.g., .gitattributes, lock files) inside vista3d_pretrained_model/, causing rmdir to fail silently (or halt the script with set -e). Using rm -rf would be more robust:

Suggested change
rmdir NV-Segment-CT/models/vista3d_pretrained_model
rm -rf NV-Segment-CT/models/vista3d_pretrained_model

```

## 1.1 **VISTA3D-CT** [[Github]](https://github.com/NVIDIA-Medtech/NV-Segment-CTMR/tree/main/NV-Segment-CT) [[Huggingface]](https://huggingface.co/nvidia/NV-Segment-CT)
Expand Down
1 change: 1 addition & 0 deletions NV-Segment-CT/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ timm
pytorch-ignite
tensorboardX
mlflow
huggingface_hub
2 changes: 2 additions & 0 deletions NV-Segment-CTMR/brain_t1_preprocess/run_brain_segmentation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,11 @@ process_single_file() {
# Step 3: Segment the brain
echo -e "${YELLOW}Step 3/4: Running segmentation...${NC}"
cd "$BUNDLE_ROOT"
# Override output_dir in config to use our output_dir so segmentation saves to the right place
python -m monai.bundle run \
--config_file configs/inference.json \
--input_dict "{'image':'$preprocess_tmp'}" \
--output_dir "$output_dir" \
--modality "$MODALITY" || {
echo -e "${RED}Error: Segmentation failed${NC}" >&2
[[ "$KEEP_TEMP" == "false" ]] && rm -rf "$temp_dir"
Expand Down
5 changes: 4 additions & 1 deletion NV-Segment-CTMR/docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ pip install -r requirements.txt
# Create models directory and download pretrained model
cd ..
mkdir -p NV-Segment-CTMR/models
wget -O NV-Segment-CTMR/models/model.pt https://huggingface.co/nvidia/NV-Segment-CTMR/resolve/main/vista3d_pretrained_model/model.pt
# Option 1: Download using hf and move to expected location
hf download nvidia/NV-Segment-CTMR vista3d_pretrained_model/model.pt --local-dir NV-Segment-CTMR/models/ && \
mv NV-Segment-CTMR/models/vista3d_pretrained_model/model.pt NV-Segment-CTMR/models/model.pt && \
rmdir NV-Segment-CTMR/models/vista3d_pretrained_model
Comment on lines +28 to +31

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Option 1" label without a corresponding "Option 2"

The comment labels this step as Option 1: Download using hf and move to expected location, but there is no Option 2 in the instructions. This could leave users confused about whether there is an alternative method. If a second option (e.g., wget or huggingface-cli) was intentionally removed, the Option 1: label should be dropped:

Suggested change
# Option 1: Download using hf and move to expected location
hf download nvidia/NV-Segment-CTMR vista3d_pretrained_model/model.pt --local-dir NV-Segment-CTMR/models/ && \
mv NV-Segment-CTMR/models/vista3d_pretrained_model/model.pt NV-Segment-CTMR/models/model.pt && \
rmdir NV-Segment-CTMR/models/vista3d_pretrained_model
# Download using hf and move to expected location
hf download nvidia/NV-Segment-CTMR vista3d_pretrained_model/model.pt --local-dir NV-Segment-CTMR/models/ && \
mv NV-Segment-CTMR/models/vista3d_pretrained_model/model.pt NV-Segment-CTMR/models/model.pt && \
rmdir NV-Segment-CTMR/models/vista3d_pretrained_model

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rmdir may fail if extra files are present

Same concern as in NV-Segment-CT/docs/README.md: rmdir is not idempotent and will fail if huggingface_hub's download writes any extra files (metadata, lock files, .gitattributes) into the subdirectory. Prefer rm -rf for reliability:

Suggested change
rmdir NV-Segment-CTMR/models/vista3d_pretrained_model
rm -rf NV-Segment-CTMR/models/vista3d_pretrained_model

```

## Automatic Segmentation (support multi-gpu batch processing)
Expand Down
Binary file added NV-Segment-CTMR/docs/ctmr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion NV-Segment-CTMR/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Pillow==10.4.0
PyYAML==6.0.2
scipy
scikit-image==0.24.0
torch==2.0.1
torch==2.1.2
torchvision==0.16.2
tqdm==4.66.2
tensorboard==2.13.0
einops==0.6.1
Expand All @@ -16,3 +17,9 @@ timm
pytorch-ignite
tensorboardX
mlflow
pymedio
SimpleITK
pydicom
statsmodels
antspyx
huggingface_hub
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Both models follow the MONAI bundle architecture.

| Feature | NV-Segment-CT | NV-Segment-CTMR |
|---------|---------------|-----------------|
| **Anatomical Classes** | 132 classes | 345+ classes |
| **Anatomical Classes** | [132 classes (7 types of tumors)](NV-Segment-CT/configs/label_dict.json) | [345+ classes](NV-Segment-CTMR/configs/label_dict.json) |
| **Modalities** | CT only | CT + MRI (body & brain) |
| **Segmentation Type** | Automatic + Interactive (point-click) | Automatic only |
| **Model Weights** | [NV-Segment-CT on HuggingFace](https://huggingface.co/nvidia/NV-Segment-CT) | [NV-Segment-CTMR on HuggingFace](https://huggingface.co/nvidia/NV-Segment-CTMR) |
Expand All @@ -25,6 +25,8 @@ Both models follow the MONAI bundle architecture.
- out-of-the-box automatic segmentation on 3D CT scans
- share the same architecture with VISTA3D-CT model but we only trained the automatic segmentation branch with larger CT and MRI datasets.

![CTMR](./NV-Segment-CTMR/docs/ctmr.png)

## Performance on held-out test set

![Benchmark CT](./NV-Segment-CTMR/docs/benchmarkct.png) ![Benchmark MR](./NV-Segment-CTMR/docs/benchmarkmr.png)
Expand Down
Loading