Repository navigation
fix: let totalseg_download_weights fetch the cropping model of each task - #644
Merged
wasserth merged 2 commits intoNov 12, 2026
Merged
Conversation
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
force-pushed
the
fix/download-crop-model-weights
branch
from
November 11, 2026 20:06
c0d3aaa to
63cef22
Compare
Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Many tasks first run a total model to crop the image to the region of interest, and
--roi_subsetdoes 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 withtotalseg_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").totalalready lists its cropping model (298). 28 other tasks did not: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_sinuseslung_vessels,liver_lesions,heartchambers_highrestotal_mr,liver_segments_mr,liver_lesions_mrabdominal_musclesteeth(crops withcraniofacial_structures)Fix
Each list in
TASK_TO_IDnow holds everything a run of the task with default options asks for, and for the total tasks also what--roi_subsetasks for. All added ids have a download entry.Two things I left as they are:
--robust_cropon 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_fastfetches it.total_v3lists 837, but a--roi_subsetrun oftotal_v3crops 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.pyneeds no GPU or weights and is added totests/tests.sh. It runstotalsegmentator()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,codespelland the existing no-GPU tests pass. I did not run a real download of all tasks.