Project-MONAI / MONAILabel

MONAI Label is an intelligent open source image labeling and learning tool.
https://docs.monai.io/projects/label
Apache License 2.0
610 stars 196 forks source link

Model not found under auto segmentation tab in 3d slicer #1332

Closed VishalJ99 closed 1 year ago

VishalJ99 commented 1 year ago

Describe the bug Not being able to find model under auto segmentation tab, despite model being loaded and trainable.

Running latest version of monai label, slicer v 5.2.1 and latest version of MONAI Label slicer plugin v d34b9c1 (2023-02-21)

Server logs (base) vishaljain@PD0677 monai-label-sandbox % monailabel start_server --app apps/radiology --studies datasets/Task09_Spleen/imagesTr --conf models segmentation_spleen Using PYTHONPATH=/Users/vishaljain:

2023-03-08 13:58:53,559 - USING:: version = False 2023-03-08 13:58:53,559 - USING:: app = /Users/vishaljain/monai-sandbox/monai-label-sandbox/apps/radiology 2023-03-08 13:58:53,559 - USING:: studies = /Users/vishaljain/monai-sandbox/monai-label-sandbox/datasets/Task09_Spleen/imagesTr 2023-03-08 13:58:53,559 - USING:: verbose = INFO 2023-03-08 13:58:53,559 - USING:: conf = [['models', 'segmentation_spleen']] 2023-03-08 13:58:53,559 - USING:: host = 0.0.0.0 2023-03-08 13:58:53,559 - USING:: port = 8000 2023-03-08 13:58:53,559 - USING:: uvicorn_app = monailabel.app:app 2023-03-08 13:58:53,559 - USING:: ssl_keyfile = None 2023-03-08 13:58:53,559 - USING:: ssl_certfile = None 2023-03-08 13:58:53,559 - USING:: ssl_keyfile_password = None 2023-03-08 13:58:53,559 - USING:: ssl_ca_certs = None 2023-03-08 13:58:53,559 - USING:: workers = None 2023-03-08 13:58:53,559 - USING:: limit_concurrency = None 2023-03-08 13:58:53,560 - USING:: access_log = False 2023-03-08 13:58:53,560 - USING:: log_config = None 2023-03-08 13:58:53,560 - USING:: dryrun = False 2023-03-08 13:58:53,560 - USING:: action = start_server 2023-03-08 13:58:53,562 - ENV SETTINGS:: MONAI_LABEL_API_STR = 2023-03-08 13:58:53,562 - ENV SETTINGS:: MONAI_LABEL_PROJECT_NAME = MONAILabel 2023-03-08 13:58:53,562 - ENV SETTINGS:: MONAI_LABEL_APP_DIR = 2023-03-08 13:58:53,562 - ENV SETTINGS:: MONAI_LABEL_STUDIES = 2023-03-08 13:58:53,563 - ENV SETTINGS:: MONAI_LABEL_AUTH_ENABLE = False 2023-03-08 13:58:53,563 - ENV SETTINGS:: MONAI_LABEL_AUTH_DB = 2023-03-08 13:58:53,563 - ENV SETTINGS:: MONAI_LABEL_APP_CONF = '{}' 2023-03-08 13:58:53,563 - ENV SETTINGS:: MONAI_LABEL_TASKS_TRAIN = True 2023-03-08 13:58:53,563 - ENV SETTINGS:: MONAI_LABEL_TASKS_STRATEGY = True 2023-03-08 13:58:53,563 - ENV SETTINGS:: MONAI_LABEL_TASKS_SCORING = True 2023-03-08 13:58:53,563 - ENV SETTINGS:: MONAI_LABEL_TASKS_BATCH_INFER = True 2023-03-08 13:58:53,563 - ENV SETTINGS:: MONAI_LABEL_DATASTORE = 2023-03-08 13:58:53,563 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_URL = 2023-03-08 13:58:53,563 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_USERNAME = 2023-03-08 13:58:53,563 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_PASSWORD = 2023-03-08 13:58:53,563 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_API_KEY = 2023-03-08 13:58:53,563 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_CACHE_PATH = 2023-03-08 13:58:53,563 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_PROJECT = 2023-03-08 13:58:53,563 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_ASSET_PATH = 2023-03-08 13:58:53,563 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_DSA_ANNOTATION_GROUPS = 2023-03-08 13:58:53,563 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_USERNAME = 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_PASSWORD = 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_CACHE_PATH = 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_QIDO_PREFIX = None 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_WADO_PREFIX = None 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_STOW_PREFIX = None 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_FETCH_BY_FRAME = False 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_CONVERT_TO_NIFTI = True 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_SEARCH_FILTER = '{"Modality": "CT"}' 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_CACHE_EXPIRY = 180 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_PROXY_TIMEOUT = 30.0 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_READ_TIMEOUT = 5.0 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_AUTO_RELOAD = True 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_READ_ONLY = False 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_FILE_EXT = '[".nii.gz", ".nii", ".nrrd", ".jpg", ".png", ".tif", ".svs", ".xml"]' 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_SERVER_PORT = 8000 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_CORS_ORIGINS = '[]' 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_SESSIONS = True 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_SESSION_PATH = 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_SESSION_EXPIRY = 3600 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_INFER_CONCURRENCY = -1 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_INFER_TIMEOUT = 600 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_TRACKING_ENABLED = True 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_LABEL_TRACKING_URI = 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_ZOO_SOURCE = github 2023-03-08 13:58:53,564 - ENV SETTINGS:: MONAI_ZOO_REPO = Project-MONAI/model-zoo/hosting_storage_v1 2023-03-08 13:58:53,565 - ENV SETTINGS:: MONAI_ZOO_AUTH_TOKEN = 2023-03-08 13:58:53,565 - ENV SETTINGS:: MONAI_LABEL_AUTO_UPDATE_SCORING = True 2023-03-08 13:58:53,565 - Allow Origins: [''] [2023-03-08 13:58:54,461] [59347] [MainThread] [INFO] (uvicorn.error:75) - Started server process [59347] [2023-03-08 13:58:54,461] [59347] [MainThread] [INFO] (uvicorn.error:45) - Waiting for application startup. [2023-03-08 13:58:54,461] [59347] [MainThread] [INFO] (monailabel.interfaces.utils.app:37) - Initializing App from: /Users/vishaljain/monai-sandbox/monai-label-sandbox/apps/radiology; studies: /Users/vishaljain/monai-sandbox/monai-label-sandbox/datasets/Task09_Spleen/imagesTr; conf: {'models': 'segmentation_spleen'} [2023-03-08 13:58:54,942] [59347] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for MONAILabelApp Found: <class 'main.MyApp'> [2023-03-08 13:58:54,965] [59347] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for TaskConfig Found: <class 'lib.configs.deepedit.DeepEdit'> [2023-03-08 13:58:54,968] [59347] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for TaskConfig Found: <class 'lib.configs.localization_spine.LocalizationSpine'> [2023-03-08 13:58:54,969] [59347] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for TaskConfig Found: <class 'lib.configs.deepgrow_2d.Deepgrow2D'> [2023-03-08 13:58:54,971] [59347] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for TaskConfig Found: <class 'lib.configs.deepgrow_3d.Deepgrow3D'> [2023-03-08 13:58:54,973] [59347] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for TaskConfig Found: <class 'lib.configs.localization_vertebra.LocalizationVertebra'> [2023-03-08 13:58:54,975] [59347] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for TaskConfig Found: <class 'lib.configs.segmentation_spleen.SegmentationSpleen'> [2023-03-08 13:58:54,977] [59347] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for TaskConfig Found: <class 'lib.configs.segmentation_vertebra.SegmentationVertebra'> [2023-03-08 13:58:54,979] [59347] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for TaskConfig Found: <class 'lib.configs.segmentation.Segmentation'> [2023-03-08 13:58:54,980] [59347] [MainThread] [INFO] (main:93) - +++ Adding Model: segmentation_spleen => lib.configs.segmentation_spleen.SegmentationSpleen [2023-03-08 13:58:54,980] [59347] [MainThread] [INFO] (monailabel.utils.others.generic:184) - Downloading resource: /Users/vishaljain/monai-sandbox/monai-label-sandbox/apps/radiology/model/pretrained_segmentation_spleen.pt from https://github.com/Project-MONAI/MONAILabel/releases/download/pretrained/radiology_segmentation_unet_spleen.pt pretrained_segmentation_spleen.pt: 18.4MB [00:01, 12.3MB/s]
2023-03-08 13:58:56,567 - INFO - Downloaded: /Users/vishaljain/monai-sandbox/monai-label-sandbox/apps/radiology/model/pretrained_segmentation_spleen.pt 2023-03-08 13:58:56,567 - INFO - Expected md5 is None, skip md5 check for file /Users/vishaljain/monai-sandbox/monai-label-sandbox/apps/radiology/model/pretrained_segmentation_spleen.pt. [2023-03-08 13:58:57,642] [59347] [MainThread] [INFO] (lib.configs.segmentation_spleen:75) - EPISTEMIC Enabled: False; Samples: 5 [2023-03-08 13:58:57,642] [59347] [MainThread] [INFO] (main:96) - +++ Using Models: ['segmentation_spleen'] [2023-03-08 13:58:57,642] [59347] [MainThread] [INFO] (monailabel.interfaces.app:134) - Init Datastore for: /Users/vishaljain/monai-sandbox/monai-label-sandbox/datasets/Task09_Spleen/imagesTr [2023-03-08 13:58:57,643] [59347] [MainThread] [INFO] (monailabel.datastore.local:129) - Auto Reload: True; Extensions: ['
.nii.gz', '.nii', '.nrrd', '.jpg', '.png', '.tif', '.svs', '*.xml'] [2023-03-08 13:58:57,657] [59347] [MainThread] [INFO] (monailabel.datastore.local:576) - Invalidate count: 0 [2023-03-08 13:58:57,658] [59347] [MainThread] [INFO] (monailabel.datastore.local:150) - Start observing external modifications on datastore (AUTO RELOAD) [2023-03-08 13:58:57,660] [59347] [MainThread] [INFO] (main:126) - +++ Adding Inferer:: segmentation_spleen => <lib.infers.segmentation_spleen.SegmentationSpleen object at 0x7fc461f7fcd0> [2023-03-08 13:58:57,660] [59347] [MainThread] [INFO] (main:191) - {'segmentation_spleen': <lib.infers.segmentation_spleen.SegmentationSpleen object at 0x7fc461f7fcd0>, 'Histogram+GraphCut': <monailabel.scribbles.infer.HistogramBasedGraphCut object at 0x7fc461f7f970>, 'GMM+GraphCut': <monailabel.scribbles.infer.GMMBasedGraphCut object at 0x7fc461f7fc10>} [2023-03-08 13:58:57,660] [59347] [MainThread] [INFO] (main:206) - +++ Adding Trainer:: segmentation_spleen => <lib.trainers.segmentation_spleen.SegmentationSpleen object at 0x7fc461fa4af0> [2023-03-08 13:58:57,661] [59347] [MainThread] [INFO] (monailabel.utils.sessions:51) - Session Path: /Users/vishaljain/.cache/monailabel/sessions [2023-03-08 13:58:57,661] [59347] [MainThread] [INFO] (monailabel.utils.sessions:52) - Session Expiry (max): 3600 [2023-03-08 13:58:57,661] [59347] [MainThread] [INFO] (monailabel.interfaces.app:468) - App Init - completed [2023-03-08 13:58:57,661] [timeloop] [INFO] Starting Timeloop.. [2023-03-08 13:58:57,661] [59347] [MainThread] [INFO] (timeloop:60) - Starting Timeloop.. [2023-03-08 13:58:57,662] [timeloop] [INFO] Registered job <function MONAILabelApp.on_init_complete..run_scheduler at 0x7fc462044ee0> [2023-03-08 13:58:57,662] [59347] [MainThread] [INFO] (timeloop:42) - Registered job <function MONAILabelApp.on_init_complete..run_scheduler at 0x7fc462044ee0> [2023-03-08 13:58:57,662] [timeloop] [INFO] Timeloop now started. Jobs will run based on the interval set [2023-03-08 13:58:57,662] [59347] [MainThread] [INFO] (timeloop:63) - Timeloop now started. Jobs will run based on the interval set [2023-03-08 13:58:57,662] [59347] [MainThread] [INFO] (uvicorn.error:59) - Application startup complete. [2023-03-08 13:58:57,663] [59347] [MainThread] [INFO] (uvicorn.error:206) - Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit) [2023-03-08 13:59:49,974] [59347] [MainThread] [INFO] (monailabel.endpoints.activelearning:43) - Active Learning Request: {'strategy': 'random', 'client_id': 'user-xyz'} [2023-03-08 13:59:49,977] [59347] [MainThread] [INFO] (monailabel.tasks.activelearning.random:47) - Random: Selected Image: spleen_10; Weight: 1678283989 [2023-03-08 13:59:49,982] [59347] [MainThread] [INFO] (monailabel.endpoints.activelearning:59) - Next sample: {'id': 'spleen_10', 'weight': 1678283989, 'path': '/Users/vishaljain/monai-sandbox/monai-label-sandbox/datasets/Task09_Spleen/imagesTr/spleen_10.nii.gz', 'ts': 1676562563, 'name': 'spleen_10.nii.gz'}

To Reproduce Following radiology hello world guide : https://github.com/Project-MONAI/tutorials/blob/main/monailabel/monailabel_HelloWorld_radiology_3dslicer.ipynb

  1. pip install monailabel-weekly
  2. monailabel apps --download --name radiology --output apps
  3. monailabel datasets --download --name Task09_Spleen --output datasets
  4. monailabel start_server --app apps/radiology --studies datasets/Task09_Spleen/imagesTr --conf models segmentation_spleen

Expected behavior segmentation spleen model should be selectable under model tab in the auto segmentation section.

Screenshots Green - identified, Red - non selectable image

SachidanandAlle commented 1 year ago

Can you check in browser.. what is the output of http://127.0.0.1:8000/info

VishalJ99 commented 1 year ago

Can you check in browser.. what is the output of http://127.0.0.1:8000/info

{"name":"MONAILabel - Radiology (0.5.dev2307)","description":"DeepLearning models for radiology","version":"0.5.dev2307","labels":["spleen"],"models":{"segmentation_spleen":{"type":"segmentation","labels":{"spleen":1},"dimension":3,"description":"A pre-trained model for volumetric (3D) segmentation of the spleen from CT image","config":{"device":["cpu"]}},"Histogram+GraphCut":{"type":"scribbles","labels":{"spleen":1},"dimension":3,"description":"A post processing step with histogram-based GraphCut for Generic segmentation","config":{"num_bins":64,"lamda":1.0,"sigma":0.1,"device":["cpu"]}},"GMM+GraphCut":{"type":"scribbles","labels":{"spleen":1},"dimension":3,"description":"A post processing step with GMM-based GraphCut for Generic segmentation","config":{"num_mixtures":20,"lamda":5.0,"sigma":0.5,"device":["cpu"]}}},"trainers":{"segmentation_spleen":{"description":"Train Spleen Segmentation Model","config":{"name":"train_01","pretrained":true,"device":"cuda","max_epochs":50,"early_stop_patience":-1,"val_split":0.2,"train_batch_size":1,"val_batch_size":1,"multi_gpu":true,"gpus":"all","dataset":["SmartCacheDataset","CacheDataset","PersistentDataset","Dataset"],"dataloader":["ThreadDataLoader","DataLoader"],"tracking":["mlflow","None"],"tracking_uri":"","tracking_experiment_name":""},"labels":{"spleen":1}}},"strategies":{"random":{"description":"Random Strategy"},"first":{"description":"Get First Sample"},"last":{"description":"Get Last Sample"}},"scoring":{},"train_stats":{"segmentation_spleen":{}},"datastore":{"total":41,"completed":0,"label_tags":{}}}

SachidanandAlle commented 1 year ago

Do you have GPU?

VishalJ99 commented 1 year ago

Do you have GPU?

Nope, testing locally on laptop first.

SachidanandAlle commented 1 year ago

Monailabel needs GPU as one of it's prerequisite

https://github.com/Project-MONAI/MONAILabel#installation

VishalJ99 commented 1 year ago

Ok ive just tried running the above code on a machine with a gpu and get the same issue: image

Logs: (monai-env) vishaljain@pd0231:~/monai$ monailabel start_server --app apps/radiology --studies datasets/Task09_Spleen/imagesTr --conf models segmentation_spleen Using PYTHONPATH=/home/vishaljain/monai:

2023-03-08 16:13:15,283 - USING:: version = False 2023-03-08 16:13:15,283 - USING:: app = /home/vishaljain/monai/apps/radiology 2023-03-08 16:13:15,283 - USING:: studies = /home/vishaljain/monai/datasets/Task09_Spleen/imagesTr 2023-03-08 16:13:15,283 - USING:: verbose = INFO 2023-03-08 16:13:15,283 - USING:: conf = [['models', 'segmentation_spleen']] 2023-03-08 16:13:15,283 - USING:: host = 0.0.0.0 2023-03-08 16:13:15,284 - USING:: port = 8000 2023-03-08 16:13:15,284 - USING:: uvicorn_app = monailabel.app:app 2023-03-08 16:13:15,284 - USING:: ssl_keyfile = None 2023-03-08 16:13:15,284 - USING:: ssl_certfile = None 2023-03-08 16:13:15,284 - USING:: ssl_keyfile_password = None 2023-03-08 16:13:15,284 - USING:: ssl_ca_certs = None 2023-03-08 16:13:15,284 - USING:: workers = None 2023-03-08 16:13:15,284 - USING:: limit_concurrency = None 2023-03-08 16:13:15,284 - USING:: access_log = False 2023-03-08 16:13:15,284 - USING:: log_config = None 2023-03-08 16:13:15,284 - USING:: dryrun = False 2023-03-08 16:13:15,284 - USING:: action = start_server 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_API_STR = 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_PROJECT_NAME = MONAILabel 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_APP_DIR = 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_STUDIES = 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_AUTH_ENABLE = False 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_AUTH_DB = 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_APP_CONF = '{}' 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_TASKS_TRAIN = True 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_TASKS_STRATEGY = True 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_TASKS_SCORING = True 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_TASKS_BATCH_INFER = True 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_DATASTORE = 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_URL = 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_USERNAME = 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_PASSWORD = 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_API_KEY = 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_CACHE_PATH = 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_PROJECT = 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_ASSET_PATH = 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_DSA_ANNOTATION_GROUPS = 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_USERNAME = 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_PASSWORD = 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_CACHE_PATH = 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_QIDO_PREFIX = None 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_WADO_PREFIX = None 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_STOW_PREFIX = None 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_FETCH_BY_FRAME = False 2023-03-08 16:13:15,284 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_CONVERT_TO_NIFTI = True 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_SEARCH_FILTER = '{"Modality": "CT"}' 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_CACHE_EXPIRY = 180 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_PROXY_TIMEOUT = 30.0 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_LABEL_DICOMWEB_READ_TIMEOUT = 5.0 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_AUTO_RELOAD = True 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_READ_ONLY = False 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_LABEL_DATASTORE_FILE_EXT = '[".nii.gz", ".nii", ".nrrd", ".jpg", ".png", ".tif", ".svs", ".xml"]' 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_LABEL_SERVER_PORT = 8000 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_LABEL_CORS_ORIGINS = '[]' 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_LABEL_SESSIONS = True 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_LABEL_SESSION_PATH = 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_LABEL_SESSION_EXPIRY = 3600 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_LABEL_INFER_CONCURRENCY = -1 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_LABEL_INFER_TIMEOUT = 600 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_LABEL_TRACKING_ENABLED = True 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_LABEL_TRACKING_URI = 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_ZOO_SOURCE = github 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_ZOO_REPO = Project-MONAI/model-zoo/hosting_storage_v1 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_ZOO_AUTH_TOKEN = 2023-03-08 16:13:15,285 - ENV SETTINGS:: MONAI_LABEL_AUTO_UPDATE_SCORING = True 2023-03-08 16:13:15,285 - Allow Origins: [''] [2023-03-08 16:13:15,700] [1888220] [MainThread] [INFO] (uvicorn.error:75) - Started server process [1888220] [2023-03-08 16:13:15,700] [1888220] [MainThread] [INFO] (uvicorn.error:45) - Waiting for application startup. [2023-03-08 16:13:15,701] [1888220] [MainThread] [INFO] (monailabel.interfaces.utils.app:37) - Initializing App from: /home/vishaljain/monai/apps/radiology; studies: /home/vishaljain/monai/datasets/Task09_Spleen/imagesTr; conf: {'models': 'segmentation_spleen'} [2023-03-08 16:13:15,751] [1888220] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for MONAILabelApp Found: <class 'main.MyApp'> [2023-03-08 16:13:15,756] [1888220] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for TaskConfig Found: <class 'lib.configs.localization_vertebra.LocalizationVertebra'> [2023-03-08 16:13:15,756] [1888220] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for TaskConfig Found: <class 'lib.configs.segmentation.Segmentation'> [2023-03-08 16:13:15,757] [1888220] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for TaskConfig Found: <class 'lib.configs.deepgrow_3d.Deepgrow3D'> [2023-03-08 16:13:15,758] [1888220] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for TaskConfig Found: <class 'lib.configs.deepedit.DeepEdit'> [2023-03-08 16:13:15,758] [1888220] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for TaskConfig Found: <class 'lib.configs.segmentation_spleen.SegmentationSpleen'> [2023-03-08 16:13:15,759] [1888220] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for TaskConfig Found: <class 'lib.configs.deepgrow_2d.Deepgrow2D'> [2023-03-08 16:13:15,759] [1888220] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for TaskConfig Found: <class 'lib.configs.localization_spine.LocalizationSpine'> [2023-03-08 16:13:15,760] [1888220] [MainThread] [INFO] (monailabel.utils.others.class_utils:57) - Subclass for TaskConfig Found: <class 'lib.configs.segmentation_vertebra.SegmentationVertebra'> [2023-03-08 16:13:15,760] [1888220] [MainThread] [INFO] (main:93) - +++ Adding Model: segmentation_spleen => lib.configs.segmentation_spleen.SegmentationSpleen [2023-03-08 16:13:15,760] [1888220] [MainThread] [INFO] (monailabel.utils.others.generic:184) - Downloading resource: /home/vishaljain/monai/apps/radiology/model/pretrained_segmentation_spleen.pt from https://github.com/Project-MONAI/MONAILabel/releases/download/pretrained/radiology_segmentation_unet_spleen.pt pretrained_segmentation_spleen.pt: 18.4MB [00:01, 16.1MB/s]
2023-03-08 16:13:16,965 - INFO - Downloaded: /home/vishaljain/monai/apps/radiology/model/pretrained_segmentation_spleen.pt 2023-03-08 16:13:16,965 - INFO - Expected md5 is None, skip md5 check for file /home/vishaljain/monai/apps/radiology/model/pretrained_segmentation_spleen.pt. [2023-03-08 16:13:18,064] [1888220] [MainThread] [INFO] (lib.configs.segmentation_spleen:75) - EPISTEMIC Enabled: False; Samples: 5 [2023-03-08 16:13:18,064] [1888220] [MainThread] [INFO] (main:96) - +++ Using Models: ['segmentation_spleen'] [2023-03-08 16:13:18,064] [1888220] [MainThread] [INFO] (monailabel.interfaces.app:134) - Init Datastore for: /home/vishaljain/monai/datasets/Task09_Spleen/imagesTr [2023-03-08 16:13:18,064] [1888220] [MainThread] [INFO] (monailabel.datastore.local:130) - Auto Reload: True; Extensions: ['
.nii.gz', '.nii', '.nrrd', '.jpg', '.png', '.tif', '.svs', '*.xml'] [2023-03-08 16:13:18,071] [1888220] [MainThread] [INFO] (monailabel.datastore.local:577) - Invalidate count: 0 [2023-03-08 16:13:18,071] [1888220] [MainThread] [INFO] (monailabel.datastore.local:151) - Start observing external modifications on datastore (AUTO RELOAD) [2023-03-08 16:13:18,085] [1888220] [MainThread] [INFO] (main:126) - +++ Adding Inferer:: segmentation_spleen => <lib.infers.segmentation_spleen.SegmentationSpleen object at 0x7f387fdf79a0> [2023-03-08 16:13:18,085] [1888220] [MainThread] [INFO] (main:191) - {'segmentation_spleen': <lib.infers.segmentation_spleen.SegmentationSpleen object at 0x7f387fdf79a0>, 'Histogram+GraphCut': <monailabel.scribbles.infer.HistogramBasedGraphCut object at 0x7f387f9e42e0>, 'GMM+GraphCut': <monailabel.scribbles.infer.GMMBasedGraphCut object at 0x7f387f9e5e70>} [2023-03-08 16:13:18,085] [1888220] [MainThread] [INFO] (main:206) - +++ Adding Trainer:: segmentation_spleen => <lib.trainers.segmentation_spleen.SegmentationSpleen object at 0x7f387f9e5fc0> [2023-03-08 16:13:18,085] [1888220] [MainThread] [INFO] (monailabel.utils.sessions:51) - Session Path: /home/vishaljain/.cache/monailabel/sessions [2023-03-08 16:13:18,086] [1888220] [MainThread] [INFO] (monailabel.utils.sessions:52) - Session Expiry (max): 3600 [2023-03-08 16:13:18,086] [1888220] [MainThread] [INFO] (monailabel.interfaces.app:468) - App Init - completed [2023-03-08 16:13:18,086] [timeloop] [INFO] Starting Timeloop.. [2023-03-08 16:13:18,086] [1888220] [MainThread] [INFO] (timeloop:60) - Starting Timeloop.. [2023-03-08 16:13:18,087] [timeloop] [INFO] Registered job <function MONAILabelApp.on_init_complete..run_scheduler at 0x7f387f989510> [2023-03-08 16:13:18,087] [1888220] [MainThread] [INFO] (timeloop:42) - Registered job <function MONAILabelApp.on_init_complete..run_scheduler at 0x7f387f989510> [2023-03-08 16:13:18,087] [timeloop] [INFO] Timeloop now started. Jobs will run based on the interval set [2023-03-08 16:13:18,087] [1888220] [MainThread] [INFO] (timeloop:63) - Timeloop now started. Jobs will run based on the interval set [2023-03-08 16:13:18,087] [1888220] [MainThread] [INFO] (uvicorn.error:59) - Application startup complete. [2023-03-08 16:13:18,087] [1888220] [MainThread] [INFO] (uvicorn.error:206) - Uvicorn running on http://0.0.0.0:8000 (Press CTRL+C to quit)

Output at http://127.0.0.1:8000/info shows device = cuda {"name":"MONAILabel - Radiology (0.5.dev2310)","description":"DeepLearning models for radiology","version":"0.5.dev2310","labels":["spleen"],"models":{"segmentation_spleen":{"type":"segmentation","labels":{"spleen":1},"dimension":3,"description":"A pre-trained model for volumetric (3D) segmentation of the spleen from CT image","config":{"device":["cuda"]}},"Histogram+GraphCut":{"type":"scribbles","labels":{"spleen":1},"dimension":3,"description":"A post processing step with histogram-based GraphCut for Generic segmentation","config":{"num_bins":64,"lamda":1.0,"sigma":0.1,"device":["cuda"]}},"GMM+GraphCut":{"type":"scribbles","labels":{"spleen":1},"dimension":3,"description":"A post processing step with GMM-based GraphCut for Generic segmentation","config":{"num_mixtures":20,"lamda":5.0,"sigma":0.5,"device":["cuda"]}}},"trainers":{"segmentation_spleen":{"description":"Train Spleen Segmentation Model","config":{"name":"train_01","pretrained":true,"device":"cuda","max_epochs":50,"early_stop_patience":-1,"val_split":0.2,"train_batch_size":1,"val_batch_size":1,"multi_gpu":true,"gpus":"all","dataset":["SmartCacheDataset","CacheDataset","PersistentDataset","Dataset"],"dataloader":["ThreadDataLoader","DataLoader"],"tracking":["mlflow","None"],"tracking_uri":"","tracking_experiment_name":""},"labels":{"spleen":1}}},"strategies":{"random":{"description":"Random Strategy"},"first":{"description":"Get First Sample"},"last":{"description":"Get Last Sample"}},"scoring":{},"train_stats":{"segmentation_spleen":{}},"datastore":{"total":41,"completed":0,"label_tags":{}}}

SachidanandAlle commented 1 year ago

Try running inference API directly for the model.. you can see what models are available from /info output

For apid.. http://127.0.0.1:8000

If you are available to run.. and get the label mask.. then possibly you have an outdated plugin or version.. uninstall the plugin and configure it developer mode.. on the GitHub plugins/slicer has more details on how to

VishalJ99 commented 1 year ago

Try running inference API directly for the model.. you can see what models are available from /info output

For apid.. http://127.0.0.1:8000

If you are available to run.. and get the label mask.. then possibly you have an outdated plugin or version.. uninstall the plugin and configure it developer mode.. on the GitHub plugins/slicer has more details on how to

Sorry i am confused, what do you mean by running inference API directly for the model? In slicer I can not select the Run button under auto segmenation due to the lack of a specified model.

Is there a way to use cli commands to send this request to the monai label server anyway?

SachidanandAlle commented 1 year ago

Open http://127.0.0.1:8000 in browser.. you can run APIs directly

VishalJ99 commented 1 year ago

Try running inference API directly for the model.. you can see what models are available from /info output

For apid.. http://127.0.0.1:8000

If you are available to run.. and get the label mask.. then possibly you have an outdated plugin or version.. uninstall the plugin and configure it developer mode.. on the GitHub plugins/slicer has more details on how to

So just to confirm, model = path to model_weights.pt file I am confused what to put for the image, session_id, token and params fields. Is the file just the file to be passed to the model and the label the binary mask nifti?

image

SachidanandAlle commented 1 year ago

Model: segmentation_spleen Image: filename without extension from your studies.. example spleen_10 Output: image only

And run.. this should be enough.. other fields can be ignored

VishalJ99 commented 1 year ago

Model: segmentation_spleen Image: filename without extension from your studies.. example spleen_10 Output: image only

And run.. this should be enough.. other fields can be ignored

Sorry for the questions but is this right?, it seems to be taking a long time... Id imagine inference on a single image to take a few seconds at most. image

SachidanandAlle commented 1 year ago

yes.. and then check into server logs.. whats happening..

VishalJ99 commented 1 year ago

No update on server log...

yes.. and then check into server logs.. whats happening..

changed url from http://127.0.0.1:8000/ to http://0.0.0.0:8000/#/Infer/ and it works now. Attached file shows some kind of segmentation Following server logs:

-03-08 16:57:31,726] [1888220] [MainThread] [INFO] (monailabel.endpoints.infer:160) - Infer Request: {'model': 'segmentation_spleen', 'image': 'spleen_10'} [2023-03-08 16:57:31,727] [1888220] [MainThread] [INFO] (monailabel.tasks.infer.basic_infer:284) - Infer Request (final): {'device': 'cuda', 'model': 'segmentation_spleen', 'image': '/home/vishaljain/monai/datasets/Task09_Spleen/imagesTr/spleen_10.nii.gz', 'description': 'A pre-trained model for volumetric (3D) segmentation of the spleen from CT image'} [2023-03-08 16:57:31,731] [1888220] [MainThread] [INFO] (monailabel.interfaces.utils.transform:76) - PRE - Run Transform(s) [2023-03-08 16:57:31,732] [1888220] [MainThread] [INFO] (monailabel.interfaces.utils.transform:77) - PRE - Input Keys: ['device', 'model', 'image', 'description', 'image_path'] [2023-03-08 16:57:32,234] [1888220] [MainThread] [INFO] (monailabel.interfaces.utils.transform:122) - PRE - Transform (LoadImaged): Time: 0.5019; image: torch.Size([512, 512, 55])(torch.float32) [2023-03-08 16:57:33,293] [1888220] [MainThread] [INFO] (monailabel.interfaces.utils.transform:122) - PRE - Transform (EnsureTyped): Time: 1.0588; image: torch.Size([512, 512, 55])(torch.float32) [2023-03-08 16:57:33,294] [1888220] [MainThread] [INFO] (monailabel.interfaces.utils.transform:122) - PRE - Transform (EnsureChannelFirstd): Time: 0.0002; image: torch.Size([1, 512, 512, 55])(torch.float32) [2023-03-08 16:57:33,728] [1888220] [MainThread] [INFO] (monailabel.interfaces.utils.transform:122) - PRE - Transform (Spacingd): Time: 0.4339; image: torch.Size([1, 500, 500, 271])(torch.float32) [2023-03-08 16:57:33,729] [1888220] [MainThread] [INFO] (monailabel.interfaces.utils.transform:122) - PRE - Transform (ScaleIntensityRanged): Time: 0.0005; image: torch.Size([1, 500, 500, 271])(torch.float32) [2023-03-08 16:57:33,729] [1888220] [MainThread] [INFO] (monailabel.tasks.infer.basic_infer:476) - Inferer:: cuda => SlidingWindowInferer => {'roi_size': (160, 160, 160), 'sw_batch_size': 1, 'overlap': 0.25, 'mode': constant, 'sigma_scale': 0.125, 'padding_mode': constant, 'cval': 0.0, 'sw_device': None, 'device': None, 'progress': False, 'cpu_thresh': None, 'roi_weight_map': None} [2023-03-08 16:57:33,729] [1888220] [MainThread] [INFO] (monailabel.tasks.infer.basic_infer:425) - Infer model path: /home/vishaljain/monai/apps/radiology/model/pretrained_segmentation_spleen.pt [2023-03-08 16:57:35,283] [1888220] [MainThread] [INFO] (monailabel.interfaces.utils.transform:76) - POST - Run Transform(s) [2023-03-08 16:57:35,283] [1888220] [MainThread] [INFO] (monailabel.interfaces.utils.transform:77) - POST - Input Keys: ['device', 'model', 'image', 'description', 'image_path', 'image_meta_dict', 'latencies', 'pred'] [2023-03-08 16:57:35,283] [1888220] [MainThread] [INFO] (monailabel.interfaces.utils.transform:122) - POST - Transform (EnsureTyped): Time: 0.0001; image: torch.Size([1, 500, 500, 271])(torch.float32); pred: torch.Size([2, 500, 500, 271])(torch.float32) [2023-03-08 16:57:35,284] [1888220] [MainThread] [INFO] (monailabel.interfaces.utils.transform:122) - POST - Transform (Activationsd): Time: 0.0002; image: torch.Size([1, 500, 500, 271])(torch.float32); pred: torch.Size([2, 500, 500, 271])(torch.float32) [2023-03-08 16:57:35,284] [1888220] [MainThread] [INFO] (monailabel.interfaces.utils.transform:122) - POST - Transform (AsDiscreted): Time: 0.0002; image: torch.Size([1, 500, 500, 271])(torch.float32); pred: torch.Size([1, 500, 500, 271])(torch.float32) [2023-03-08 16:57:35,285] [1888220] [MainThread] [INFO] (monailabel.interfaces.utils.transform:122) - POST - Transform (Restored): Time: 0.0007; image: torch.Size([1, 500, 500, 271])(torch.float32); pred: torch.Size([512, 512, 55])(torch.float32) [2023-03-08 16:57:35,285] [1888220] [MainThread] [INFO] (monailabel.tasks.infer.basic_infer:576) - Writing Result... [2023-03-08 16:57:35,285] [1888220] [MainThread] [INFO] (monailabel.transform.writer:189) - Result ext: .nii.gz; write_to_file: True; dtype: None [2023-03-08 16:57:38,435] [1888220] [MainThread] [INFO] (monailabel.tasks.infer.basic_infer:339) - ++ Latencies => Total: 6.7083; Pre: 2.0015; Inferer: 1.5536; Invert: 0.0000; Post: 0.0026; Write: 3.1499 [2023-03-08 16:57:38,435] [1888220] [MainThread] [INFO] (monailabel.tasks.infer.basic_infer:363) - Result File: /tmp/tmpiudipkqz.nii.gz [2023-03-08 16:57:38,435] [1888220] [MainThread] [INFO] (monailabel.tasks.infer.basic_infer:364) - Result Json Keys: ['label_names', 'latencies'] image

SachidanandAlle commented 1 year ago

Download the mask output and see in 3d slicer as mask

SachidanandAlle commented 1 year ago

This also means.. u have some issue with the 3d slicer..

You can open python console and see the logs/prints.. click refresh button in front of server uri and see what happens on the console in 3d Slicer

VishalJ99 commented 1 year ago

Download the mask output and see in 3d slicer as mask

Mask file is good so that means the problem is with 3d slicer?

SachidanandAlle commented 1 year ago

Uninstall 3d slicer.. install latest again.. and install plugin via developer mode..

https://github.com/Project-MONAI/MONAILabel/tree/main/plugins/slicer#install-plugin-in-developer-mode

VishalJ99 commented 1 year ago

This also means.. u have some issue with the 3d slicer..

You can open python console and see the logs/prints.. click refresh button in front of server uri and see what happens on the console in 3d Slicer

sorry where can i open a console in 3d slicer? pressing refresh does not affect monailabel server logs shown on terminal.

SachidanandAlle commented 1 year ago

Edit or view menu in slicer..

VishalJ99 commented 1 year ago

Uninstall 3d slicer.. install latest again.. and install plugin via developer mode..

https://github.com/Project-MONAI/MONAILabel/tree/main/plugins/slicer#install-plugin-in-developer-mode Fixed! image