Project-MONAI / Project-MONAI/MONAILabel

ImportError: cannot import name 'AddChanneld' from 'monai.transforms'

Open
#1,571 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
891
Forks
269
Avg merge
15h 41m
Merged PRs (30d)
1

Description

Please use MONAILabel's Discussions tab
For questions relating to MONAILabel usage, please do not create an issue.

Instead, use MONAI's GitHub Discussions tab. This can be found next to Issues and Pull Requests along the top of our repository.

My Trackback as follow:

(FUXIAN) PS C:\Users\xiaoqianmu> monailabel start_server --app apps/radiology --studies datasets/Task09_Spleen/imagesTr --conf models Using PYTHONPATH=C:\Anaconda\envs;
""
[2023-10-14 09:35:43,470] [4720] [MainThread] [INFO] (main:285) - USING:: version = False
[2023-10-14 09:35:43,470] [4720] [MainThread] [INFO] (main:285) - USING:: app = C:\Users\xiaoqianmu\apps\radiology
[2023-10-14 09:35:43,470] [4720] [MainThread] [INFO] (main:285) - USING:: studies = C:\Users\xiaoqianmu\datasets\Task09_Spleen\imagesTr
[2023-10-14 09:35:43,471] [4720] [MainThread] [INFO] (main:285) - USING:: verbose = INFO
[2023-10-14 09:35:43,471] [4720] [MainThread] [INFO] (main:285) - USING:: conf = [['models', 'deepedit']]
[2023-10-14 09:35:43,471] [4720] [MainThread] [INFO] (main:285) - USING:: host = 0.0.0.0
[2023-10-14 09:35:43,471] [4720] [MainThread] [INFO] (main:285) - USING:: port = 8000
[2023-10-14 09:35:43,471] [4720] [MainThread] [INFO] (main:285) - USING:: uvicorn_app = monailabel.app:app
[2023-10-14 09:35:43,471] [4720] [MainThread] [INFO] (main:285) - USING:: ssl_keyfile = None
[2023-10-14 09:35:43,471] [4720] [MainThread] [INFO] (main:285) - USING:: ssl_certfile = None
[2023-10-14 09:35:43,471] [4720] [MainThread] [INFO] (main:285) - USING:: ssl_keyfile_password = None
[2023-10-14 09:35:43,471] [4720] [MainThread] [INFO] (main:285) - USING:: ssl_ca_certs = None
[2023-10-14 09:35:43,471] [4720] [MainThread] [INFO] (main:285) - USING:: workers = None
[2023-10-14 09:35:43,471] [4720] [MainThread] [INFO] (main:285) - USING:: limit_concurrency = None
[2023-10-14 09:35:43,471] [4720] [MainThread] [INFO] (main:285) - USING:: access_log = False
[2023-10-14 09:35:43,471] [4720] [MainThread] [INFO] (main:285) - USING:: root_path = /
[2023-10-14 09:35:43,471] [4720] [MainThread] [INFO] (main:285) - USING:: log_level = info
[2023-10-14 09:35:43,471] [4720] [MainThread] [INFO] (main:285) - USING:: log_config = None
[2023-10-14 09:35:43,471] [4720] [MainThread] [INFO] (main:285) - USING:: dryrun = False
[2023-10-14 09:35:43,471] [4720] [MainThread] [INFO] (main:285) - USING:: action = start_server
[2023-10-14 09:35:43,472] [4720] [MainThread] [INFO] (main:296) -
Allow Origins: ['*']
[2023-10-14 09:35:44,305] [4720] [MainThread] [INFO] (uvicorn.error:74) - Started server process [4720]
[2023-10-14 09:35:44,306] [4720] [MainThread] [INFO] (uvicorn.error:48) - Waiting for application startup.
[2023-10-14 09:35:44,306] [4720] [MainThread] [INFO] (monailabel.interfaces.utils.app:37) - Initializing App from: C:\Users\xiaoqianmu\apps\radiology; studies: C:\Users\xiaoqianmu\datasets\Task09_Spleen\imagesTr; conf: {'models': 'deepedit'}
[2023-10-14 09:35:44,342] [4720] [MainThread] [ERROR] (uvicorn.error:123) - Traceback (most recent call last):
File "C:\Anaconda\envs\FUXIAN\lib\site-packages\starlette\routing.py", line 677, in lifespan
async with self.lifespan_context(app) as maybe_state:
File "C:\Anaconda\envs\FUXIAN\lib\site-packages\starlette\routing.py", line 566, in aenter
await self.router.startup()
File "C:\Anaconda\envs\FUXIAN\lib\site-packages\starlette\routing.py", line 654, in startup
await handler()
File "C:\Anaconda\envs\FUXIAN\lib\site-packages\monailabel\app.py", line 108, in startup_event
instance = app_instance()
File "C:\Anaconda\envs\FUXIAN\lib\site-packages\monailabel\interfaces\utils\app.py", line 43, in app_instance
c = get_class_of_subclass_from_file("main", main_py, "MONAILabelApp")
File "C:\Anaconda\envs\FUXIAN\lib\site-packages\monailabel\utils\others\class_utils.py", line 75, in get_class_of_subclass_from_file
File "C:\Anaconda\envs\FUXIAN\lib\site-packages\monailabel\utils\others\class_utils.py", line 45, in module_from_file
spec.loader.exec_module(module)
File "", line 843, in exec_module
File "", line 219, in call_with_frames_removed
File "C:\Users\xiaoqianmu\apps\radiology\main.py", line 19, in
from lib.infers.deepgrow_pipeline import InferDeepgrowPipeline
File "C:\Users\xiaoqianmu\apps\radiology\lib\infers_init
.py", line 13, in
from .deepgrow import Deepgrow
File "C:\Users\xiaoqianmu\apps\radiology\lib\infers\deepgrow.py", line 23, in
from monai.transforms import (
ImportError: cannot import name 'AddChanneld' from 'monai.transforms' (C:\Anaconda\envs\FUXIAN\lib\site-packages\monai\transforms_init
.py)

[2023-10-14 09:35:44,342] [4720] [MainThread] [ERROR] (uvicorn.error:59) - Application startup failed. Exiting.

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 apps/radiology/lib/infers/deepgrow.py and the import reached from apps/radiology/main.py. Reproduce the reported MONAI Label startup command and inspect the failing monai.transforms import. Done means the radiology app starts without this ImportError, with the compatible change verified against the reported traceback.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.