Skip to content

fix: let totalseg_download_weights fetch the cropping model of each task - #644

Merged
wasserth merged 2 commits into
wasserth:masterfrom
harshpatel:fix/download-crop-model-weights
Nov 12, 2026
Merged

wasserth merged 2 commits into
wasserth:masterfrom
harshpatel:fix/download-crop-model-weights

Conversation

@harshpatel

Copy link
Copy Markdown
Contributor

Problem

Many tasks first run a total model to crop the image to the region of interest, and --roi_subset does the same. totalseg_download_weights -t <task> only fetches the weights of the task itself. On a machine without internet, or in a container that was built with totalseg_download_weights, the first run then fails while it tries to download the cropping model. The README describes exactly this use ("download on another machine with internet and copy ~/.totalsegmentator").

total already lists its cropping model (298). 28 other tasks did not:

cropping model tasks
298 (total 6mm) total_v3, lung_vessels_LEGACY, cerebral_bleed, hip_implant, pleural_pericard_effusion, head_glands_cavities, headneck_bones_vessels, head_muscles, headneck_muscles, liver_vessels, lung_nodules, kidney_cysts, oculomotor_muscles, ventricle_parts, liver_segments, craniofacial_structures, brain_structures, coronary_arteries, coronary_arteries_LEGACY, aortic_sinuses
297 (total 3mm) lung_vessels, liver_lesions, heartchambers_highres
852 (total_mr 3mm) total_mr, liver_segments_mr, liver_lesions_mr
300 (body 6mm) abdominal_muscles
115 and 298 teeth (crops with craniofacial_structures)

Fix

Each list in TASK_TO_ID now holds everything a run of the task with default options asks for, and for the total tasks also what --roi_subset asks for. All added ids have a download entry.

Two things I left as they are:

  • --robust_crop on a CT task asks for 297 instead of 298. That is not added to every list, as it is an option and not the default. -t total_fast fetches it.
  • total_v3 lists 837, but a --roi_subset run of total_v3 crops with 298 today, so 298 is added. If cropping with 837 is what is intended there, tell me and I will change that instead.

Tests

tests/test_download_weights_tasks.py needs no GPU or weights and is added to tests/tests.sh. It runs totalsegmentator() for every downloadable task with the download and the prediction mocked, and checks that no weights are requested which the list of the task lacks. On master it fails for the 28 tasks above. It will also fail when a new task with a cropping step is added without its cropping model.

ruff, codespell and the existing no-GPU tests pass. I did not run a real download of all tasks.

Many tasks first run a total model to crop the image to the region of
interest (and so does --roi_subset). `totalseg_download_weights -t <task>`
only fetched the weights of the task itself, so on a machine without
internet (or in a container built without the cropping model) the first run
failed while trying to download the cropping model. This affected 28 tasks,
for example total_mr with --roi_subset, lung_vessels, liver_segments and
heartchambers_highres.

Each list now holds everything a run of the task asks for. A test runs
every downloadable task with the download and the prediction mocked and
checks that nothing is requested which the list lacks.
@harshpatel
harshpatel force-pushed the fix/download-crop-model-weights branch from c0d3aaa to 63cef22 Compare November 11, 2026 20:06
Co-authored-by: Cursor <cursoragent@cursor.com>
@wasserth
wasserth merged commit d89e47f into wasserth:master Nov 12, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants