Monailabel issue - Internal Server Error

Facing a few issues while using monailabel training.
1)
[Python] Failed to run inference in MONAI Label Server.
[Python] Message: Status: 500; Response: Internal Server Error

Traceback (most recent call last):
File “C:/Users/admin/AppData/Local/slicer.org/Slicer 5.6.2/slicer.org/Extensions-32448/MONAILabel/lib/Slicer-5.6/qt-scripted-modules/MONAILabel.py”, line 1545, in onClickSegmentation
result_file, params = self.logic.infer(model, image_file, params, session_id=self.getSessionId())
File “C:/Users/admin/AppData/Local/slicer.org/Slicer 5.6.2/slicer.org/Extensions-32448/MONAILabel/lib/Slicer-5.6/qt-scripted-modules/MONAILabel.py”, line 2321, in infer
result_file, params = client.infer(model, image_in, params, label_in, file, session_id)
File “C:\Users\admin\AppData\Local\slicer.org\Slicer 5.6.2\slicer.org\Extensions-32448\MONAILabel\lib\Slicer-5.6\qt-scripted-modules\MONAILabelLib\client.py”, line 344, in infer
raise MONAILabelClientException(
MONAILabelLib.client.MONAILabelClientException: (1, ‘Status: 500; Response: Internal Server Error’)

  1. training bar and accuracy bar shows training error and accuracy 0.

3)happens during training
RuntimeError: Error(s) in loading state_dict for SegResNet:
size mismatch for conv_final.2.conv.weight: copying a param with shape torch.Size([26, 32, 1, 1, 1]) from checkpoint, the shape in current model is torch.Size([3, 32, 1, 1, 1]).
size mismatch for conv_final.2.conv.bias: copying a param with shape torch.Size([26]) from checkpoint, the shape in current model is torch.Size([3]).

Hi @Daniel_Lo,

It looks like the issue might be related to a mismatch between the number of labels the model was trained on and those defined in the config file. Could you please share a bit more detail so we can help replicate the issue?

Also, for any questions specifically about MONAI Label, it might be helpful to comment directly on the MONAI Label repository: GitHub - Project-MONAI/MONAILabel: MONAI Label is an intelligent open source image labeling and learning tool.

Best,

So i have same trouble.

I make training from scratch, change segmentation file and made active learning 100%.

Monailabel is install on localhost Fujitsu Primergy with 192 GB RAM and nVidia GTX 1070 under Ubuntu 24.04.

Dataset for learning is from tutorial learning from scratch.

I want to autosegment data from MosMedData: Chest CT Scans with COVID-19 Related Findings COVID19_1110 1.0 - Academic Torrents

Error in console: File “/home/mirospiro/anaconda3/lib/python3.12/site-packages/monailabel/tasks/infer/basic_infer.py”, line 479, in _get_network
network.load_state_dict(model_state_dict, strict=self.load_strict)
File “/home/mirospiro/anaconda3/lib/python3.12/site-packages/torch/nn/modules/module.py”, line 2584, in load_state_dict
raise RuntimeError(
RuntimeError: Error(s) in loading state_dict for SegResNet:
size mismatch for conv_final.2.conv.weight: copying a param with shape torch.Size([26, 32, 1, 1, 1]) from checkpoint, the shape in current model is torch.Size([3, 32, 1, 1, 1]).
size mismatch for conv_final.2.conv.bias: copying a param with shape torch.Size([26]) from checkpoint, the shape in current model is torch.Size([3]).
[2025-02-14 19:56:02,928] [295788] [Thread-4] [INFO] (monailabel.utils.sessions:

1 Like

Hi @Miro_Spiro,

Thanks for sharing the logs.
From the log, it seems you’re trying to train a model for a different number of labels/segments than the pretrained model. I suggest you remove the pretrained file (.pt file) from the model folder and set this flag to false before starting the server: MONAILabel/sample-apps/radiology/lib/configs/segmentation.py at b205e92d5e5fcd265c17e33eb13ccfd855b74e7f · Project-MONAI/MONAILabel · GitHub

Also, I strongly suggest you post future insights/comments dirently in the MONAI Label repo :slight_smile:

Hope this helps