Exceptions while using my own dataset
See original GitHub issueI have my own nifti dataset for labelling. I could see the below Issue while starting the monaiLabel server.
[2022-02-21 05:04:44,855] [15675] [MainThread] [INFO] (monailabel.tasks.scoring.epistemic:110) - Using /home/ec2-user/efs/apps/deepedit/model/pretrained_dynunet.pt for running Epistemic
Traceback (most recent call last):
File "/opt/conda/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/conda/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/ec2-user/.local/lib/python3.9/site-packages/monailabel/interfaces/utils/app.py", line 132, in <module>
run_main()
File "/home/ec2-user/.local/lib/python3.9/site-packages/monailabel/interfaces/utils/app.py", line 123, in run_main
result = a.scoring(request)
File "/home/ec2-user/.local/lib/python3.9/site-packages/monailabel/interfaces/app.py", line 307, in scoring
return task(copy.deepcopy(request), datastore if datastore else self.datastore())
File "/home/ec2-user/.local/lib/python3.9/site-packages/monailabel/tasks/scoring/epistemic.py", line 126, in __call__
model, model_ts = self._load_model(self.model, self.network)
File "/home/ec2-user/.local/lib/python3.9/site-packages/monailabel/tasks/scoring/epistemic.py", line 117, in _load_model
model.load_state_dict(model_state_dict)
File "/home/ec2-user/.local/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1482, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for DynUNet:
Unexpected key(s) in state_dict: "deep_supervision_heads.0.conv.conv.weight", "deep_supervision_heads.0.conv.conv.bias", "deep_supervision_heads.1.conv.conv.weight", "deep_supervision_heads.1.conv.conv.bias", "deep_supervision_heads.2.conv.conv.weight", "deep_supervision_heads.2.conv.conv.bias", "deep_supervision_heads.3.conv.conv.weight", "deep_supervision_heads.3.conv.conv.bias".
Facing Similar error after connecting from 3DSlicer and trying to fetch the next image. and also extra error ValueError: len(spatial_size) must be greater or equal to img spatial dimensions, got spatial_size=2 img=3.
[2022-02-21 05:18:00,001] [15313] [MainThread] [INFO] (monailabel.interfaces.utils.transform:98) - INV - Transform (ToTensord): Time: 0.0111; image: (1, 256, 256, 128)(float32); pred: torch.Size([1, 256, 256, 128])(torch.float32)
[2022-02-21 05:18:00,008] [15313] [MainThread] [ERROR] (uvicorn.error:380) - Exception in ASGI application
Traceback (most recent call last):
File "/home/ec2-user/.local/lib/python3.9/site-packages/uvicorn/protocols/http/h11_impl.py", line 377, in run_asgi
result = await app(self.scope, self.receive, self.send)
File "/home/ec2-user/.local/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 75, in __call__
return await self.app(scope, receive, send)
File "/home/ec2-user/.local/lib/python3.9/site-packages/fastapi/applications.py", line 212, in __call__
await super().__call__(scope, receive, send)
File "/home/ec2-user/.local/lib/python3.9/site-packages/starlette/applications.py", line 112, in __call__
await self.middleware_stack(scope, receive, send)
File "/home/ec2-user/.local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 181, in __call__
raise exc
File "/home/ec2-user/.local/lib/python3.9/site-packages/starlette/middleware/errors.py", line 159, in __call__
await self.app(scope, receive, _send)
File "/home/ec2-user/.local/lib/python3.9/site-packages/starlette/middleware/cors.py", line 84, in __call__
await self.app(scope, receive, send)
File "/home/ec2-user/.local/lib/python3.9/site-packages/starlette/exceptions.py", line 82, in __call__
raise exc
File "/home/ec2-user/.local/lib/python3.9/site-packages/starlette/exceptions.py", line 71, in __call__
await self.app(scope, receive, sender)
File "/home/ec2-user/.local/lib/python3.9/site-packages/starlette/routing.py", line 656, in __call__
await route.handle(scope, receive, send)
File "/home/ec2-user/.local/lib/python3.9/site-packages/starlette/routing.py", line 259, in handle
await self.app(scope, receive, send)
File "/home/ec2-user/.local/lib/python3.9/site-packages/starlette/routing.py", line 61, in app
response = await func(request)
File "/home/ec2-user/.local/lib/python3.9/site-packages/fastapi/routing.py", line 226, in app
raw_response = await run_endpoint_function(
File "/home/ec2-user/.local/lib/python3.9/site-packages/fastapi/routing.py", line 159, in run_endpoint_function
return await dependant.call(**values)
File "/home/ec2-user/.local/lib/python3.9/site-packages/monailabel/endpoints/infer.py", line 177, in api_run_inference
return run_inference(background_tasks, model, image, session_id, params, file, label, output)
File "/home/ec2-user/.local/lib/python3.9/site-packages/monailabel/endpoints/infer.py", line 160, in run_inference
result = instance.infer(request)
File "/home/ec2-user/.local/lib/python3.9/site-packages/monailabel/interfaces/app.py", line 231, in infer
result_file_name, result_json = task(request)
File "/home/ec2-user/.local/lib/python3.9/site-packages/monailabel/interfaces/tasks/infer.py", line 237, in __call__
data = self.run_invert_transforms(data, pre_transforms, self.inverse_transforms())
File "/home/ec2-user/.local/lib/python3.9/site-packages/monailabel/interfaces/tasks/infer.py", line 288, in run_invert_transforms
d = run_transforms(d, transforms, inverse=True, log_prefix="INV")
File "/home/ec2-user/.local/lib/python3.9/site-packages/monailabel/interfaces/utils/transform.py", line 80, in run_transforms
data = t.inverse(data)
File "/home/ec2-user/.local/lib/python3.9/site-packages/monai/transforms/spatial/dictionary.py", line 589, in inverse
d[key] = inverse_transform(d[key])
File "/home/ec2-user/.local/lib/python3.9/site-packages/monai/transforms/spatial/array.py", line 447, in __call__
raise ValueError(
ValueError: len(spatial_size) must be greater or equal to img spatial dimensions, got spatial_size=2 img=3.
Traceback (most recent call last):
File "/opt/conda/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/conda/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/ec2-user/.local/lib/python3.9/site-packages/monailabel/interfaces/utils/app.py", line 132, in <module>
run_main()
File "/home/ec2-user/.local/lib/python3.9/site-packages/monailabel/interfaces/utils/app.py", line 123, in run_main
result = a.scoring(request)
File "/home/ec2-user/.local/lib/python3.9/site-packages/monailabel/interfaces/app.py", line 307, in scoring
return task(copy.deepcopy(request), datastore if datastore else self.datastore())
File "/home/ec2-user/.local/lib/python3.9/site-packages/monailabel/tasks/scoring/epistemic.py", line 126, in __call__
model, model_ts = self._load_model(self.model, self.network)
File "/home/ec2-user/.local/lib/python3.9/site-packages/monailabel/tasks/scoring/epistemic.py", line 117, in _load_model
model.load_state_dict(model_state_dict)
File "/home/ec2-user/.local/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1482, in load_state_dict
raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format(
RuntimeError: Error(s) in loading state_dict for DynUNet:
Unexpected key(s) in state_dict: "deep_supervision_heads.0.conv.conv.weight", "deep_supervision_heads.0.conv.conv.bias", "deep_supervision_heads.1.conv.conv.weight", "deep_supervision_heads.1.conv.conv.bias", "deep_supervision_heads.2.conv.conv.weight", "deep_supervision_heads.2.conv.conv.bias", "deep_supervision_heads.3.conv.conv.weight", "deep_supervision_heads.3.conv.conv.bias".
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8
Top Results From Across the Web
Add Custom Data to Exceptions -- Visual Studio Magazine
There are two things to avoid here. First, make sure that retrieving the information you're going to put in the Data collection won't...
Read more >Errors while trying to import and format my own dataset in ...
My function returns a (train_images, train_labels), (test_images, test_labels) object where both part are split accordingly. Both "images" list ...
Read more >Should we use custom exceptions in Python?
Python has so many built-in exceptions that we rarely need to create and use custom ones. Or do we? Custom exceptions: Own your...
Read more >errors in finetuning the clip using my own datasets · Issue #81
2 errors detected in the compilation of "default_program". nvrtc compilation failed: #define NAN __int_as_float(0x7fffffff) #define POS_INFINITY ...
Read more >How to Define Custom Exceptions in Python ...
In Python, we can define custom exceptions by creating a new class that is derived from the built-in Exception class. Here's the syntax...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @diazandr3s ,
It is working now. Thanks for the help.
Hi @j-sieger,
Please remove the
SingleLabelSingleModalityd
transform in both infer and train files.This transform makes sure the images are single modality and labels and single class. However, this error is common when some headers are lost after converting from DICOM to NIFTI. I need to investigate more on this.
After removing those you should be able to perform inference. If not, use the ITK reader in the
LoadImaged
transform like this:reader="itkreader"
For some reason, I kept thinking on the deepedit_multilabel and thought I did the same for the deepedit App. Sorry about this.
Please let me know how that goes 😃