question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MONAI Label App - Radiology - Transforms - Bug

See original GitHub issue

Hi everyone,

I have started researching active learning and I am trying to use MONAI Label to develop my pipeline. I have started from the radiology sample app as a baseline app to develop it to be scriptable and I am having issues running it since I encountered this bug.

Describe the bug The reordering of the labels generates that happens here generates the wrong indexed order that in turn creates issues when its index is used here.

To Reproduce Use the main.py in radiology app to train a network.

Expected behavior I would expect this method to take as input something like:

{
    "background":0,
    "target_class_0":2,
    "target_class_1":1,
}

and transform it into:

{
    "background":0,
    "target_class_0":1,
    "target_class_1":2,
}

but instead, it transforms it into:

{
    "background":0,
    "target_class_0":2,
    "target_class_1":3,
}

And now the code here tries to compensate for this +1 shift and it ends up indexing outside of the number of labels since “target_class_1” with index 3 should be at index 2 actually.

Environment

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

================================
Printing MONAI config...
================================
MONAI version: 1.0.1rc4
Numpy version: 1.23.4
Pytorch version: 1.12.1+cu102
MONAI flags: HAS_EXT = False, USE_COMPILED = False, USE_META_DICT = False
MONAI rev id: 52a7fde440123460f2ce13a515a0f3d023292f95
MONAI __file__: /home/danieltudosiu/projects/MONAILabel/venv/lib/python3.9/site-packages/monai/__init__.py

Optional dependencies:
Pytorch Ignite version: 0.4.10
Nibabel version: 4.0.2
scikit-image version: 0.19.3
Pillow version: 9.2.0
Tensorboard version: 2.10.1
gdown version: 4.5.3
TorchVision version: 0.13.1+cu102
tqdm version: 4.64.1
lmdb version: 1.3.0
psutil version: 5.9.3
pandas version: NOT INSTALLED or UNKNOWN VERSION.
einops version: 0.5.0
transformers version: NOT INSTALLED or UNKNOWN VERSION.
mlflow version: NOT INSTALLED or UNKNOWN VERSION.
pynrrd version: 0.4.3

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


================================
Printing system config...
================================
System: Linux
Linux version: Ubuntu 18.04.6 LTS
Platform: Linux-5.4.0-131-generic-x86_64-with-glibc2.27
Processor: x86_64
Machine: x86_64
Python version: 3.9.15
Process name: python
Command: ['python', '-c', 'import monai; monai.config.print_debug_info()']
Open files: []
Num physical CPUs: 16
Num logical CPUs: 32
Num usable CPUs: 32
CPU usage (%): [16.8, 7.1, 5.1, 5.1, 5.8, 6.4, 5.8, 7.2, 5.8, 7.2, 5.1, 5.1, 7.1, 6.5, 8.0, 47.9, 6.4, 6.4, 5.8, 5.8, 6.5, 5.0, 6.4, 5.0, 5.8, 5.8, 5.8, 5.8, 5.9, 5.8, 6.4, 46.0]
CPU freq. (MHz): 2246
Load avg. in last 1, 5, 15 mins (%): [2.5, 3.0, 2.9]
Disk usage (%): 64.8
Avg. sensor temp. (Celsius): UNKNOWN for given OS
Total physical memory (GB): 62.7
Available memory (GB): 42.5
Used memory (GB): 19.1

================================
Printing GPU config...
================================
Num GPUs: 2
Has CUDA: True
CUDA version: 10.2
cuDNN enabled: True
cuDNN version: 7605
Current device: 0
Library compiled for CUDA architectures: ['sm_37', 'sm_50', 'sm_60', 'sm_70']
GPU 0 Name: TITAN V
GPU 0 Is integrated: False
GPU 0 Is multi GPU board: False
GPU 0 Multi processor count: 80
GPU 0 Total memory (GB): 11.8
GPU 0 CUDA capability (maj.min): 7.0
GPU 1 Name: GeForce GT 1030
GPU 1 Is integrated: False
GPU 1 Is multi GPU board: False
GPU 1 Multi processor count: 3
GPU 1 Total memory (GB): 2.0
GPU 1 CUDA capability (maj.min): 6.1

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
danieltudosiucommented, Nov 15, 2022

I had a chat with @diazandr3s today and explained the issue in detail. The buggy code is this for loop. I am proposing to change it to:

            idx=1
            for key_label, val_label in self.label_names.items():
                if key_label != "background":
                    new_label_names[key_label] = idx
                    label[d[key] == val_label] = idx
                    idx+=1
                if key_label == "background":
                    new_label_names["background"] = 0

@diazandr3s agreed with the surgical change.

@SachidanandAlle regarding the Radiology App I am mainly talking about the main.py which is peculiarly underdeveloped. What I would propose is to expose all the variables in the main.py and create a TODO list for users. Furthermore, I see some unused code (mainly looking at the self.planner variable) that could be removed to clarify of code. I am more than happy to try and do a PR for this as I have been doing it for my research.

1reaction
SachidanandAllecommented, Nov 14, 2022

I think that the current Radiology app is somewhat underdeveloped.

@danieltudosiu it is true… it’s more of a reference implementation with couple of different types of model (to segment xyz labels) and these examples will not generalize to fit in every other use-case to train your own model.

Either you have to fix data preparation, transforms etc… depending on your dataset. But if you find better ways to make it more generic, please feel free to chime in and raise a PR to fix/add those improvements for everyone to use.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Scribbles update gives "Failed to post process label on MONAI ...
Hi, I am working in Windows and I was able to install MONAILabel and run the exemplary server with the radiology app and...
Read more >
Transforms — MONAI 1.1.0 Documentation
log_stats ( bool ) – whether to log the detailed information of data and applied transform when error happened, for NumPy array and...
Read more >
monailabel · PyPI
Active Learning Toolkit for Healthcare Imaging. ... Framework for developing and deploying MONAI Label Apps to train and infer AI models ...
Read more >
Tutorial: MONAI LABEL - UFRC Help and Documentation
App Development. Datasets. Deployment. AI-assisted image labeling tool. MONAI Label v0.3 deep learning training. MONAI Core v0.8.
Read more >
MONAI Label - Scribbles Annotation - YouTube
In this video, you'll learn how to start labeling your images using the scribbles method. You'll also learn how to combine scribbles with ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found