Hi,
I came across this discussion post 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:
(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!