# Auto3DSeg with model trained using MONAILabel

**URL:** <https://discourse.slicer.org/t/auto3dseg-with-model-trained-using-monailabel/39927>\
**Category:** Support\
**Tags:** segmentation, python\
**Created:** [October 29, 2024, 7:59pm UTC](https://discourse.slicer.org/t/auto3dseg-with-model-trained-using-monailabel/39927 "2024-10-29T19:59:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![h\_z1](https://avatars.discourse-cdn.com/v4/letter/h/bc8723/32.png) [@h\_z1](https://discourse.slicer.org/u/h_z1)\
**Post date:** [October 29, 2024, 7:59pm UTC](https://discourse.slicer.org/t/auto3dseg-with-model-trained-using-monailabel/39927/1 "2024-10-29T19:59:15Z")

</div>

Hi,  
I came across this discussion [post](https://github.com/Project-MONAI/MONAILabel/discussions/1701) that referenced another post in SlicerMONAIAuto3DSeg about using inference only, which is what I am currently interested in. So, I was wondering if it was possible to use a model that was trained and annotated using the radiology app of MONAILabel to do the inference (using auto3dseg\_segresnet\_inference.py). I followed the format of the example command, but I keep getting the same erorr when I tried to run the command. I tried putting the path to the model that I have for segmentation using radiology sample app for MONAI Label, but also with wholeBody\_ct\_segmentation\_v0.1.9 (pretty sure used SegResNet), and they both give me the same error:

```auto
(venv) C:\Users\hz\Documents\auto3dseg_script>python auto3dseg_segresnet_inference.py --model_file "C:\Users\hz\Documents\auto3dseg_script\wholeBody_ct_segmentation_v0.1.9\wholeBody_ct_segmentation\models\model.pt" --image_file "C:\Users\hz\Documents\datasets\Task09_Spleen\imagesTr\spleen_2.nii.gz" --result_file .
C:\Users\hz\AppData\Local\Programs\Python\Python39\lib\site-packages\ignite\handlers\checkpoint.py:17: DeprecationWarning: `TorchScript` support for functional optimizers is deprecated and will be removed in a future PyTorch release. Consider using the `torch.compile` optimizer instead.
  from torch.distributed.optim import ZeroRedundancyOptimizer
You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
Traceback (most recent call last):
  File "C:\Users\hz\Documents\auto3dseg_script\auto3dseg_segresnet_inference.py", line 361, in <module>
    fire.Fire(main)
  File "C:\Users\hz\AppData\Local\Programs\Python\Python39\lib\site-packages\fire\core.py", line 143, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "C:\Users\hz\AppData\Local\Programs\Python\Python39\lib\site-packages\fire\core.py", line 477, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "C:\Users\hz\AppData\Local\Programs\Python\Python39\lib\site-packages\fire\core.py", line 693, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "C:\Users\hz\AppData\Local\Programs\Python\Python39\lib\site-packages\torch\utils\_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
  File "C:\Users\hz\Documents\auto3dseg_script\auto3dseg_segresnet_inference.py", line 69, in main
    raise ValueError('Config not found in checkpoint (not a auto3dseg/segresnet model):' + str(model_file))
ValueError: Config not found in checkpoint (not a auto3dseg/segresnet model):C:\Users\hz\Documents\auto3dseg_script\wholeBody_ct_segmentation_v0.1.9\wholeBody_ct_segmentation\models\model.pt

```

I am not sure if I just misunderstood what should I put for the path to my model or if the model just does not work with auto3dseg\_segresnet\_inference.py 😅

Thank you!

---

<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:** [November 26, 2024, 3:02pm UTC](https://discourse.slicer.org/t/auto3dseg-with-model-trained-using-monailabel/39927/2 "2024-11-26T15:02:06Z")

</div>

> [@h\_z1](#):
>
> using the radiology app of MONAILabel to do the inference

Hi @h_z1,

Thanks for asking this.

If you trained a model using the radiology app of MONAILabel, you could use the main script withing the radiology app/folder to run inference without starting the server: [MONAILabel/sample-apps/radiology/main.py at da0247ee54651014e841d6261f6d00908f4108cc · Project-MONAI/MONAILabel · GitHub](https://github.com/Project-MONAI/MONAILabel/blob/da0247ee54651014e841d6261f6d00908f4108cc/sample-apps/radiology/main.py#L286-L371)

The script _[auto3dseg\_segresnet\_inference.py](https://github.com/lassoan/SlicerMONAIAuto3DSeg/blob/main/MONAIAuto3DSeg/Scripts/auto3dseg_segresnet_inference.py)_ is mainly for Auto3DSeg models: [New extension: MONAI Auto3DSeg - raise the bar in AI medical image segmentation](https://discourse.slicer.org/t/new-extension-monai-auto3dseg-raise-the-bar-in-ai-medical-image-segmentation/35680)

Hope this helps,
