Skip to content

Navigation Menu

Sign in
Sign up
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

error brats mri generative model #485

oledrenth started this conversation in General
Discussion options

I want to generate 3D scans using the pre-trained diffusion model of Monai (version 1.3.0). The model is Brats mri generative diffusion version: 1.0.6. My python version is 3.10.12.
If I want to train the latent diffusion model, it seems not to work.

The prompt that should train the LD model in the read.me file is
$ python -m monai.bundle run --config_file "['configs/train_autoencoder.json','configs/train_diffusion.json']"

This is the error I get:

2024年04月26日 13:08:32,628 - INFO - --- input summary of monai.bundle.scripts.run ---
2024年04月26日 13:08:32,628 - INFO - > config_file: ['configs/train_autoencoder.json', 'configs/train_diffusion.json']
2024年04月26日 13:08:32,629 - INFO - ---

/home/ole/.local/lib/python3.10/site-packages/monai/utils/deprecate_utils.py:321: FutureWarning: monai.bundle.workflows ConfigWorkflow.init:workflow_type: Current default value of argument workflow_type=None has been deprecated since version 1.2. It will be changed to workflow_type=train in version 1.4.
warn_deprecated(argname, msg, warning_category)
2024年04月26日 13:08:32,629 - INFO - Setting logging properties based on config: configs/logging.conf.

Traceback (most recent call last):
File "/home/ole/.local/lib/python3.10/site-packages/monai/bundle/config_item.py", line 293, in instantiate
return instantiate(modname, mode, **args)
File "/home/ole/.local/lib/python3.10/site-packages/monai/utils/module.py", line 248, in instantiate
raise ModuleNotFoundError(f"Cannot locate class or function path: '{__path}'.")
ModuleNotFoundError: Cannot locate class or function path: 'generative.networks.nets.AutoencoderKL'.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/home/ole/.local/lib/python3.10/site-packages/monai/bundle/main.py", line 31, in
fire.Fire()
File "/home/ole/.local/lib/python3.10/site-packages/fire/core.py", line 143, in Fire
component_trace = _Fire(component, args, parsed_flag_args, context, name)
File "/home/ole/.local/lib/python3.10/site-packages/fire/core.py", line 477, in _Fire
component, remaining_args = _CallAndUpdateTrace(
File "/home/ole/.local/lib/python3.10/site-packages/fire/core.py", line 693, in _CallAndUpdateTrace
component = fn(*varargs, **kwargs)
File "/home/ole/.local/lib/python3.10/site-packages/monai/bundle/scripts.py", line 787, in run
workflow.run()
File "/home/ole/.local/lib/python3.10/site-packages/monai/bundle/workflows.py", line 310, in run
return self._run_expr(id=self.run_id)
File "/home/ole/.local/lib/python3.10/site-packages/monai/bundle/workflows.py", line 344, in _run_expr
return self.parser.get_parsed_content(id, **kwargs) if id in self.parser else None
File "/home/ole/.local/lib/python3.10/site-packages/monai/bundle/config_parser.py", line 290, in get_parsed_content
return self.ref_resolver.get_resolved_content(id=id, **kwargs)
File "/home/ole/.local/lib/python3.10/site-packages/monai/bundle/reference_resolver.py", line 193, in get_resolved_content
return self._resolve_one_item(id=id, **kwargs)
File "/home/ole/.local/lib/python3.10/site-packages/monai/bundle/reference_resolver.py", line 163, in _resolve_one_item
self._resolve_one_item(id=d, waiting_list=waiting_list, **kwargs)
File "/home/ole/.local/lib/python3.10/site-packages/monai/bundle/reference_resolver.py", line 163, in _resolve_one_item
self._resolve_one_item(id=d, waiting_list=waiting_list, **kwargs)
File "/home/ole/.local/lib/python3.10/site-packages/monai/bundle/reference_resolver.py", line 171, in _resolve_one_item
self.resolved_content[id] = item.instantiate() if kwargs.get("instantiate", True) else item
File "/home/ole/.local/lib/python3.10/site-packages/monai/bundle/config_item.py", line 295, in instantiate
raise RuntimeError(f"Failed to instantiate {self}") from e
RuntimeError: Failed to instantiate ConfigComponent:
{'target': 'generative.networks.nets.AutoencoderKL',
'attention_levels': [False, False, False],
'in_channels': 1,
'latent_channels': 8,
'norm_eps': 1e-06,
'norm_num_groups': 32,
'num_channels': [64, 128, 256],
'num_res_blocks': 2,
'out_channels': 1,
'spatial_dims': 3,
'with_decoder_nonlocal_attn': False,
'with_encoder_nonlocal_attn': False}

So it seems there is something wrong with the config component. Maybe the version of the model (1.0.6) I use is outdated and not compatible with the current monai library (1.3.0)? I have not changed the config files.

Thank you, Ole

You must be logged in to vote

Replies: 2 comments 1 reply

Comment options

Can you try installing monai-generative with pip install monai-generative then trying again?

You must be logged in to vote
0 replies
Comment options

Hi! I installed it and the error *ModuleNotFoundError: Cannot locate class or function path: 'generative.networks.nets.AutoencoderKL' *seemed to disappear. However, now my error is: *ModuleNotFoundError: Cannot locate class or function path: 'AddChanneld'.* *...* *RuntimeError: Failed to instantiate ConfigComponent: {'_target_': 'AddChanneld', 'keys': 'image'}* This is located in the train_autoencoder.json file under "preprocessing_transforms" Could this error be the fact that AddChanneld is not used anymore? Thank you for your help and time!
...
On 2024年4月30日 at 11:41, Mark Graham ***@***.***> wrote: Can you try installing monai-generative with pip install monai-generative then trying again? — Reply to this email directly, view it on GitHub <#485 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AVTKIAEWIOTYCRJEMP7A6GDY75ROLAVCNFSM6AAAAABG3IKO6GVHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4TENZTGMZTO> . You are receiving this because you authored the thread.Message ID: <Project-MONAI/GenerativeModels/repo-discussions/485/comments/9273337@ github.com>
You must be logged in to vote
1 reply
Comment options

Could you try with monai version 1.2, or 1.1? i think addchanneld has been removed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /