Update download link - #7
Conversation
Signed-off-by: heyufan <heyufan1995@gmail.com>
Greptile SummaryThis PR updates the model download method from Key changes:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User
participant Shell as run_brain_segmentation.sh
participant SynthStrip
participant Preprocess as preprocess.py
participant MONAI as monai.bundle run
participant Revert as revert_preprocess.py
User->>Shell: --input brain_t1.nii.gz --output_dir results/
Shell->>SynthStrip: skull strip input → temp/skull_stripped.nii.gz
SynthStrip-->>Shell: skull_stripped.nii.gz
Shell->>Preprocess: align to LUMIR template → temp/preprocessed.nii.gz
Preprocess-->>Shell: preprocessed.nii.gz + meta.json
Shell->>MONAI: run inference --output_dir results/ (NEW)
Note over MONAI: Previously output_dir was not passed,<br/>causing segmentation to write to wrong location
MONAI-->>Shell: results/preprocessed/preprocessed_trans.nii.gz
Shell->>Revert: revert to original space → results/basename_trans.nii.gz
Revert-->>Shell: final_output
Shell-->>User: Segmentation complete
Last reviewed commit: 7dc37ae |
| 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 |
There was a problem hiding this comment.
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:
| rmdir NV-Segment-CT/models/vista3d_pretrained_model | |
| rm -rf NV-Segment-CT/models/vista3d_pretrained_model |
| # 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 |
There was a problem hiding this comment.
"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:
| # 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 |
| # 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 |
There was a problem hiding this comment.
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:
| rmdir NV-Segment-CTMR/models/vista3d_pretrained_model | |
| rm -rf NV-Segment-CTMR/models/vista3d_pretrained_model |
No description provided.