Project-MONAI / Project-MONAI/model-zoo

TypeError when using lung_nodule_ct_detection

Open
#492 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
338
Forks
106
PR merge metrics
No merged PRs in 30d

Description

Describe the bug
I have downloaded the lung_nodule_ct_detection bundle (0.5.9) and I try to follow the steps of https://docs.monai.io/projects/monai-deploy-app-sdk/en/latest/notebooks/tutorials/06_monai_bundle_app.html# to create a MAP using the downloaded bundle. Unfortunately, I fail already when trying to run the app locally, i.e., using something like:

app = LungNoduleDetectionApp()

app.run(
    input=str(input_dir),
    output=str(output_dir),
    model=str(model_dir),
)

This fails with the following error:

Going to initiate execution of operator MonaiBundleInferenceOperator
Executing operator MonaiBundleInferenceOperator (Process ID: 2193, Operator ID: 44d6d5d5-79ea-497e-bed5-469f23959f76)
/home/da-for/.pyenv/versions/monai/lib/python3.10/site-packages/monai/utils/deprecate_utils.py:321: FutureWarning: monai.transforms.io.dictionary LoadImaged.__init__:image_only: Current default value of argument `image_only=False` has been deprecated since version 1.1. It will be changed to `image_only=True` in version 1.3.
  warn_deprecated(argname, msg, warning_category)
/home/da-for/.pyenv/versions/monai/lib/python3.10/site-packages/monai/utils/deprecate_utils.py:221: FutureWarning: monai.transforms.utility.dictionary EnsureChannelFirstd.__init__:meta_key_postfix: Argument `meta_key_postfix` has been deprecated since version 0.9. not needed if image is type `MetaTensor`.
  warn_deprecated(argname, msg, warning_category)
Traceback (most recent call last):
  File "/home/da-for/code/byoai-workshop/workshops/monai-application-package/lung_nodule_ct_detection/run_model_locally.py", line 22, in <module>
    app.run(
  File "/home/da-for/code/byoai-workshop/workshops/monai-application-package/lung_nodule_ct_detection/app.py", line 52, in run
    super().run(*args, **kwargs)
  File "/home/da-for/.pyenv/versions/monai/lib/python3.10/site-packages/monai/deploy/core/application.py", line 429, in run
    executor_obj.run()
  File "/home/da-for/.pyenv/versions/monai/lib/python3.10/site-packages/monai/deploy/core/executors/single_process_executor.py", line 125, in run
    op.compute(op_exec_context.input_context, op_exec_context.output_context, op_exec_context)
  File "/home/da-for/.pyenv/versions/monai/lib/python3.10/site-packages/monai/deploy/operators/monai_bundle_inference_operator.py", line 579, in compute
    outputs: Any = self.predict(data=first_input, **other_inputs)  # Use type Any to quiet MyPy complaints.
  File "/home/da-for/.pyenv/versions/monai/lib/python3.10/site-packages/monai/deploy/operators/monai_bundle_inference_operator.py", line 604, in predict
    return self._inferer(inputs=data, network=self._model_network, *args, **kwargs)
  File "/home/da-for/code/byoai-workshop/workshops/monai-application-package/lung_nodule_ct_detection/scripts/detection_inferer.py", line 55, in __call__
    self.detector.network = network
  File "/home/da-for/.pyenv/versions/monai/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1304, in __setattr__
    raise TypeError("cannot assign '{}' as child module '{}' "
TypeError: cannot assign 'monai.deploy.core.models.torch_model.TorchScriptModel' as child module 'network' (torch.nn.Module or None expected)

Environment
Windows 11 with WSL2 and Ubuntu 22.04

Ensuring you use the relevant python executable, please paste the output of:

MONAI version: 1.2.0
Numpy version: 1.22.2
Pytorch version: 1.13.1+cu117
MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False
MONAI rev id: c33f1ba588ee00229a309000e888f9817b4f1934
MONAI __file__: /home/da-for/.pyenv/versions/monai/lib/python3.10/site-packages/monai/__init__.py

Optional dependencies:
Pytorch Ignite version: 0.4.9
ITK version: NOT INSTALLED or UNKNOWN VERSION.
Nibabel version: 4.0.1
scikit-image version: 0.21.0
Pillow version: 10.0.0
Tensorboard version: NOT INSTALLED or UNKNOWN VERSION.
gdown version: NOT INSTALLED or UNKNOWN VERSION.
TorchVision version: 0.14.1+cu117
tqdm version: 4.66.1
lmdb version: NOT INSTALLED or UNKNOWN VERSION.
psutil version: 5.9.5
pandas version: 2.0.3
einops version: NOT INSTALLED or UNKNOWN VERSION.
transformers version: NOT INSTALLED or UNKNOWN VERSION.
mlflow version: NOT INSTALLED or UNKNOWN VERSION.
pynrrd version: NOT INSTALLED or UNKNOWN VERSION.

For details about installing the optional dependencies, please visit:
    https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies

System: Linux
Linux version: Ubuntu 22.04.3 LTS
Platform: Linux-6.1.21.1-microsoft-standard-WSL2+-x86_64-with-glibc2.35
Processor: x86_64
Machine: x86_64
Python version: 3.10.4
Process name: python
Command: ['/home/da-for/.pyenv/versions/monai/bin/python', '-c', 'import monai; monai.config.print_debug_info()']
Open files: []
Num physical CPUs: 2
Num logical CPUs: 4
Num usable CPUs: 4
CPU usage (%): [7.8, 7.3, 8.2, 100.0]
CPU freq. (MHz): 2304
Load avg. in last 1, 5, 15 mins (%): [0.7, 1.1, 0.3]
Disk usage (%): 27.3
Avg. sensor temp. (Celsius): UNKNOWN for given OS
Total physical memory (GB): 15.6
Available memory (GB): 12.2
Used memory (GB): 3.1

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with scripts/detection_inferer.py at the call method shown in the traceback, then trace how MonaiBundleInferenceOperator supplies the model to it. Reproduce the local lung_nodule_ct_detection run with the listed MONAI, PyTorch, and Python versions. Done means the app runs past model assignment without the TypeError and the documented local workflow completes.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
backend, machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.