pyplati / platipy

Processing Library and Analysis Toolkit for Medical Imaging in Python
https://pyplati.github.io/platipy/
Apache License 2.0
103 stars 24 forks source link

Pinckling Error On MacOS #141

Open VincentBourbon opened 2 years ago

VincentBourbon commented 2 years ago

Hello,

I'm trying to use the Segmentation Cardiac Tool.

After installing PyTorch and nnUnet and running the code, I get the following error.

My setup MacOS BigSur 11.3.1, Python 3.9, PyTorch 11.1.

I'm fairly new to Python scripts. After several searches on the web, I couldn't find a solution for this topic.

Thanks

Vincent

"~ utilisateur$ platipy segmentation cardiac /Users/utilisateur/Documents/Test_AutoSeg/INPUT/P1.nii.gz -o /Users/utilisateur/Documents/Test_AutoSeg/OUTPUT Running cardiac segmentation

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

/Users/utilisateur/.platipy/nnUNet_models/nnUNet/3d_lowres/Task400_OPEN_HEART_1FOLD This model expects 1 input modalities for each image Found 1 unique case ids, here are some examples: ['Task400_OPEN_HEART_1FOLD'] If they don't look right, make sure to double check your filenames. They must end with _0000.nii.gz etc emptying cuda cache loading parameters for folds, all using the following model files: ['/Users/utilisateur/.platipy/nnUNet_models/nnUNet/3d_lowres/Task400_OPEN_HEART_1FOLD/nnUNetTrainerV2nnUNetPlansv2.1/all/model_final_checkpoint.model'] starting preprocessing generator starting prediction... Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.9/bin/platipy", line 8, in sys.exit(platipy_cli()) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/platipy/cli/run.py", line 73, in platipy_cli tools[tool]() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/click/core.py", line 1130, in call return self.main(*args, kwargs) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/click/core.py", line 1055, in main rv = self.invoke(ctx) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/click/core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/click/core.py", line 760, in invoke return callback(*args, **kwargs) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/platipy/cli/segmentation.py", line 106, in click_command results = segmentation_algorithms[algorithm]["algorithm"](image, algorithm_config) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/platipy/imaging/projects/cardiac/run.py", line 429, in run_hybrid_segmentation mask_wh = run_segmentation(img, settings["nnunet_settings"]) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/platipy/imaging/projects/nnunet/run.py", line 127, in run_segmentation predict_from_folder(str(model_folder_name), str(input_path), str(output_path), folds, False, File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/nnunet/inference/predict.py", line 658, in predict_from_folder return predict_cases(model, list_of_lists[part_id::num_parts], output_files[part_id::num_parts], folds, File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/nnunet/inference/predict.py", line 206, in predict_cases for preprocessed in preprocessing: File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/nnunet/inference/predict.py", line 109, in preprocess_multithreaded pr.start() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 121, in start self._popen = self._Popen(self) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/context.py", line 224, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/context.py", line 284, in _Popen return Popen(process_obj) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 32, in init super().init(process_obj) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_fork.py", line 19, in init self._launch(process_obj) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/popen_spawn_posix.py", line 47, in _launch reduction.dump(process_obj, fp) File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/reduction.py", line 60, in dump ForkingPickler(file, protocol).dump(obj) _pickle.PicklingError: Can't pickle <function at 0x167e4cee0>: attribute lookup on nnunet.utilities.nd_softmax failed"

pchlap commented 2 years ago

Hi @VincentBourbon, thanks for reaching out with this issue. I believe this might be due to operating system incompatibilities for the nnUNet portion of this tool. At this stage, the tool has only been tested and run on a Linux (Ubuntu) operating system. Are you able to test it out using Ubuntu?

In the future, hopefully, we can support more platforms, however, we are somewhat relying on nnNUnet supporting these other operating systems first.

VincentBourbon commented 1 year ago

Hello,

Thanks for your reply.

I'm trying to get access to the link but my access is denied.

Could you help me ?

Thanks

Best regards

Vincent Bourbonne

Le lun. 29 août 2022 à 07:28, Phil Chlap @.***> a écrit :

https://camo.githubusercontent.com/208d50cabd9d101500fe5dd548265dcfa00e017e397395692a173e7116c1094a/68747470733a2f2f6769746875622e7472656c6c6f2e73657276696365732f696d616765732f6d696e692d7472656c6c6f2d69636f6e2e706e67 PSQA bug fixes https://trello.com/c/HQsv78aj/369-psqa-bug-fixes

— Reply to this email directly, view it on GitHub https://github.com/pyplati/platipy/issues/141#issuecomment-1229794735, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZP3JIDL6MP6QWWELGMD6F3V3RDA5ANCNFSM5X5YUX3Q . You are receiving this because you were mentioned.Message ID: @.***>

-- Dr Vincent Bourbonne, MD PhD CCA-AHU, Service de Radiothérapie CHU Brest LATIM UMR 1101

hakim-sina commented 1 year ago

Hi @pchlap

I'm running into the same problem both on my M2 Max mac and windows 10 . I will be using linux for our final deployment but in the meantime I only have these 2 machines for testing out the code. Have you guys found a solution to this bug ?

pchlap commented 1 year ago

Hi @pchlap

I'm running into the same problem both on my M2 Max mac and windows 10 . I will be using linux for our final deployment but in the meantime I only have these 2 machines for testing out the code. Have you guys found a solution to this bug ?

Hi @hakim-sina,

as mentioned above, this is due to a limitation in the nnUNet library. So unless that library was to start supporting other platforms then we won't be able to either. From what I read they have no intention to make that tool work outside of a linux environment. So I think this will stay a limitation for us unfortunately.

MarkGardnerUSyd commented 6 months ago

Hi Phil. I'm not sure about for Macs, but I know that nnUnet has released a new module nnunetv2 which is windows and Mac compatible. From an initial look it looks like a whole re-write. There is a migration guide (https://github.com/MIC-DKFZ/nnUNet/blob/master/documentation/tldr_migration_guide_from_v1.md) but I realise it might be a bit of work to translate to the new version. Anyway thought it might be of interest. Mark

pchlap commented 5 months ago

Hi @MarkGardnerUSyd, yes I agree that upgrading to nnunet v2 would definitely be of interest, especially if it can run on other OS's. The problem as you say is that we can't transfer the existing trained model to v2. So we would need to retrain and both @rnfinnegan and I are no longer at Ingham so can't easily do this. We could figure out a way if absolutely necessary but I don't think this is high priority of us since we run this exclusively on Ubuntu anyway.