Project-MONAI / model-zoo

MONAI Model Zoo that hosts models in the MONAI Bundle format.
Apache License 2.0
190 stars 67 forks source link

Brats bundle compatible issue #66

Closed KumoLiu closed 2 years ago

KumoLiu commented 2 years ago

Describe the bug Brats bundle is not compatible with 0.9.1.

To Reproduce Infer with the following test command, you will get an error below. python -m monai.bundle run evaluating --meta_file configs/metadata.json --config_file configs/inference.json --logging_file configs/logging.conf

Error information

Traceback (most recent call last):
  File "/opt/monai/monai/transforms/transform.py", line 90, in apply_transform
    return _apply_transform(transform, data, unpack_items)
  File "/opt/monai/monai/transforms/transform.py", line 54, in _apply_transform
    return transform(parameters)
  File "/opt/monai/monai/transforms/post/dictionary.py", line 642, in __call__
    transform_info = d[InvertibleTransform.trace_key(orig_key)]
KeyError: 'image_transforms'

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

Traceback (most recent call last):
  File "/opt/monai/monai/transforms/transform.py", line 90, in apply_transform
    return _apply_transform(transform, data, unpack_items)
  File "/opt/monai/monai/transforms/transform.py", line 54, in _apply_transform
    return transform(parameters)
  File "/opt/monai/monai/transforms/compose.py", line 173, in __call__
    input_ = apply_transform(_transform, input_, self.map_items, self.unpack_items, self.log_stats)
  File "/opt/monai/monai/transforms/transform.py", line 114, in apply_transform
    raise RuntimeError(f"applying transform {transform}") from e
RuntimeError: applying transform <monai.transforms.post.dictionary.Invertd object at 0x7faae6b6c130>

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

Traceback (most recent call last):
  File "/opt/conda/lib/python3.8/site-packages/ignite/engine/engine.py", line 840, in _run_once_on_dataset
    self.state.output = self._process_function(self, self.state.batch)
  File "/opt/monai/monai/engines/evaluator.py", line 286, in _iteration
    engine.fire_event(IterationEvents.MODEL_COMPLETED)
  File "/opt/conda/lib/python3.8/site-packages/ignite/engine/engine.py", line 445, in fire_event
    return self._fire_event(event_name)
  File "/opt/conda/lib/python3.8/site-packages/ignite/engine/engine.py", line 421, in _fire_event
    func(*first, *(event_args + others), **kwargs)
  File "/opt/monai/monai/engines/workflow.py", line 234, in _run_postprocessing
    engine.state.batch[i], engine.state.output[i] = engine_apply_transform(b, o, posttrans)
  File "/opt/monai/monai/engines/utils.py", line 247, in engine_apply_transform
    transformed_data = apply_transform(transform, data)
  File "/opt/monai/monai/transforms/transform.py", line 114, in apply_transform
    raise RuntimeError(f"applying transform {transform}") from e
RuntimeError: applying transform <monai.transforms.compose.Compose object at 0x7faae6c89a90>
wyli commented 2 years ago

Could you please include detailed error messages? It'll be useful for the users running into a similar issue.

see also: https://github.com/Project-MONAI/MONAI/discussions/4764

tangy5 commented 2 years ago

Hi @KumoLiu This is partly due to the Invertd postprocessing. Please ensure the last preprocessing transform as the Ensuretyped, no the ToTensord.

Or adjusting the preprocessing transforms, some are not invertible.

KumoLiu commented 2 years ago

Hi @tangy5 Thanks for your advice! I just raised this issue to submit the pr to fix the bundle.