Lung CT Segmenter now supports 'lungmask' AI for lung and lobe segmentation

This seems to be a torch problem.
Could you install 3D Slicer 5.6.1 into a new directory and just install Pytorch, LungCTAnalyzer and TotalSegmentator extensions ?
And determine the version of torch as shown here ?

https://www.youtube.com/watch?v=s2lB6MLBVeE

Best
Rudolf

@rsalkin If you switch to the “PyTorch Utils” module in Slicer, what version of Torch does it show that is currently installed?

@rbumm What is the minimum torch version requirement to use your LungCTSegmenter module? I see that your code checks if torch is present and that CUDA support is available, but it doesn’t check a specific torch version requirement?

Below is example usage of SlicerTotalSegmentator enforcing a minimum torch version.

It appears that lungmask specifies no torch version which can result in incompatibilities of an older torch version not working.

@rbumm I did a fresh install into a new directory with the modules as you suggested and get the same error.

@jamesobutler The current version of Torch is 1.8.1. I don’t know if it matters but TorchVision is 0.9.1.

Uninstall Pytorch again.
Then install it with cu118.
For that press "show all compatible and select cu118.
Press Install Pytorch.

Any changes?

image.png

The Pytorch Utils module only let me install up to version 1.8.1+cpu but I was able to manually install version 2.1.2+cpu via the python console (Pytorch extension installation) and now the segmenter is working.

Thanks Dr. Bumm for answering my question. The module has been extremely helpful.

Great, but there seems to be a bug in Pytorch …

Could you describe in detail what you had to do to install the torch version that finally worked?

This is just for the CPU version as my computer does not have a capable GPU for PyTorch.

You first have to go to the PyTorch Utils module (see below) in slicer then select uninstall PyTorch (if you uninstall via the python console slicer.util.pip_uninstall("torch") it doesn’t work and crashes when you try to uninstall via the Utils module afterwards, assuming the original PyTorch installation used the Utils module).

image

Restart Slicer after removing PyTorch then run the line:

slicer.util.pip_install("torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu")

Restart the application one more time after PyTorch has been re-downloaded and you should be good to go.

For some reason, on some computers these ancient PyTorch 1.x versions are installed by default.

We added the “torch version requirement” field to PyTorch Utils module to make it very easy to install a more recent version. For example, you can type >2 in that field and click Install PyTorch.

@rsalkin Do you have any recommendation of how to make it more clear that the required pytorch version can be specified in Pytorch Utils module? Maybe changing the placeholder text from “default” to something like “specify version requirement here” would help?

@rbumm I would recommend to copy the PyTorch version check that @jamesobutler highlighted from TotalSegmentator module to the LungCTSegmenter module.

Now check the Pytorch version in LungCTSegmenter.

Hi Andras, I think that could be good, otherwise it might be simpler to have a drop down menu and select either latest stable version, system default version, or a specify system version where you can then type which one you want, i.e. x.x. That way its easy for someone not to have to look up the first two and give the optionality if a module is very specific for the last option.