Dental Segmentator Error

Hi,

I am unable to use the Dental Segmentator module. I am using slicer 5.8, Pytorch version is 2.6.0 + cu118. I have tried manually downloading the weights and adding it to the Recources/ML folder. However, I am still getting the following error in the log:

2025/01/30 09:50:19.665 :: nnUNet is already installed (2.5.1) and compatible with requested version (nnunetv2).
2025/01/30 09:50:24.325 :: Transferring volume to nnUNet in C:/Users//AppData/Local/Temp/2/Slicer-OCVZwp
2025/01/30 09:50:30.096 :: Starting nnUNet with the following parameters:
2025/01/30 09:50:30.096 ::
2025/01/30 09:50:30.096 :: C:\Users\Slicer 5.8.0\lib\Python\Scripts\nnUNetv2_predict.exe -i C:/Users//AppData/Local/Temp/2/Slicer-OCVZwp/input -o C:/Users//AppData/Local/Temp/2/Slicer-OCVZwp/output -d Dataset111_453CT -tr nnUNetTrainer -p nnUNetPlans -c 3d_fullres -f 0 -npp 1 -nps 1 -step_size 0.5 -device cuda -chk checkpoint_final.pth --disable_tta
2025/01/30 09:50:30.096 ::
2025/01/30 09:50:30.096 :: JSON parameters :
2025/01/30 09:50:30.096 :: {
2025/01/30 09:50:30.096 :: “folds”: “0”,
2025/01/30 09:50:30.096 :: “device”: “cuda”,
2025/01/30 09:50:30.096 :: “stepSize”: 0.5,
2025/01/30 09:50:30.096 :: “disableTta”: true,
2025/01/30 09:50:30.096 :: “nProcessPreprocessing”: 1,
2025/01/30 09:50:30.096 :: “nProcessSegmentationExport”: 1,
2025/01/30 09:50:30.096 :: “checkPointName”: “”,
2025/01/30 09:50:30.096 :: “modelPath”: {
2025/01/30 09:50:30.096 :: “_path”: “C:\Users\Slicer 5.8.0\slicer.org\Extensions-33216\DentalSegmentator\lib\Slicer-5.8\qt-scripted-modules\Resources\ML”
2025/01/30 09:50:30.096 :: }
2025/01/30 09:50:30.096 :: }
2025/01/30 09:50:30.137 :: nnUNet preprocessing…
2025/01/30 09:50:33.686 :: Traceback (most recent call last):
2025/01/30 09:50:33.686 :: File “C:\Users\Slicer 5.8.0\lib\Python\Lib\runpy.py”, line 197, in _run_module_as_main
2025/01/30 09:50:33.781 :: return run_code(code, main_globals, None,
2025/01/30 09:50:33.781 :: File “C:\Users\Slicer 5.8.0\lib\Python\Lib\runpy.py”, line 87, in run_code
2025/01/30 09:50:33.781 :: exec(code, run_globals)
2025/01/30 09:50:33.781 :: File "C:\Users\Slicer 5.8.0\lib\Python\Scripts\nnUNetv2_predict.exe_main
.py", line 7, in
2025/01/30 09:50:33.781 :: File “C:\Users\Slicer 5.8.0\lib\Python\Lib\site-packages\nnunetv2\inference\predict_from_raw_data.py”, line 861, in predict_entry_point
2025/01/30 09:50:33.781 :: predictor.initialize_from_trained_model_folder(
2025/01/30 09:50:33.781 :: File “C:\Users\Slicer 5.8.0\lib\Python\Lib\site-packages\nnunetv2\inference\predict_from_raw_data.py”, line 84, in initialize_from_trained_model_folder
2025/01/30 09:50:33.781 :: checkpoint = torch.load(join(model_training_output_dir, f’fold
{f}', checkpoint_name),
2025/01/30 09:50:33.781 :: File “C:\Users\Slicer 5.8.0\lib\Python\Lib\site-packages\torch\serialization.py”, line 1470, in load
2025/01/30 09:50:33.781 :: raise pickle.UnpicklingError(_get_wo_message(str(e))) from None
2025/01/30 09:50:33.781 :: _pickle.UnpicklingError: Weights only load failed. This file can still be loaded, to do so you have two options, e[1mdo those steps only if you trust the source of the checkpointe[0m.
2025/01/30 09:50:33.781 :: (1) In PyTorch 2.6, we changed the default value of the weights_only argument in torch.load from False to True. Re-running torch.load with weights_only set to False will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
2025/01/30 09:50:33.781 :: (2) Alternatively, to load with weights_only=True please check the recommended steps in the following error message.
2025/01/30 09:50:33.781 :: WeightsUnpickler error: Unsupported global: GLOBAL numpy.core.multiarray.scalar was not an allowed global by default. Please use torch.serialization.add_safe_globals([scalar]) or the torch.serialization.safe_globals([scalar]) context manager to allowlist this global if you trust this class/function.
2025/01/30 09:50:33.781 ::
2025/01/30 09:50:33.781 :: Check the documentation of torch.load to learn more about types accepted by default with weights_only torch.load — PyTorch 2.6 documentation.
2025/01/30 09:50:33.781 ::
2025/01/30 09:50:33.781 :: #######################################################################
2025/01/30 09:50:33.781 :: Please cite the following paper when using nnU-Net:
2025/01/30 09:50:33.781 :: Isensee, F., Jaeger, P. F., Kohl, S. A., Petersen, J., & Maier-Hein, K. H. (2021). nnU-Net: a self-configuring method for deep learning-based biomedical image segmentation. Nature methods, 18(2), 203-211.
2025/01/30 09:50:33.781 :: #######################################################################
2025/01/30 09:50:34.073 :: Loading inference results…
2025/01/30 09:50:36.366 :: Error loading results :
2025/01/30 09:50:36.366 :: Failed to load the segmentation.
2025/01/30 09:50:36.366 :: Something went wrong during the nnUNet processing.
2025/01/30 09:50:36.366 :: Please check the logs for potential errors and contact the library maintainers."

Could someone please look into the issue and recommend some possible workarounds?

Hi @mraihan,

Looking at the error message, the PyTorch version 2.6 seems to be incompatible with the current version of the model / loading settings of nnU-Net.

You can manually downgrade the installed PyTorch version by using the Slicer PyTorch extension and installing the 2.5 version.

Best,
Thibault

1 Like

Thanks, Thibault. It worked!

Regards,
Raihan

Please, tell, how to install another version of Torch than automatic. I am trying to type different version in the field “Torch version requirement” But all the time I got errors:
ERROR: No matching distribution found for torch2.5.0
ERROR: Could not find a version that satisfies the requirement torch2.5.1 (from versions: none)
ERROR: No matching distribution found for torch2.5.1
ERROR: Could not find a version that satisfies the requirement torch2.5.1 (from versions: none)
ERROR: No matching distribution found for torch2.5.1
ERROR: Could not find a version that satisfies the requirement torch2.4.1 (from versions: none)
ERROR: No matching distribution found for torch2.4.1
ERROR: Could not find a version that satisfies the requirement torch2.4.0 (from versions: none)
ERROR: No matching distribution found for torch2.4.0
ERROR: Could not find a version that satisfies the requirement torch2.3.1 (from versions: none)
ERROR: No matching distribution found for torch2.3.1

are you trying to install PyTorch for DentalSegmentator? You can uninstall the PyTorch extension and DentalSegmentator automatically installs the required library on its first usage (including the required PyTorch version). That worked for me.

If you want to install a specific version, you need to specify it using “PyPi” syntaxe :

Using “<2.6” should force the install to the latest torch version before 2.6

For 2.5.1, you should use “==2.5.1”

Just a follow up on this problem, the issue is currently being tracked in the nnUNet repository to change how the nnUNet loads its weights : PyTorch 2.6 has changed the default value of `weights_only` to `True`, breaking the loading of some `nnunetv2` models · Issue #2681 · MIC-DKFZ/nnUNet · GitHub

The nnUNetv2 developer issued a fix and created a new release. Install the latest to use PyTorch 2.6. Also note that torchvision 0.21.0 is specifically compatible with PyTorch 2.6.0. See this table for more info.




dear professor,when i download this“dentalsegmentator” extension,some questions above appeaer,how can i solve with them?

Hi @yijie3091,

As pointed out by the message, the weight download failed because your internet connection was down.

To troubleshoot this, please follow the instructions here : GitHub - gaudot/SlicerDentalSegmentator: 3D Slicer extension for fully-automatic segmentation of CT and CBCT dental volumes.

You will need to unzip the weight files in the correct folder and create a download_info.json file in the ML folder.

Best,
Thibault

I have downloaded the zip files,but I can not
find the weight file,even I do not have the LM folder.In addition ,my windows do not have GPU.

Thibault Pelletier via 3D Slicer Community <notifications@slicer.discoursemail.com>于2025年5月14日 周三14:20写道:

Hi @yijie3091,

As written in the troubleshooting section, you need to :

If everything works well, you should have the following file accessible :
C:\Users\<user_name>\AppData\Local\slicer.org\Slicer 5.8.1\slicer.org\Extensions-33241\DentalSegmentator\lib\Slicer-5.8\qt-scripted-modules\Resources\ML\Dataset111_453CT\nnUNetTrainer__nnUNetPlans__3d_fullres\dataset.json

Best,
Thibault

I have followed your instructions step by step,but it seems have a problem.How can i solve with it?

Thibault Pelletier via 3D Slicer Community <notifications@slicer.discoursemail.com>于2025年5月14日 周三18:59写道:

Hi @yijie3091,

Please don’t take pictures of you screen in the future and instead copy / paste the contents of the error messages and python console when providing context for your issues.

Regarding the issue itself, it’s indicating that the “dataset.json” file is missing in the python console. This indicates that your ML file tree is still not correct.

Your Resources folder should contain the following file structure :

+---Icons
|       DentalSegmentator.png
|       DentalSegmentator_full_icon.png
|       info.png
|       loading.gif
|       start_icon.png
|       
\---ML
    |   Dataset111_453CT_v100.zip
    |   download_info.json
    |   
    \---Dataset111_453CT
        \---nnUNetTrainer__nnUNetPlans__3d_fullres
            |   dataset.json
            |   plans.json
            |   
            \---fold_0
                    checkpoint_final.pth

FYI you can print your file structure on windows using the command prompt and the tree /F /A command.

Best,
Thibault