Page MenuHomePhabricator

[Seg] Totalseg and SAM/MedSAM tool fails
Closed, ResolvedPublic

Description

All AI tool like Totalsegmentator v2 and SAM/MedSAM tool fails to produce segmentation.
Relevant part of the log:

742.28 core.mod.core.imgIo: Writing image: C:\Users\Stefan\AppData\Local\Temp\\mitk-WwHUza\totalseg-in-WwHUza\WwHUza_000_0000.nii.gz
742.38 core.mod.seg.totalsegmentatorTl: -i C:\Users\Stefan\AppData\Local\Temp\\mitk-WwHUza\totalseg-in-WwHUza\WwHUza_000_0000.nii.gz -o C:\Users\Stefan\AppData\Local\Temp\\mitk-WwHUza\totalseg-out-WwHUza\WwHUza_000.nii.gz --ml C:/Users/Stefan/AppData/Local\DKFZ\.totalsegmentator_v2\Scripts
745.28 core.mod.seg.totalsegmentatorTl ERROR:
A module that was compiled using NumPy 1.x cannot be run in
NumPy 2.0.0 as it may crash. To support both 1.x and 2.x
versions of NumPy, modules must be compiled with NumPy 2.0.
Some module may need to rebuild instead e.g. with 'pybind11>=2.12'.

If you are a user of the module, the easiest solution will be to
downgrade to 'numpy<2' or try to upgrade the affected module.
We expect that some modules will need time to support NumPy 2.

C:\Users\Stefan\AppData\Local\DKFZ\.totalsegmentator_v2\Lib\site-packages\nnunetv2\inference\data_iterators.py:41: UserWarning: Failed to initialize NumPy: _ARRAY_API not found (Triggered internally at ..\torch\csrc\utils\tensor_numpy.cpp:84.)
  data = torch.from_numpy(data).to(dtype=torch.float32, memory_format=torch.contiguous_format)

Looks like latest numpy v2 release (June 16) is not working well with Pytorch.
https://pypi.org/project/numpy/#history

Revisions and Commits

rMITK MITK
Restricted Differential Revision
Restricted Differential Revision

Event Timeline

a178n triaged this task as High priority.Jun 25 2024, 11:27 AM
a178n created this task.
a178n updated the task description. (Show Details)

The numpy version upgrade seems disruptive. The current latest torch version 2.3.1 is incompatible with numpy v2 while running torch.from_numpy conversions
Since the numpy v2 release, Totalsegmentator repo has updated its dependency specification. See: https://github.com/wasserth/TotalSegmentator/commit/e648b08445434585511a8a7c8118e34f5309ce05
However, new a release hasn't occurred on pypi.

As far as SAM/MedSAM is concerned, we can add numpy<2 in our agent-sam repo and fix the issue without code changes to MITK.
Perhaps we should think about creating Totalsegmentator "agents" scripts to deal with such production issues.

a178n added a revision: Restricted Differential Revision.Jun 25 2024, 4:42 PM

Numpy dependency updated for SegmentAnything & MedSAM installation in https://github.com/MIC-DKFZ/agent-sam.git
Now the both tools should work.

a178n claimed this task.