panseg 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- panseg-0.1.0/.github/workflows/ci.yml +63 -0
- panseg-0.1.0/.gitignore +59 -0
- panseg-0.1.0/.python-version +1 -0
- panseg-0.1.0/Makefile +109 -0
- panseg-0.1.0/PKG-INFO +244 -0
- panseg-0.1.0/README.md +209 -0
- panseg-0.1.0/apps/eval_viewer.py +144 -0
- panseg-0.1.0/comp3888-capstone-panseg-miniset/README.md +82 -0
- panseg-0.1.0/comp3888-capstone-panseg-miniset/metadata.csv +7 -0
- panseg-0.1.0/dataset_generation/configs/ct_pancreas.yaml +16 -0
- panseg-0.1.0/dataset_generation/configs/ct_pancreas_70_tumour_inc.yaml +16 -0
- panseg-0.1.0/dataset_generation/configs/ct_pancreas_amos.yaml +16 -0
- panseg-0.1.0/dataset_generation/configs/ct_pancreas_loss.yaml +16 -0
- panseg-0.1.0/dataset_generation/configs/ct_pancreas_msd.yaml +16 -0
- panseg-0.1.0/dataset_generation/configs/default.yaml +43 -0
- panseg-0.1.0/dataset_generation/configs/mri_pancreas.yaml +16 -0
- panseg-0.1.0/dataset_generation/configs/mri_pancreas_70_tumour_inc.yaml +16 -0
- panseg-0.1.0/dataset_generation/configs/mri_pancreas_amos.yaml +16 -0
- panseg-0.1.0/dataset_generation/configs/mri_pancreas_amos_panseg_t1.yaml +16 -0
- panseg-0.1.0/dataset_generation/configs/mri_pancreas_amos_panseg_t2.yaml +16 -0
- panseg-0.1.0/dataset_generation/configs/mri_pancreas_loss.yaml +16 -0
- panseg-0.1.0/dataset_generation/configs/mri_pancreas_panseg_t1.yaml +16 -0
- panseg-0.1.0/dataset_generation/configs/mri_pancreas_panseg_t2.yaml +16 -0
- panseg-0.1.0/dataset_generation/configs/mri_pancreas_pansegs.yaml +16 -0
- panseg-0.1.0/dataset_generation/configs/quick_ct.yaml +16 -0
- panseg-0.1.0/dataset_generation/dataset_gen.py +474 -0
- panseg-0.1.0/datasets/README.md +95 -0
- panseg-0.1.0/datasets/download_datasets +85 -0
- panseg-0.1.0/datasets/view_amos.py +70 -0
- panseg-0.1.0/datasets/view_msd_pancreas.py +49 -0
- panseg-0.1.0/datasets/view_panseg.py +49 -0
- panseg-0.1.0/datasets/viewer.py +252 -0
- panseg-0.1.0/docs/annealing_evaluation_summary.md +181 -0
- panseg-0.1.0/docs/baseline_evaluation_summary.md +70 -0
- panseg-0.1.0/docs/c2b_aggressive_evaluation_summary.md +73 -0
- panseg-0.1.0/docs/dataset_combination_evaluation_summary.md +124 -0
- panseg-0.1.0/docs/group_contract.md +5 -0
- panseg-0.1.0/docs/minutes.md +25 -0
- panseg-0.1.0/docs/overall_evaluation_summary.md +127 -0
- panseg-0.1.0/docs/project_reports.md +32 -0
- panseg-0.1.0/docs/standardized_losses_evaluation_summary.md +124 -0
- panseg-0.1.0/docs/xp_summary.md +40 -0
- panseg-0.1.0/install.sh +35 -0
- panseg-0.1.0/main.py +6 -0
- panseg-0.1.0/models.yaml +26 -0
- panseg-0.1.0/panseg/artifacts.py +109 -0
- panseg-0.1.0/panseg/cli.py +176 -0
- panseg-0.1.0/panseg/constants.py +9 -0
- panseg-0.1.0/panseg/datasets.py +162 -0
- panseg-0.1.0/panseg/infer.py +298 -0
- panseg-0.1.0/panseg/metrics.py +105 -0
- panseg-0.1.0/panseg/models/__init__.py +0 -0
- panseg-0.1.0/panseg/models/common.py +81 -0
- panseg-0.1.0/panseg/models/monai_dints.py +217 -0
- panseg-0.1.0/panseg/models/mrsegmentator.py +86 -0
- panseg-0.1.0/panseg/models/nnunet.py +374 -0
- panseg-0.1.0/panseg/models/totalseg.py +84 -0
- panseg-0.1.0/panseg/pansegai.py +81 -0
- panseg-0.1.0/panseg/pipeline.py +178 -0
- panseg-0.1.0/panseg/utils.py +157 -0
- panseg-0.1.0/panseg/viewer.py +32 -0
- panseg-0.1.0/phase_1/monai_dints_demo.py +42 -0
- panseg-0.1.0/phase_1/mrsegmentator_demo.py +77 -0
- panseg-0.1.0/phase_1/totalseg_demo.py +33 -0
- panseg-0.1.0/phase_2/models/.gitignore +3 -0
- panseg-0.1.0/phase_2/models/00_setup.sh +70 -0
- panseg-0.1.0/phase_2/models/01_convert.sh +14 -0
- panseg-0.1.0/phase_2/models/02_preprocess.sh +40 -0
- panseg-0.1.0/phase_2/models/03_train.sh +59 -0
- panseg-0.1.0/phase_2/models/04_evaluate.sh +55 -0
- panseg-0.1.0/phase_2/models/05_plots.sh +14 -0
- panseg-0.1.0/phase_2/models/06_panseg_eval.sh +129 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas.yaml +27 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_amos.yaml +18 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_anneal_bnd_late.yaml +29 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_anneal_c2b.yaml +34 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_anneal_c2b_aggressive.yaml +33 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_anneal_focal.yaml +28 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_anneal_peak.yaml +28 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_anneal_rev.yaml +31 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_anneal_static_mix.yaml +27 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_anneal_vol_late.yaml +29 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_boundary.yaml +26 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_centre.yaml +26 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_fullres.yaml +27 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_harsh.yaml +27 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_msd.yaml +18 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_standardized_boundary.yaml +22 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_standardized_centre.yaml +22 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_standardized_fullres.yaml +23 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_standardized_harsh.yaml +22 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_standardized_volume.yaml +23 -0
- panseg-0.1.0/phase_2/models/configs/ct_pancreas_volume.yaml +23 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas.yaml +27 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_amos.yaml +22 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_amos_panseg_t1.yaml +22 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_amos_panseg_t2.yaml +22 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_anneal_bnd_late.yaml +29 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_anneal_c2b.yaml +34 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_anneal_c2b_aggressive.yaml +33 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_anneal_focal.yaml +28 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_anneal_peak.yaml +28 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_anneal_rev.yaml +31 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_anneal_static_mix.yaml +27 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_anneal_vol_late.yaml +29 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_boundary.yaml +26 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_centre.yaml +26 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_fullres.yaml +27 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_harsh.yaml +27 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_panseg_t1.yaml +22 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_panseg_t2.yaml +22 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_pansegs.yaml +22 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_standardized_boundary.yaml +22 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_standardized_centre.yaml +22 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_standardized_fullres.yaml +22 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_standardized_harsh.yaml +22 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_standardized_volume.yaml +23 -0
- panseg-0.1.0/phase_2/models/configs/mri_pancreas_volume.yaml +26 -0
- panseg-0.1.0/phase_2/models/configs/quick_ct.yaml +85 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/README.md +71 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/boundary_late/amos-ct-pancreas_cases.csv +46 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/boundary_late/msd-pancreas_cases.csv +43 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/boundary_late/summary.md +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/boundary_late/summary.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/c2b/amos-ct-pancreas_cases.csv +46 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/c2b/msd-pancreas_cases.csv +43 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/c2b/summary.md +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/c2b/summary.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/c2b_aggressive/amos-ct-pancreas_cases.csv +46 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/c2b_aggressive/msd-pancreas_cases.csv +43 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/c2b_aggressive/summary.md +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/c2b_aggressive/summary.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/focal/amos-ct-pancreas_cases.csv +46 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/focal/msd-pancreas_cases.csv +43 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/focal/summary.md +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/focal/summary.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/peak/amos-ct-pancreas_cases.csv +46 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/peak/msd-pancreas_cases.csv +43 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/peak/summary.md +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/peak/summary.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/reverse/amos-ct-pancreas_cases.csv +46 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/reverse/msd-pancreas_cases.csv +43 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/reverse/summary.md +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/reverse/summary.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/static_mix/amos-ct-pancreas_cases.csv +46 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/static_mix/msd-pancreas_cases.csv +43 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/static_mix/summary.md +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/static_mix/summary.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/volume_late/amos-ct-pancreas_cases.csv +46 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/volume_late/msd-pancreas_cases.csv +43 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/volume_late/summary.md +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/ct/volume_late/summary.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/manifest.tsv +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/boundary_late/amos-pancreas_cases.csv +10 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/boundary_late/panseg-t1-pancreas_cases.csv +59 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/boundary_late/panseg-t2-pancreas_cases.csv +58 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/boundary_late/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/boundary_late/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/c2b/amos-pancreas_cases.csv +10 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/c2b/panseg-t1-pancreas_cases.csv +59 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/c2b/panseg-t2-pancreas_cases.csv +58 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/c2b/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/c2b/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/c2b_aggressive/amos-pancreas_cases.csv +10 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/c2b_aggressive/panseg-t1-pancreas_cases.csv +59 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/c2b_aggressive/panseg-t2-pancreas_cases.csv +58 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/c2b_aggressive/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/c2b_aggressive/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/focal/amos-pancreas_cases.csv +10 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/focal/panseg-t1-pancreas_cases.csv +59 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/focal/panseg-t2-pancreas_cases.csv +58 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/focal/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/focal/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/peak/amos-pancreas_cases.csv +10 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/peak/panseg-t1-pancreas_cases.csv +59 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/peak/panseg-t2-pancreas_cases.csv +58 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/peak/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/peak/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/reverse/amos-pancreas_cases.csv +10 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/reverse/panseg-t1-pancreas_cases.csv +59 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/reverse/panseg-t2-pancreas_cases.csv +58 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/reverse/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/reverse/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/static_mix/amos-pancreas_cases.csv +10 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/static_mix/panseg-t1-pancreas_cases.csv +59 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/static_mix/panseg-t2-pancreas_cases.csv +58 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/static_mix/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/static_mix/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/volume_late/amos-pancreas_cases.csv +10 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/volume_late/panseg-t1-pancreas_cases.csv +59 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/volume_late/panseg-t2-pancreas_cases.csv +58 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/volume_late/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/annealing/mri/volume_late/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/README.md +43 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/ct/dints/amos-ct-pancreas_cases.csv +46 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/ct/dints/msd-pancreas_cases.csv +43 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/ct/dints/summary.md +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/ct/dints/summary.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/ct/totalseg/amos-ct-pancreas_cases.csv +46 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/ct/totalseg/msd-pancreas_cases.csv +43 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/ct/totalseg/summary.md +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/ct/totalseg/summary.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/manifest.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/mri/mrseg/amos-pancreas_cases.csv +10 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/mri/mrseg/panseg-t1-pancreas_cases.csv +59 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/mri/mrseg/panseg-t2-pancreas_cases.csv +58 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/mri/mrseg/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/mri/mrseg/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/mri/totalseg/amos-pancreas_cases.csv +10 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/mri/totalseg/panseg-t1-pancreas_cases.csv +59 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/mri/totalseg/panseg-t2-pancreas_cases.csv +58 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/mri/totalseg/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/baselines/mri/totalseg/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/README.md +43 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/ct/all_sources/amos-ct-pancreas_cases.csv +16 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/ct/all_sources/msd-pancreas_cases.csv +15 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/ct/all_sources/summary.md +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/ct/all_sources/summary.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/ct/amos_only/amos-ct-pancreas_cases.csv +16 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/ct/amos_only/msd-pancreas_cases.csv +15 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/ct/amos_only/summary.md +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/ct/amos_only/summary.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/ct/msd_only/amos-ct-pancreas_cases.csv +16 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/ct/msd_only/msd-pancreas_cases.csv +15 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/ct/msd_only/summary.md +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/ct/msd_only/summary.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/manifest.tsv +11 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/all_sources/amos-pancreas_cases.csv +4 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/all_sources/panseg-t1-pancreas_cases.csv +20 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/all_sources/panseg-t2-pancreas_cases.csv +20 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/all_sources/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/all_sources/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/amos_only/amos-pancreas_cases.csv +4 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/amos_only/panseg-t1-pancreas_cases.csv +20 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/amos_only/panseg-t2-pancreas_cases.csv +20 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/amos_only/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/amos_only/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/amos_panseg_t1/amos-pancreas_cases.csv +4 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/amos_panseg_t1/panseg-t1-pancreas_cases.csv +20 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/amos_panseg_t1/panseg-t2-pancreas_cases.csv +20 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/amos_panseg_t1/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/amos_panseg_t1/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/amos_panseg_t2/amos-pancreas_cases.csv +4 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/amos_panseg_t2/panseg-t1-pancreas_cases.csv +20 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/amos_panseg_t2/panseg-t2-pancreas_cases.csv +20 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/amos_panseg_t2/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/amos_panseg_t2/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/panseg_t1_only/amos-pancreas_cases.csv +4 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/panseg_t1_only/panseg-t1-pancreas_cases.csv +20 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/panseg_t1_only/panseg-t2-pancreas_cases.csv +20 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/panseg_t1_only/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/panseg_t1_only/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/panseg_t1_t2/amos-pancreas_cases.csv +4 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/panseg_t1_t2/panseg-t1-pancreas_cases.csv +20 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/panseg_t1_t2/panseg-t2-pancreas_cases.csv +20 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/panseg_t1_t2/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/panseg_t1_t2/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/panseg_t2_only/amos-pancreas_cases.csv +4 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/panseg_t2_only/panseg-t1-pancreas_cases.csv +20 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/panseg_t2_only/panseg-t2-pancreas_cases.csv +20 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/panseg_t2_only/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/dataset_combinations/mri/panseg_t2_only/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/README.md +73 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/ct/boundary/amos-ct-pancreas_cases.csv +46 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/ct/boundary/msd-pancreas_cases.csv +43 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/ct/boundary/summary.md +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/ct/boundary/summary.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/ct/centre/amos-ct-pancreas_cases.csv +46 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/ct/centre/msd-pancreas_cases.csv +43 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/ct/centre/summary.md +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/ct/centre/summary.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/ct/fullres/amos-ct-pancreas_cases.csv +46 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/ct/fullres/msd-pancreas_cases.csv +43 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/ct/fullres/summary.md +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/ct/fullres/summary.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/ct/harsh/amos-ct-pancreas_cases.csv +46 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/ct/harsh/msd-pancreas_cases.csv +43 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/ct/harsh/summary.md +17 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/ct/harsh/summary.tsv +5 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/manifest.tsv +9 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/boundary/amos-pancreas_cases.csv +10 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/boundary/panseg-t1-pancreas_cases.csv +59 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/boundary/panseg-t2-pancreas_cases.csv +58 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/boundary/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/boundary/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/centre/amos-pancreas_cases.csv +10 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/centre/panseg-t1-pancreas_cases.csv +59 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/centre/panseg-t2-pancreas_cases.csv +58 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/centre/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/centre/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/fullres/amos-pancreas_cases.csv +10 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/fullres/panseg-t1-pancreas_cases.csv +59 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/fullres/panseg-t2-pancreas_cases.csv +58 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/fullres/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/fullres/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/harsh/amos-pancreas_cases.csv +10 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/harsh/panseg-t1-pancreas_cases.csv +59 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/harsh/panseg-t2-pancreas_cases.csv +58 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/harsh/summary.md +18 -0
- panseg-0.1.0/phase_2/models/evaluation_results/standardized_losses/mri/harsh/summary.tsv +6 -0
- panseg-0.1.0/phase_2/models/lib/build_shared_test_manifest.py +55 -0
- panseg-0.1.0/phase_2/models/lib/gen_trainer.py +293 -0
- panseg-0.1.0/phase_2/models/lib/list_panseg_eval_datasets.py +53 -0
- panseg-0.1.0/phase_2/models/lib/loss_spec.py +109 -0
- panseg-0.1.0/phase_2/models/lib/losses.py +641 -0
- panseg-0.1.0/phase_2/models/lib/patch_plans.py +87 -0
- panseg-0.1.0/phase_2/models/lib/plot_from_csv.py +271 -0
- panseg-0.1.0/phase_2/models/lib/read_config.py +196 -0
- panseg-0.1.0/phase_2/models/lib/report_metrics.py +94 -0
- panseg-0.1.0/phase_2/models/lib/run_chunked_panseg_eval.py +199 -0
- panseg-0.1.0/phase_2/models/lib/schedules.py +194 -0
- panseg-0.1.0/phase_2/models/lib/selftest_losses.py +120 -0
- panseg-0.1.0/phase_2/models/lib/summarize_panseg_evals.py +244 -0
- panseg-0.1.0/phase_2/models/nnunet_env.sh +98 -0
- panseg-0.1.0/phase_2/models/parquet_to_nnunet.py +213 -0
- panseg-0.1.0/phase_2/models/run_all.sh +14 -0
- panseg-0.1.0/phase_2/models/run_all_eval_suites.sh +13 -0
- panseg-0.1.0/phase_2/models/run_anneal_all.sh +23 -0
- panseg-0.1.0/phase_2/models/run_anneal_eval_all.sh +26 -0
- panseg-0.1.0/phase_2/models/run_baseline_eval_all.sh +137 -0
- panseg-0.1.0/phase_2/models/run_c2b_aggressive_all.sh +24 -0
- panseg-0.1.0/phase_2/models/run_dataset_comb_eval_all.sh +61 -0
- panseg-0.1.0/phase_2/models/run_standardized_losses_all.sh +23 -0
- panseg-0.1.0/phase_2/models/run_standardized_losses_eval_all.sh +27 -0
- panseg-0.1.0/pyproject.toml +129 -0
- panseg-0.1.0/scripts/make_panseg_miniset.py +235 -0
- panseg-0.1.0/tests/__init__.py +1 -0
- panseg-0.1.0/tests/code/__init__.py +1 -0
- panseg-0.1.0/tests/code/test_artifacts.py +195 -0
- panseg-0.1.0/tests/code/test_common.py +107 -0
- panseg-0.1.0/tests/code/test_datasets.py +344 -0
- panseg-0.1.0/tests/code/test_infer.py +253 -0
- panseg-0.1.0/tests/code/test_loss_spec.py +140 -0
- panseg-0.1.0/tests/code/test_monai_dints.py +109 -0
- panseg-0.1.0/tests/code/test_nnunet.py +196 -0
- panseg-0.1.0/tests/code/test_pipeline.py +122 -0
- panseg-0.1.0/tests/code/test_utils.py +97 -0
- panseg-0.1.0/tests/metrics/__init__.py +1 -0
- panseg-0.1.0/tests/metrics/test_eval_summary.py +84 -0
- panseg-0.1.0/tests/metrics/test_metrics.py +221 -0
- panseg-0.1.0/trained_model_evals.mk +38 -0
- panseg-0.1.0/uv.lock +5760 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
concurrency:
|
|
10
|
+
group: ci-${{ github.workflow }}-${{ github.ref }}
|
|
11
|
+
cancel-in-progress: true
|
|
12
|
+
|
|
13
|
+
jobs:
|
|
14
|
+
test:
|
|
15
|
+
name: Tests (Python ${{ matrix.python-version }})
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
timeout-minutes: 60
|
|
18
|
+
strategy:
|
|
19
|
+
fail-fast: false
|
|
20
|
+
matrix:
|
|
21
|
+
python-version: ["3.13"]
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- name: Check out repository
|
|
25
|
+
uses: actions/checkout@v4
|
|
26
|
+
|
|
27
|
+
- name: Install uv
|
|
28
|
+
uses: astral-sh/setup-uv@v10.3.0
|
|
29
|
+
with:
|
|
30
|
+
enable-cache: true
|
|
31
|
+
python-version: ${{ matrix.python-version }}
|
|
32
|
+
|
|
33
|
+
# CPU wheels only: skip cuda/xpu extras (they conflict and need GPUs).
|
|
34
|
+
# Install monai so DiNTS adapter tests run instead of importorskip.
|
|
35
|
+
# Datasets are not required — unit tests use tmp_path / mocks.
|
|
36
|
+
- name: Sync dependencies
|
|
37
|
+
run: uv sync --locked --group dev --extra monai
|
|
38
|
+
|
|
39
|
+
- name: Run tests with coverage
|
|
40
|
+
run: |
|
|
41
|
+
uv run pytest tests/ \
|
|
42
|
+
--cov-report=html:htmlcov \
|
|
43
|
+
--junitxml=pytest-report.xml
|
|
44
|
+
|
|
45
|
+
- name: Write coverage summary
|
|
46
|
+
if: always()
|
|
47
|
+
run: |
|
|
48
|
+
{
|
|
49
|
+
echo "## Coverage"
|
|
50
|
+
echo
|
|
51
|
+
uv run coverage report --format=markdown || uv run coverage report || true
|
|
52
|
+
} >> "$GITHUB_STEP_SUMMARY"
|
|
53
|
+
|
|
54
|
+
- name: Upload coverage artifacts
|
|
55
|
+
if: always()
|
|
56
|
+
uses: actions/upload-artifact@v4
|
|
57
|
+
with:
|
|
58
|
+
name: coverage-py${{ matrix.python-version }}
|
|
59
|
+
path: |
|
|
60
|
+
coverage.xml
|
|
61
|
+
htmlcov/
|
|
62
|
+
pytest-report.xml
|
|
63
|
+
if-no-files-found: warn
|
panseg-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
*.png
|
|
2
|
+
*.jpg
|
|
3
|
+
*.jpeg
|
|
4
|
+
*.gif
|
|
5
|
+
*.bmp
|
|
6
|
+
*.tiff
|
|
7
|
+
*.ico
|
|
8
|
+
*.svg
|
|
9
|
+
*.psd
|
|
10
|
+
*.ai
|
|
11
|
+
*.eps
|
|
12
|
+
*.pdf
|
|
13
|
+
*.mp3
|
|
14
|
+
*.wav
|
|
15
|
+
*.flac
|
|
16
|
+
*.mp4
|
|
17
|
+
*.avi
|
|
18
|
+
*.mov
|
|
19
|
+
*.mkv
|
|
20
|
+
*.wmv
|
|
21
|
+
*.zip
|
|
22
|
+
*.tar
|
|
23
|
+
*.gz
|
|
24
|
+
*.rar
|
|
25
|
+
*.7z
|
|
26
|
+
*.exe
|
|
27
|
+
*.dll
|
|
28
|
+
*.so
|
|
29
|
+
*.dylib
|
|
30
|
+
*.pyc
|
|
31
|
+
*.pyo
|
|
32
|
+
*.class
|
|
33
|
+
*.o
|
|
34
|
+
*.obj
|
|
35
|
+
*.out
|
|
36
|
+
*.nii
|
|
37
|
+
|
|
38
|
+
datasets/tmp_downloads/
|
|
39
|
+
datasets/MSD_Task07_Pancreas/
|
|
40
|
+
datasets/AMOS22/
|
|
41
|
+
datasets/PanSegData/
|
|
42
|
+
|
|
43
|
+
# generated dataset manifests (regenerate with dataset_generation/dataset_gen.py)
|
|
44
|
+
dataset_generation/output/
|
|
45
|
+
.exported-models/
|
|
46
|
+
.eval-artifacts/
|
|
47
|
+
.prediction-artifacts/
|
|
48
|
+
|
|
49
|
+
# local documentation-generation helpers
|
|
50
|
+
docs/*.py
|
|
51
|
+
|
|
52
|
+
__pycache__/**
|
|
53
|
+
|
|
54
|
+
# pytest / coverage
|
|
55
|
+
.coverage
|
|
56
|
+
.coverage.*
|
|
57
|
+
htmlcov/
|
|
58
|
+
coverage.xml
|
|
59
|
+
.pytest_cache/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.13
|
panseg-0.1.0/Makefile
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
.PHONY: test test-ci test-metrics test-code test-monai \
|
|
2
|
+
eval-ct-totalseg-msd-pancreas eval-ct-dints-msd-pancreas \
|
|
3
|
+
eval-ct-totalseg-amos-pancreas eval-ct-dints-amos-pancreas \
|
|
4
|
+
eval-mri-totalseg-amos-pancreas eval-mri-mrseg-amos-pancreas \
|
|
5
|
+
eval-mri-totalseg-panseg-t1-pancreas eval-mri-mrseg-panseg-t1-pancreas \
|
|
6
|
+
eval-mri-totalseg-panseg-t2-pancreas eval-mri-mrseg-panseg-t2-pancreas
|
|
7
|
+
|
|
8
|
+
PARQUET ?= dataset_generation/output/ct_pancreas.parquet
|
|
9
|
+
MRI_PARQUET ?= dataset_generation/output/mri_pancreas.parquet
|
|
10
|
+
|
|
11
|
+
# ---------------------------------------------------------------------------
|
|
12
|
+
# Unit tests
|
|
13
|
+
# tests/metrics — HD95 / CC / eval-summary contracts
|
|
14
|
+
# tests/code — datasets, models, pipeline, utils, infer, artifacts, …
|
|
15
|
+
# ---------------------------------------------------------------------------
|
|
16
|
+
|
|
17
|
+
test:
|
|
18
|
+
uv run --group dev pytest tests/
|
|
19
|
+
|
|
20
|
+
test-metrics:
|
|
21
|
+
uv run --group dev pytest tests/metrics/
|
|
22
|
+
|
|
23
|
+
test-code:
|
|
24
|
+
uv run --group dev pytest tests/code/ --ignore=tests/code/test_monai_dints.py --no-cov
|
|
25
|
+
|
|
26
|
+
test-monai:
|
|
27
|
+
uv run --extra monai --group dev pytest tests/code/test_monai_dints.py
|
|
28
|
+
|
|
29
|
+
# Same shape as GitHub Actions CI (CPU + monai, coverage XML/HTML).
|
|
30
|
+
test-ci:
|
|
31
|
+
uv run --extra monai --group dev pytest tests/ \
|
|
32
|
+
--cov=panseg \
|
|
33
|
+
--cov=phase_2/models/lib \
|
|
34
|
+
--cov-report=term-missing \
|
|
35
|
+
--cov-report=xml:coverage.xml \
|
|
36
|
+
--cov-report=html:htmlcov
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
eval-ct-totalseg-msd-pancreas:
|
|
40
|
+
uv run python panseg/cli.py eval \
|
|
41
|
+
--parquet $(PARQUET) \
|
|
42
|
+
--modality ct \
|
|
43
|
+
--model totalseg \
|
|
44
|
+
--dataset msd-pancreas
|
|
45
|
+
|
|
46
|
+
eval-ct-dints-msd-pancreas:
|
|
47
|
+
uv run --extra monai python panseg/cli.py eval \
|
|
48
|
+
--parquet $(PARQUET) \
|
|
49
|
+
--modality ct \
|
|
50
|
+
--model dints \
|
|
51
|
+
--dataset msd-pancreas
|
|
52
|
+
|
|
53
|
+
eval-ct-totalseg-amos-pancreas:
|
|
54
|
+
uv run python panseg/cli.py eval \
|
|
55
|
+
--parquet $(PARQUET) \
|
|
56
|
+
--modality ct \
|
|
57
|
+
--model totalseg \
|
|
58
|
+
--dataset amos-ct-pancreas
|
|
59
|
+
|
|
60
|
+
eval-ct-dints-amos-pancreas:
|
|
61
|
+
uv run --extra monai python panseg/cli.py eval \
|
|
62
|
+
--parquet $(PARQUET) \
|
|
63
|
+
--modality ct \
|
|
64
|
+
--model dints \
|
|
65
|
+
--dataset amos-ct-pancreas
|
|
66
|
+
|
|
67
|
+
eval-mri-totalseg-amos-pancreas:
|
|
68
|
+
uv run python panseg/cli.py eval \
|
|
69
|
+
--parquet $(MRI_PARQUET) \
|
|
70
|
+
--modality mri \
|
|
71
|
+
--model totalseg \
|
|
72
|
+
--dataset amos-pancreas
|
|
73
|
+
|
|
74
|
+
eval-mri-mrseg-amos-pancreas:
|
|
75
|
+
uv run --extra mrsegmentator python panseg/cli.py eval \
|
|
76
|
+
--parquet $(MRI_PARQUET) \
|
|
77
|
+
--modality mri \
|
|
78
|
+
--model mrseg \
|
|
79
|
+
--dataset amos-pancreas
|
|
80
|
+
|
|
81
|
+
eval-mri-totalseg-panseg-t1-pancreas:
|
|
82
|
+
uv run python panseg/cli.py eval \
|
|
83
|
+
--parquet $(MRI_PARQUET) \
|
|
84
|
+
--modality mri \
|
|
85
|
+
--model totalseg \
|
|
86
|
+
--dataset panseg-t1-pancreas
|
|
87
|
+
|
|
88
|
+
eval-mri-mrseg-panseg-t1-pancreas:
|
|
89
|
+
uv run --extra mrsegmentator python panseg/cli.py eval \
|
|
90
|
+
--parquet $(MRI_PARQUET) \
|
|
91
|
+
--modality mri \
|
|
92
|
+
--model mrseg \
|
|
93
|
+
--dataset panseg-t1-pancreas
|
|
94
|
+
|
|
95
|
+
eval-mri-totalseg-panseg-t2-pancreas:
|
|
96
|
+
uv run python panseg/cli.py eval \
|
|
97
|
+
--parquet $(MRI_PARQUET) \
|
|
98
|
+
--modality mri \
|
|
99
|
+
--model totalseg \
|
|
100
|
+
--dataset panseg-t2-pancreas
|
|
101
|
+
|
|
102
|
+
eval-mri-mrseg-panseg-t2-pancreas:
|
|
103
|
+
uv run --extra mrsegmentator python panseg/cli.py eval \
|
|
104
|
+
--parquet $(MRI_PARQUET) \
|
|
105
|
+
--modality mri \
|
|
106
|
+
--model mrseg \
|
|
107
|
+
--dataset panseg-t2-pancreas
|
|
108
|
+
|
|
109
|
+
include trained_model_evals.mk
|
panseg-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: panseg
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Pancreas segmentation inference
|
|
5
|
+
Requires-Python: >=3.13
|
|
6
|
+
Requires-Dist: huggingface-hub>=0.26
|
|
7
|
+
Requires-Dist: kaggle>=2.2.4
|
|
8
|
+
Requires-Dist: lightning>=2.5.0
|
|
9
|
+
Requires-Dist: napari[all]>=0.6
|
|
10
|
+
Requires-Dist: pandas>=2.2.0
|
|
11
|
+
Requires-Dist: pyside6>=6.6
|
|
12
|
+
Requires-Dist: pyyaml>=6.0
|
|
13
|
+
Requires-Dist: torch>=2.13.0
|
|
14
|
+
Requires-Dist: torchmetrics>=1.9.0
|
|
15
|
+
Requires-Dist: totalsegmentator>=2.18.0
|
|
16
|
+
Requires-Dist: tqdm>=4.67.0
|
|
17
|
+
Requires-Dist: typer>=0.27.1
|
|
18
|
+
Provides-Extra: cuda
|
|
19
|
+
Requires-Dist: torch>=2.13.0; (sys_platform == 'linux') and extra == 'cuda'
|
|
20
|
+
Requires-Dist: torchvision>=0.28.0; (sys_platform == 'linux') and extra == 'cuda'
|
|
21
|
+
Provides-Extra: monai
|
|
22
|
+
Requires-Dist: monai<1.7,>=1.6; extra == 'monai'
|
|
23
|
+
Requires-Dist: pytorch-ignite>=0.4.11; extra == 'monai'
|
|
24
|
+
Provides-Extra: mrsegmentator
|
|
25
|
+
Requires-Dist: mrsegmentator==2.0.0; extra == 'mrsegmentator'
|
|
26
|
+
Provides-Extra: nnunet
|
|
27
|
+
Requires-Dist: nnunetv2; extra == 'nnunet'
|
|
28
|
+
Provides-Extra: viz
|
|
29
|
+
Requires-Dist: streamlit>=1.40; extra == 'viz'
|
|
30
|
+
Provides-Extra: xpu
|
|
31
|
+
Requires-Dist: torch>=2.13.0; (sys_platform == 'linux') and extra == 'xpu'
|
|
32
|
+
Requires-Dist: torchvision>=0.28.0; (sys_platform == 'linux') and extra == 'xpu'
|
|
33
|
+
Requires-Dist: triton-xpu>=3.7.0; (sys_platform == 'linux') and extra == 'xpu'
|
|
34
|
+
Description-Content-Type: text/markdown
|
|
35
|
+
|
|
36
|
+
# COMP3888_Capstone
|
|
37
|
+
|
|
38
|
+
## Quickstart
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
curl -LsSf \
|
|
42
|
+
-H "Authorization: Bearer $(gh auth token)" \
|
|
43
|
+
-H "Accept: application/vnd.github.raw" \
|
|
44
|
+
"https://api.github.com/repos/C-O-R-N-H/COMP3888_TU13_01_P35/contents/install.sh?ref=main" | sh
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
The repository is private, so this needs the GitHub CLI logged in (`gh auth login`). A plain `curl` of the raw URL returns 404.
|
|
48
|
+
|
|
49
|
+
Once that finishes, run inference with:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pansegai scan.nii.gz .prediction-artifacts
|
|
53
|
+
pansegai scan.nii.gz ./predictions --checkpoint mri/mri_final_ckpt_c2b_annealing_aggressive.pth
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Prerequisites
|
|
57
|
+
|
|
58
|
+
Please ensure you have `uv` installed.
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
## Installation
|
|
65
|
+
|
|
66
|
+
From the repository root, download the pancreas segmentation datasets (about 40 GiB). The script writes into `datasets/` regardless of the current directory, and skips anything already extracted:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
./datasets/download_datasets
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Running an example
|
|
73
|
+
|
|
74
|
+
`uv run --extra cuda python phase_1/totalseg_demo.py`
|
|
75
|
+
|
|
76
|
+
Choose exactly one PyTorch backend extra: `cuda` for the standard CUDA wheel,
|
|
77
|
+
or `xpu` for Intel Arc. `uv` rejects selecting both, preventing one wheel from
|
|
78
|
+
silently replacing the other.
|
|
79
|
+
|
|
80
|
+
## Running Evaluations
|
|
81
|
+
|
|
82
|
+
To run the baseline evaluations for this project, please see the `Makefile` in the root of this repository.
|
|
83
|
+
|
|
84
|
+
You can run a variety of available evaluations by simply running:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
make {name of eval make target}
|
|
88
|
+
# example below
|
|
89
|
+
make eval-mri-mrseg-amos-pancreas
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Alternatively, it is also possible to run the CLI script with relevant arguments directly:
|
|
93
|
+
```
|
|
94
|
+
uv run python panseg/cli.py eval \
|
|
95
|
+
--parquet $(MRI_PARQUET) \
|
|
96
|
+
--modality mri \
|
|
97
|
+
--model mrseg \
|
|
98
|
+
--dataset amos-pancreas
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
This will run the evaluation for the MRI MRSEG model on the AMOS pancreas dataset. Errors are thrown
|
|
102
|
+
for missing or invalid arguments.
|
|
103
|
+
|
|
104
|
+
## pansegai CLI
|
|
105
|
+
|
|
106
|
+
`pansegai` runs the same Hugging Face checkpoint inference as `panseg/cli.py infer`. Modality is inferred from voxel intensities unless you pass `--modality`. `--checkpoint` is a file path inside `dillondesilva/comp3888-capstone-panseg-models`; omit it to use the default CT or MRI annealing checkpoint. `install.sh` installs `uv` when it is missing, then installs the tool from this git repository (`PANSEG_REF` defaults to `main`). MRSegmentator is an optional extra (`uv sync --extra mrsegmentator`) because its Torch pin conflicts with this project's Torch 2.13 requirement; `pansegai` does not need it.
|
|
107
|
+
|
|
108
|
+
From a checkout, without the install script:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
uv tool install --editable ".[nnunet]"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The same run without installing the tool:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
uv run --extra nnunet python panseg/cli.py infer \
|
|
118
|
+
--input scan.nii.gz \
|
|
119
|
+
--artifacts-dir .prediction-artifacts
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Eval artifact viewer
|
|
123
|
+
|
|
124
|
+
After an `infer` dump exists, compare models against the original image and
|
|
125
|
+
ground truth:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
uv run --extra viz streamlit run apps/eval_viewer.py
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The sidebar picks a folder under `.eval-artifacts/`. Toggle **Ground truth**
|
|
132
|
+
(green) and **Predicted** (red) to overlay both on the same original slice.
|
|
133
|
+
|
|
134
|
+
## MONAI BasicUNet
|
|
135
|
+
|
|
136
|
+
The first in-project MONAI model is optional, so install its dependency extra
|
|
137
|
+
before importing it:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
uv sync --extra monai --extra cuda
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
`MonaiUNetModel` is a 3D, single-channel pancreas-segmentation network. It
|
|
144
|
+
accepts a floating-point tensor shaped `[batch, depth, height, width]` and
|
|
145
|
+
returns a `float32` binary mask of the same shape. It adds MONAI's channel
|
|
146
|
+
dimension internally.
|
|
147
|
+
|
|
148
|
+
```python
|
|
149
|
+
import torch
|
|
150
|
+
from panseg.models.monai_unet import MonaiUNetModel
|
|
151
|
+
|
|
152
|
+
model = MonaiUNetModel(modality="ct", checkpoint_path="models/panseg_unet.pt")
|
|
153
|
+
model.eval()
|
|
154
|
+
mask = model(torch.randn(1, 32, 32, 32))
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
`checkpoint_path` must point to a local raw PyTorch state dictionary produced
|
|
158
|
+
by the same `MonaiUNetModel` architecture. Without one, the model has random
|
|
159
|
+
weights and is useful only for integration checks. Training, NIfTI
|
|
160
|
+
preprocessing, and sliding-window full-volume inference are not part of this
|
|
161
|
+
initial integration.
|
|
162
|
+
|
|
163
|
+
Run unit tests with:
|
|
164
|
+
|
|
165
|
+
```bash
|
|
166
|
+
make test # all tests under tests/ (with coverage)
|
|
167
|
+
make test-ci # same shape as GitHub Actions (CPU + monai + coverage)
|
|
168
|
+
make test-metrics # HD95 / CC / eval-summary contracts
|
|
169
|
+
make test-code # application modules (skips MONAI-only cases)
|
|
170
|
+
make test-monai # MONAI DiNTS adapter tests (needs --extra monai)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Or directly:
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
uv run --group dev pytest tests/
|
|
177
|
+
uv run --extra monai --group dev pytest tests/code/test_monai_dints.py
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Continuous integration
|
|
181
|
+
|
|
182
|
+
GitHub Actions (`.github/workflows/ci.yml`) runs on every push to `main` and on
|
|
183
|
+
pull requests. The job uses Linux CPU wheels only (no CUDA/XPU), installs the
|
|
184
|
+
`monai` extra so optional DiNTS tests execute, and does **not** download the
|
|
185
|
+
~40 GiB image datasets — unit tests rely on temporary fixtures and mocks.
|
|
186
|
+
Coverage XML/HTML reports are uploaded as workflow artifacts.
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
Run the MONAI patch demo with a compatible checkpoint:
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
uv run --extra monai --extra cuda python phase_1/monai_demo.py --checkpoint models/panseg_unet.pt
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
The demo runs a centre crop rather than full-volume inference. Full-volume
|
|
196
|
+
sliding-window inference will be added with the MONAI training workflow.
|
|
197
|
+
|
|
198
|
+
### Pretrained MONAI pancreas model
|
|
199
|
+
|
|
200
|
+
`MonaiPancreasDiNTSModel` uses MONAI Model Zoo's CT-only pancreas/tumour DiNTS
|
|
201
|
+
bundle. Like `TotalSegModel`, it downloads its pretrained bundle automatically
|
|
202
|
+
on first use and caches it in `~/.cache/panseg/monai-bundles` (override with
|
|
203
|
+
`bundle_dir`). Its `run()` method accepts the same batched 3D tensor and
|
|
204
|
+
optional NIfTI affine as `TotalSegModel`; it returns only the pancreas label as
|
|
205
|
+
a binary mask. The bundle supplies the CT preprocessing and full-volume
|
|
206
|
+
sliding-window inference.
|
|
207
|
+
|
|
208
|
+
For inference, the adapter selects CUDA first, then PyTorch's Intel XPU
|
|
209
|
+
backend (for Intel Arc), then CPU. XPU uses one sliding-window patch at a time
|
|
210
|
+
by default to keep memory use conservative.
|
|
211
|
+
|
|
212
|
+
All PanSeg models accept `accelerator="auto"` by default. Auto selection uses
|
|
213
|
+
CUDA, then XPU, then MPS, then CPU, but only chooses accelerators supported by
|
|
214
|
+
the individual adapter. For example, the MONAI adapters support XPU, while
|
|
215
|
+
TotalSegmentator currently supports CUDA, MPS, and CPU only. Request a
|
|
216
|
+
specific supported backend with `accelerator="xpu"` or `accelerator="cpu"`.
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
import nibabel as nib
|
|
220
|
+
import torch
|
|
221
|
+
|
|
222
|
+
from panseg.models.monai_dints import MonaiPancreasDiNTSModel
|
|
223
|
+
|
|
224
|
+
source = nib.load("scan.nii.gz")
|
|
225
|
+
volume = torch.from_numpy(source.get_fdata()).unsqueeze(0).float()
|
|
226
|
+
model = MonaiPancreasDiNTSModel(modality="ct", accelerator="auto")
|
|
227
|
+
mask = model.run(volume, affine=source.affine)
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
Run the matching demo with:
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
uv run --extra monai python phase_1/monai_dints_demo.py
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
If you have activated a separate environment containing PyTorch's Intel XPU
|
|
237
|
+
wheel (for example `.venv-xpu`), use the tracked `xpu` extra. It selects
|
|
238
|
+
PyTorch's XPU wheel index and prevents `uv` from replacing it with a CUDA
|
|
239
|
+
build:
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
uv sync --extra monai --extra xpu
|
|
243
|
+
uv run --extra monai --extra xpu python phase_1/monai_dints_demo.py
|
|
244
|
+
```
|
panseg-0.1.0/README.md
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# COMP3888_Capstone
|
|
2
|
+
|
|
3
|
+
## Quickstart
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
curl -LsSf \
|
|
7
|
+
-H "Authorization: Bearer $(gh auth token)" \
|
|
8
|
+
-H "Accept: application/vnd.github.raw" \
|
|
9
|
+
"https://api.github.com/repos/C-O-R-N-H/COMP3888_TU13_01_P35/contents/install.sh?ref=main" | sh
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The repository is private, so this needs the GitHub CLI logged in (`gh auth login`). A plain `curl` of the raw URL returns 404.
|
|
13
|
+
|
|
14
|
+
Once that finishes, run inference with:
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pansegai scan.nii.gz .prediction-artifacts
|
|
18
|
+
pansegai scan.nii.gz ./predictions --checkpoint mri/mri_final_ckpt_c2b_annealing_aggressive.pth
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Prerequisites
|
|
22
|
+
|
|
23
|
+
Please ensure you have `uv` installed.
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
From the repository root, download the pancreas segmentation datasets (about 40 GiB). The script writes into `datasets/` regardless of the current directory, and skips anything already extracted:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
./datasets/download_datasets
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Running an example
|
|
38
|
+
|
|
39
|
+
`uv run --extra cuda python phase_1/totalseg_demo.py`
|
|
40
|
+
|
|
41
|
+
Choose exactly one PyTorch backend extra: `cuda` for the standard CUDA wheel,
|
|
42
|
+
or `xpu` for Intel Arc. `uv` rejects selecting both, preventing one wheel from
|
|
43
|
+
silently replacing the other.
|
|
44
|
+
|
|
45
|
+
## Running Evaluations
|
|
46
|
+
|
|
47
|
+
To run the baseline evaluations for this project, please see the `Makefile` in the root of this repository.
|
|
48
|
+
|
|
49
|
+
You can run a variety of available evaluations by simply running:
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
make {name of eval make target}
|
|
53
|
+
# example below
|
|
54
|
+
make eval-mri-mrseg-amos-pancreas
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Alternatively, it is also possible to run the CLI script with relevant arguments directly:
|
|
58
|
+
```
|
|
59
|
+
uv run python panseg/cli.py eval \
|
|
60
|
+
--parquet $(MRI_PARQUET) \
|
|
61
|
+
--modality mri \
|
|
62
|
+
--model mrseg \
|
|
63
|
+
--dataset amos-pancreas
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
This will run the evaluation for the MRI MRSEG model on the AMOS pancreas dataset. Errors are thrown
|
|
67
|
+
for missing or invalid arguments.
|
|
68
|
+
|
|
69
|
+
## pansegai CLI
|
|
70
|
+
|
|
71
|
+
`pansegai` runs the same Hugging Face checkpoint inference as `panseg/cli.py infer`. Modality is inferred from voxel intensities unless you pass `--modality`. `--checkpoint` is a file path inside `dillondesilva/comp3888-capstone-panseg-models`; omit it to use the default CT or MRI annealing checkpoint. `install.sh` installs `uv` when it is missing, then installs the tool from this git repository (`PANSEG_REF` defaults to `main`). MRSegmentator is an optional extra (`uv sync --extra mrsegmentator`) because its Torch pin conflicts with this project's Torch 2.13 requirement; `pansegai` does not need it.
|
|
72
|
+
|
|
73
|
+
From a checkout, without the install script:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
uv tool install --editable ".[nnunet]"
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
The same run without installing the tool:
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
uv run --extra nnunet python panseg/cli.py infer \
|
|
83
|
+
--input scan.nii.gz \
|
|
84
|
+
--artifacts-dir .prediction-artifacts
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Eval artifact viewer
|
|
88
|
+
|
|
89
|
+
After an `infer` dump exists, compare models against the original image and
|
|
90
|
+
ground truth:
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
uv run --extra viz streamlit run apps/eval_viewer.py
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The sidebar picks a folder under `.eval-artifacts/`. Toggle **Ground truth**
|
|
97
|
+
(green) and **Predicted** (red) to overlay both on the same original slice.
|
|
98
|
+
|
|
99
|
+
## MONAI BasicUNet
|
|
100
|
+
|
|
101
|
+
The first in-project MONAI model is optional, so install its dependency extra
|
|
102
|
+
before importing it:
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
uv sync --extra monai --extra cuda
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
`MonaiUNetModel` is a 3D, single-channel pancreas-segmentation network. It
|
|
109
|
+
accepts a floating-point tensor shaped `[batch, depth, height, width]` and
|
|
110
|
+
returns a `float32` binary mask of the same shape. It adds MONAI's channel
|
|
111
|
+
dimension internally.
|
|
112
|
+
|
|
113
|
+
```python
|
|
114
|
+
import torch
|
|
115
|
+
from panseg.models.monai_unet import MonaiUNetModel
|
|
116
|
+
|
|
117
|
+
model = MonaiUNetModel(modality="ct", checkpoint_path="models/panseg_unet.pt")
|
|
118
|
+
model.eval()
|
|
119
|
+
mask = model(torch.randn(1, 32, 32, 32))
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
`checkpoint_path` must point to a local raw PyTorch state dictionary produced
|
|
123
|
+
by the same `MonaiUNetModel` architecture. Without one, the model has random
|
|
124
|
+
weights and is useful only for integration checks. Training, NIfTI
|
|
125
|
+
preprocessing, and sliding-window full-volume inference are not part of this
|
|
126
|
+
initial integration.
|
|
127
|
+
|
|
128
|
+
Run unit tests with:
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
make test # all tests under tests/ (with coverage)
|
|
132
|
+
make test-ci # same shape as GitHub Actions (CPU + monai + coverage)
|
|
133
|
+
make test-metrics # HD95 / CC / eval-summary contracts
|
|
134
|
+
make test-code # application modules (skips MONAI-only cases)
|
|
135
|
+
make test-monai # MONAI DiNTS adapter tests (needs --extra monai)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Or directly:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
uv run --group dev pytest tests/
|
|
142
|
+
uv run --extra monai --group dev pytest tests/code/test_monai_dints.py
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Continuous integration
|
|
146
|
+
|
|
147
|
+
GitHub Actions (`.github/workflows/ci.yml`) runs on every push to `main` and on
|
|
148
|
+
pull requests. The job uses Linux CPU wheels only (no CUDA/XPU), installs the
|
|
149
|
+
`monai` extra so optional DiNTS tests execute, and does **not** download the
|
|
150
|
+
~40 GiB image datasets — unit tests rely on temporary fixtures and mocks.
|
|
151
|
+
Coverage XML/HTML reports are uploaded as workflow artifacts.
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
Run the MONAI patch demo with a compatible checkpoint:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
uv run --extra monai --extra cuda python phase_1/monai_demo.py --checkpoint models/panseg_unet.pt
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
The demo runs a centre crop rather than full-volume inference. Full-volume
|
|
161
|
+
sliding-window inference will be added with the MONAI training workflow.
|
|
162
|
+
|
|
163
|
+
### Pretrained MONAI pancreas model
|
|
164
|
+
|
|
165
|
+
`MonaiPancreasDiNTSModel` uses MONAI Model Zoo's CT-only pancreas/tumour DiNTS
|
|
166
|
+
bundle. Like `TotalSegModel`, it downloads its pretrained bundle automatically
|
|
167
|
+
on first use and caches it in `~/.cache/panseg/monai-bundles` (override with
|
|
168
|
+
`bundle_dir`). Its `run()` method accepts the same batched 3D tensor and
|
|
169
|
+
optional NIfTI affine as `TotalSegModel`; it returns only the pancreas label as
|
|
170
|
+
a binary mask. The bundle supplies the CT preprocessing and full-volume
|
|
171
|
+
sliding-window inference.
|
|
172
|
+
|
|
173
|
+
For inference, the adapter selects CUDA first, then PyTorch's Intel XPU
|
|
174
|
+
backend (for Intel Arc), then CPU. XPU uses one sliding-window patch at a time
|
|
175
|
+
by default to keep memory use conservative.
|
|
176
|
+
|
|
177
|
+
All PanSeg models accept `accelerator="auto"` by default. Auto selection uses
|
|
178
|
+
CUDA, then XPU, then MPS, then CPU, but only chooses accelerators supported by
|
|
179
|
+
the individual adapter. For example, the MONAI adapters support XPU, while
|
|
180
|
+
TotalSegmentator currently supports CUDA, MPS, and CPU only. Request a
|
|
181
|
+
specific supported backend with `accelerator="xpu"` or `accelerator="cpu"`.
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
import nibabel as nib
|
|
185
|
+
import torch
|
|
186
|
+
|
|
187
|
+
from panseg.models.monai_dints import MonaiPancreasDiNTSModel
|
|
188
|
+
|
|
189
|
+
source = nib.load("scan.nii.gz")
|
|
190
|
+
volume = torch.from_numpy(source.get_fdata()).unsqueeze(0).float()
|
|
191
|
+
model = MonaiPancreasDiNTSModel(modality="ct", accelerator="auto")
|
|
192
|
+
mask = model.run(volume, affine=source.affine)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Run the matching demo with:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
uv run --extra monai python phase_1/monai_dints_demo.py
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
If you have activated a separate environment containing PyTorch's Intel XPU
|
|
202
|
+
wheel (for example `.venv-xpu`), use the tracked `xpu` extra. It selects
|
|
203
|
+
PyTorch's XPU wheel index and prevents `uv` from replacing it with a CUDA
|
|
204
|
+
build:
|
|
205
|
+
|
|
206
|
+
```bash
|
|
207
|
+
uv sync --extra monai --extra xpu
|
|
208
|
+
uv run --extra monai --extra xpu python phase_1/monai_dints_demo.py
|
|
209
|
+
```
|