# Monailabel issue - Internal Server Error

**URL:** <https://discourse.slicer.org/t/monailabel-issue-internal-server-error/39699>\
**Category:** Support\
**Tags:** segmentation, python, monailabel\
**Created:** [October 14, 2024, 5:40pm UTC](https://discourse.slicer.org/t/monailabel-issue-internal-server-error/39699 "2024-10-14T17:40:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Daniel\_Lo](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/daniel_lo/32/77935_2.png) [@Daniel\_Lo](https://discourse.slicer.org/u/Daniel_Lo)\
**Post date:** [October 14, 2024, 5:40pm UTC](https://discourse.slicer.org/t/monailabel-issue-internal-server-error/39699/1 "2024-10-14T17:40:02Z")

</div>

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.  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/a/b/ab1f1b4f23445c018abee98db0d47d5840aa3307.jpeg)

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]).

---

<div class="post-metadata">

**Author:** ![diazandr3s](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/diazandr3s/32/9973_2.png) [@diazandr3s](https://discourse.slicer.org/u/diazandr3s)\
**Post date:** [October 17, 2024, 9:51pm UTC](https://discourse.slicer.org/t/monailabel-issue-internal-server-error/39699/2 "2024-10-17T21:51:19Z")

</div>

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.](https://github.com/Project-MONAI/MONAILabel)

Best,

---

<div class="post-metadata">

**Author:** ![Miro\_Spiro](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/miro_spiro/32/79457_2.png) [@Miro\_Spiro](https://discourse.slicer.org/u/Miro_Spiro)\
**Post date:** [February 14, 2025, 7:13pm UTC](https://discourse.slicer.org/t/monailabel-issue-internal-server-error/39699/3 "2025-02-14T19:13:41Z")

</div>

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](https://academictorrents.com/details/f2175c4676e041ea65568bb70c2bcd15c7325fd2)

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:

---

<div class="post-metadata">

**Author:** ![diazandr3s](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/diazandr3s/32/9973_2.png) [@diazandr3s](https://discourse.slicer.org/u/diazandr3s)\
**Post date:** [February 17, 2025, 10:57am UTC](https://discourse.slicer.org/t/monailabel-issue-internal-server-error/39699/4 "2025-02-17T10:57:49Z")

</div>

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](https://github.com/Project-MONAI/MONAILabel/blob/b205e92d5e5fcd265c17e33eb13ccfd855b74e7f/sample-apps/radiology/lib/configs/segmentation.py#L77)

Also, I strongly suggest you post future insights/comments dirently in the [MONAI Label repo](https://github.com/Project-MONAI/MONAILabel) 🙂

Hope this helps
