How to start with monailabel for new models

@lassoan maybe we should split this into a new topic? If you agree thanks

There are more messages in the CloudFormation log and probably you already got something like

further down?

In any case, during setting this up there were two main hurdles that we identified, and afterward fine. You would probably need to contact an amazon representative to get advice on which region (see top right in your Amazon console) you should set up the server - youĀ“ll get a recommendation for one with high availability of server GPU - and the GPU instance quota of your Amazon account will need to get raised for being able to use them at all.

Prof.Dr. Rudolf Bumm

Thank you very much for your information. I followed the procedure again and I received a similar message like this putting the IP address correctly this time.

So, according to you, I will have to update my current limit of vCPU to create the EC2Instance. For MONAILabel to run, which type of vCPU and how many do you need ?

And kind of basic ( and hoping a valid oneā€¦) question, but every time I want to launch and use MONAI I will have to request vCPU to run it ?

Best.
Spiros.

Hi Spiros,

Yes, you will need to request a raise of your vCPU instance quota to 16 or 32, in particular, the G and VT instance types (last page on the ā€œLimitā€ Webpage, and select a good region with high availability of GPUs on AWS. An option as of Feb 2023 is to use Ireland from Europe.

The limit increase will probably be rejected the first time you try it yourself, here is where you need a regional AWS solution architect to assist you. And it is good to create an institutional AWS account.

Concerning your other question (start GPU whenever run MONAILabel server) please see here.

Maybe @diazandr3s is aware of a different solution, and in your particular case, the comfort of having a dedicated GPU-powered Windows instance with the option to run 3D Slicer on it is maybe not necessary if you just want to run the MONAILabel server in the cloud.

2 Likes

Hi all,

Thanks for this very informative thread, I look forward to testing this on my clinical datasets in the future.

I do not have NVIDIA and therefore do not have CUDA, does this prevent me from using MonaiLabel?

Thank you,
Eva

Installing MONAILabel is possible, you could use slow inference from pre-trained models and label your data. Training requires CUDA and an NVIDIA GPU.
Please see this thread.

1 Like

Thank you, that is really helpful.
My personal computer does have NVIDIA (my work one has a different GPU) so that approach could work well for me, thanks!

I am trying to build a tutorial for multilabel segmentation using MonaiLabel. It has been a while I used monailabel, but the deepedit link above gives 404.

Is it renamed or discontinued?

1 Like

@diazandr3s could you comment please?

1 Like

Hi @muratmaga,

Itā€™s been a while since we changed this model to be DeepEdit only - I think it was on June 13 2022 (Release MONAI Label 0.4.0 Ā· Project-MONAI/MONAILabel Ā· GitHub).

Previously we had one DeepEdit for binary segmentation and another DeepEdit for multilabel (https://github.com/Project-MONAI/MONAILabel/tree/0.3.2/sample-apps). Now it is just DeepEdit - this updated version can do both binary and multilabel segmentation: https://github.com/Project-MONAI/MONAILabel/tree/main/sample-apps/radiology#deepedit

Iā€™d suggest using the latest MONAI Label version: Release MONAI Label 0.7.0 Ā· Project-MONAI/MONAILabel Ā· GitHub

Please let me know if there is anything I can help with.

1 Like

Thanks, I found the deepedit folder under apps. Last time I had to train a multilabel model from scratch, I had to manually edit the deepedit.py with the label indices and define the spatial resolution of the model (see below). I am not seeing a deepeditp.py, but two other scripts called interaction.py and transform.py. But I still havenā€™t managed to figure out where to put the new label incides in.


class MyApp(MONAILabelApp):
    def __init__(self, app_dir, studies, conf):

        # Zero values are reserved to background. Non zero values are for the labels
        self.label_names = {
            "left lung": 1,
            "cranial lobe": 2,
            "middle lobe": 3,
            "caudal lobe": 4,
            "accessory lobe": 5,
            "left kidney": 6,
            "right kidney": 7,
            "stomach wall": 8,
            "stomach lumen": 9,
            "medial lobe of liver": 10,
            "left lobe of liver": 11,
            "right lobe of liver": 12,
            "caudate lobe of liver": 13,
            "left adrenal": 14,
            "right adrenal": 15,
            "rectum": 16,
            "bladder": 17,
            "left ventricle": 18,
            "right ventricle": 19,
            "left thymic rudiment": 20,
            "right thymic rudiment": 21,
            "third ventricle": 22,
            "mesencephalic vesicle": 23,
            "fourth ventricle": 24,
            "cerebral aqueduct": 25,
            "left lateral ventricle": 26,
            "right lateral ventricle": 27,
            "right olfactory bulb": 28,
            "left olfacotory bulb": 29,
            "right thalamus": 30,
            "left thalamus": 31,
            "right hypothamalus": 32,
            "left hypothalmus": 33,
            "right septal area": 34,
            "left septal area": 35,
            "left neopallial cortex abd amygdala": 36,
            "right neopallial cortex and amygdala": 37,
            "right striatum": 38,
            "left striatum": 39,
            "right ventricular zone": 40,
            "left ventricular zone": 41,
            "pons": 42,
            "left cerebellar primordium ": 43,
            "right cerebellar primordium": 44,
            "midbrain": 45,
            "medulla oblongata": 46,
            "spinal cord": 47,
            "vertebrae": 48,
            "left ventricle chamber": 102,
            "right ventricle chamber": 103,
            "background": 0,
        }

        network = conf.get("network", "dynunet")

        # Use Heuristic Planner to determine target spacing and spatial size based on dataset+gpu
        spatial_size = json.loads(conf.get("spatial_size", "[128, 128, 128]"))
        target_spacing = json.loads(conf.get("target_spacing", "[1.0, 1.0, 1.0]"))
        self.heuristic_planner = strtobool(conf.get("heuristic_planner", "false"))
        self.planner = HeuristicPlanner(spatial_size=spatial_size, target_spacing=target_spacing)

Again the goal is to train a new multilabel network scratch from a handful of segmented samples.

1 Like

Hi @muratmaga,

All of this is now located under the configs folder. For the deepedit, you can edit the deepedit.py file: https://github.com/Project-MONAI/MONAILabel/blob/main/sample-apps/radiology/lib/configs/deepedit.py#L42

Here you can change the spatial size: https://github.com/Project-MONAI/MONAILabel/blob/main/sample-apps/radiology/lib/configs/deepedit.py#L77

Hope this helps,

1 Like

I am working off the docker installation, and having a hard time matching the repos source code structure to what I am seeing under the /opt/monai in docker. Should I be looking somewhere else?

nevermind, I missed the radiology sample app download step in docker.

1 Like

Thanks for the update :slight_smile:

Well I am stuck at another level though :frowning:

I am trying to rearrange the workspace with persistent shares in docker. These are the commands I used to check out the vanilla radiology app and the Spleen dataset:

monailabel apps --download --name radiology --output /workspace/rad2
monailabel datasets --download --name Task09_Spleen --output /workspace/

then when I start the server with command:

monailabel start_server --app /workspace/rad2/radiology/ --studies /workspace/Task09_Spleen/

I am getting this error:

---------------------------------------------------------------------------------------
Provide --conf models <name>
Following are the available models.  You can pass comma (,) seperated names to pass multiple
    all, deepedit, deepgrow_2d, deepgrow_3d, localization_spine, localization_vertebra, segmentation, segmentation_spleen, segmentation_vertebra
---------------------------------------------------------------------------------------

[2023-09-25 17:34:14,253] [861] [MainThread] [ERROR] (uvicorn.error:123) - Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 677, in lifespan
    async with self.lifespan_context(app) as maybe_state:
  File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 566, in __aenter__
    await self._router.startup()
  File "/usr/local/lib/python3.8/dist-packages/starlette/routing.py", line 654, in startup
    await handler()
  File "/usr/local/lib/python3.8/dist-packages/monailabel/app.py", line 108, in startup_event
    instance = app_instance()
  File "/usr/local/lib/python3.8/dist-packages/monailabel/interfaces/utils/app.py", line 50, in app_instance
    app = c(app_dir=app_dir, studies=studies, conf=conf)
  File "/workspace/rad2/radiology/main.py", line 65, in __init__
    exit(-1)
  File "/usr/lib/python3.8/_sitebuiltins.py", line 26, in __call__
    raise SystemExit(code)
SystemExit: -1

[2023-09-25 17:34:14,253] [861] [MainThread] [ERROR] (uvicorn.error:59) - Application startup failed. Exiting.

any suggestions?

1 Like

The radiology app has evolved a lot and has now more models than before. For this reason we added a mandatory argument:

--conf models

In this case, for deepedit it should be something like this:

monailabel start_server --app /workspace/rad2/radiology/ --studies /workspace/Task09_Spleen/ --conf models deepedit

Please see here for more examples: https://github.com/Project-MONAI/MONAILabel/tree/main/sample-apps/radiology#how-to-use-the-app

2 Likes

Maybe time for a new workshop @diazandr3s? Will there be one next month?

2 Likes

Hi @rbumm,

Yes, there will be one for MICCAI: Project MONAI - MICCAI 2023 - Tutorial

Do you have another event in mind? :slight_smile:

1 Like

Hi,

I have successfully trained a new model and infer unseen images through 3D Slicer.

But I wondered if it was possible to run inference from command line commands or a Python script. Is it possible to download the output label mask using either commands or a Python script? The reason behind this is so that I donā€™t have to start the 3D-Slicer application after the model has been trained.

Please let me know if there is a way! Thank you for your help in advance.