lassoan / SlicerTotalSegmentator

Fully automatic total body segmentation in 3D Slicer using "TotalSegmentator" AI model
Apache License 2.0
176 stars 25 forks source link

Exception run on sample data #22

Closed x1y9 closed 1 year ago

x1y9 commented 1 year ago

I run this extension on CTA Abdomen (Panoramix) dataset, and get this exception:

Processing started
Writing input file to C:/Users/z/AppData/Local/Temp/Slicer/__SlicerTemp__2023-04-24_16+17+51.391/total-segmentator-input.nii
Creating segmentations with TotalSegmentator AI...
Total Segmentator arguments: ['-i', 'C:/Users/z/AppData/Local/Temp/Slicer/__SlicerTemp__2023-04-24_16+17+51.391/total-segmentator-input.nii', '-o', 'C:/Users/z/AppData/Local/Temp/Slicer/__SlicerTemp__2023-04-24_16+17+51.391/segmentation', '--ml', '--task', 'total', '--fast']

Please cite the following paper when using nnUNet:

Isensee, F., Jaeger, P.F., Kohl, S.A.A. et al. "nnU-Net: a self-configuring method for deep learning-based biomedical image segmentation." Nat Methods (2020). https://doi.org/10.1038/s41592-020-01008-z

If you have questions or suggestions, feel free to open an issue at https://github.com/MIC-DKFZ/nnUNet

preprocessing C:\Users\z\AppData\Local\Temp\nnunet_tmp_zk3wskdc\s01.nii.gz
using preprocessor GenericPreprocessor
before crop: (1, 108, 79, 109) after crop: (1, 108, 79, 108) spacing: [3. 3. 3.]

no resampling necessary
no resampling necessary
before: {'spacing': array([3., 3., 3.]), 'spacing_transposed': array([3., 3., 3.]), 'data.shape (data is transposed)': (1, 108, 79, 108)}
after:  {'spacing': array([3., 3., 3.]), 'data.shape (data is resampled)': (1, 108, 79, 108)}

(1, 108, 79, 108)
This worker has ended successfully, no errors to report
D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\torch\cuda\amp\grad_scaler.py:116: UserWarning: torch.cuda.amp.GradScaler is enabled, but CUDA is not available.  Disabling.
  warnings.warn("torch.cuda.amp.GradScaler is enabled, but CUDA is not available.  Disabling.")
D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\torch\cuda\amp\autocast_mode.py:118: UserWarning: torch.cuda.amp.autocast only affects CUDA ops, but CUDA is not available.  Disabling.
  warnings.warn("torch.cuda.amp.autocast only affects CUDA ops, but CUDA is not available.  Disabling.")
Traceback (most recent call last):
  File "D:\dev\Slicer 5.2.2\lib\Python\Scripts\TotalSegmentator", line 93, in <module>
    main()
  File "D:\dev\Slicer 5.2.2\lib\Python\Scripts\TotalSegmentator", line 86, in main
    totalsegmentator(args.input, args.output, args.ml, args.nr_thr_resamp, args.nr_thr_saving,
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\totalsegmentator\python_api.py", line 173, in totalsegmentator
    seg = nnUNet_predict_image(input, output, task_id, model=model, folds=folds,
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\totalsegmentator\nnunet.py", line 255, in nnUNet_predict_image
    nnUNet_predict(tmp_dir, tmp_dir, task_id, model, folds, trainer, tta)
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\totalsegmentator\nnunet.py", line 106, in nnUNet_predict
    predict_from_folder(model_folder_name, dir_in, dir_out, folds, save_npz, num_threads_preprocessing,
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\nnunet\inference\predict.py", line 668, in predict_from_folder
    return predict_cases_fastest(model, list_of_lists[part_id::num_parts], output_files[part_id::num_parts], folds,
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\nnunet\inference\predict.py", line 493, in predict_cases_fastest
    res = trainer.predict_preprocessed_data_return_seg_and_softmax(d, do_mirroring=do_tta,
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\nnunet\training\network_training\nnUNetTrainerV2.py", line 211, in predict_preprocessed_data_return_seg_and_softmax
    ret = super().predict_preprocessed_data_return_seg_and_softmax(data,
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\nnunet\training\network_training\nnUNetTrainer.py", line 516, in predict_preprocessed_data_return_seg_and_softmax
    ret = self.network.predict_3D(data, do_mirroring=do_mirroring, mirror_axes=mirror_axes,
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\nnunet\network_architecture\neural_network.py", line 147, in predict_3D
    res = self._internal_predict_3D_3Dconv_tiled(x, step_size, do_mirroring, mirror_axes, patch_size,
  File "D:\dev\Slicer 5.2.2\lib\Python\Lib\site-packages\nnunet\network_architecture\neural_network.py", line 348, in _internal_predict_3D_3Dconv_tiled
    gaussian_importance_map[gaussian_importance_map == 0] = gaussian_importance_map[
RuntimeError: "min_all" not implemented for 'Half'
Exception ignored in: <totalsegmentator.libs.DummyFile object at 0x000002829F8B86D0>
AttributeError: 'DummyFile' object has no attribute 'flush'

If you use this tool please cite: https://doi.org/10.48550/arXiv.2208.05868

No GPU detected. Running on CPU. This can be very slow. The '--fast' option can help to some extend.
Using 'fast' option: resampling to lower resolution (3mm)
Resampling...
  Resampled in 1.24s
Predicting...
lassoan commented 1 year ago

What GPU do you have in your computer (if any)?

x1y9 commented 1 year ago

I have no GPU installed, just Intel CPU.

lassoan commented 1 year ago

What Pytorch version do you see in PyTorch Utils module? If it is a cuda version then use that module to install the CPU version.

x1y9 commented 1 year ago

Curretly, The CPU version is installed.

image

lassoan commented 1 year ago

Which segmentation task are you trying to run?

x1y9 commented 1 year ago

Total Segmentator arguments: ['-i', 'C:/Users/z/AppData/Local/Temp/Slicer/SlicerTemp2023-04-24_16+17+51.391/total-segmentator-input.nii', '-o', 'C:/Users/z/AppData/Local/Temp/Slicer/SlicerTemp2023-04-24_16+17+51.391/segmentation', '--ml', '--task', 'total', '--fast']

The task is 'total'

lassoan commented 1 year ago

Installation of TotalSegmentator and dependencies have been made more robust, everything should work well now when starting from a clean installation.