Skip to content
This repository has been archived by the owner on Mar 21, 2024. It is now read-only.

Adding mutually exclusive label check to load_labels_from_dataset_source #454

Merged
merged 3 commits into from
May 19, 2021

Conversation

dumbledad
Copy link
Contributor

@dumbledad dumbledad commented May 6, 2021

Issue

Closes #339

Overview

We need to check that labels are mutually exclusive early, when the labels are loaded from the data source.

Details

load_labels_from_dataset_source builds up the ground truth tensor from individual binary masks. It sets the background mask correctly, but does not check if each pixel is really only in 1 class. If that assumption is violated, model training may later fail when computing the FocalLoss, and when it fails later the error message does not explain the reason well. So we need to check that the labels are mutually exclusive early, when the labels are loaded from the data source.

Some loss functions (e.g. SoftDice) may cope with overlapping labels so we provide a flag for users to turn off the check, but by default if the labels are not mutually exclusive we now throw a ValueError with a suitably explanatory message.

Checklist

  • Ensure that your PR is small, and implements one change.
  • Add unit tests for all functions that you introduced or modified.
  • Run PyCharm's code cleanup tools on your Python files. (I'm using VS Code)
  • Link the correct GitHub issue for tracking.
  • Update the Changelog file: Describe your change in terms of
    Added/Changed/Removed/... in the "Upcoming" section.
  • When merging your PR, replace the default merge message with a description of your PR,
    and if needed a motivation why that change was required.

@dumbledad dumbledad self-assigned this May 6, 2021
@dumbledad dumbledad force-pushed the timregan/339-mutually-exclusive-segmentation-labels branch 5 times, most recently from 7e6f6aa to 5f08f5d Compare May 13, 2021 08:31
@dumbledad dumbledad marked this pull request as ready for review May 13, 2021 16:46
@dumbledad dumbledad enabled auto-merge (squash) May 13, 2021 16:50
InnerEye/ML/lightning_base.py Outdated Show resolved Hide resolved
InnerEye/ML/model_training.py Outdated Show resolved Hide resolved
InnerEye/ML/runner.py Outdated Show resolved Hide resolved
InnerEye/ML/config.py Outdated Show resolved Hide resolved
InnerEye/ML/config.py Show resolved Hide resolved
InnerEye/ML/utils/io_util.py Outdated Show resolved Hide resolved
InnerEye/ML/utils/io_util.py Outdated Show resolved Hide resolved
Tests/ML/utils/test_io_util.py Outdated Show resolved Hide resolved
@dumbledad dumbledad force-pushed the timregan/339-mutually-exclusive-segmentation-labels branch 3 times, most recently from ce0c5b3 to cf72125 Compare May 19, 2021 07:19
Tests/ML/test_data/cxr_test_dataset/Data_Entry_2017.csv Outdated Show resolved Hide resolved
Tests/ML/test_data/cxr_test_dataset/dataset.csv Outdated Show resolved Hide resolved
Tests/ML/utils/test_io_util.py Outdated Show resolved Hide resolved
@dumbledad dumbledad force-pushed the timregan/339-mutually-exclusive-segmentation-labels branch from cf72125 to 3ba6955 Compare May 19, 2021 07:29
.gitignore Outdated Show resolved Hide resolved
@dumbledad dumbledad requested a review from Shruthi42 May 19, 2021 10:48
@dumbledad dumbledad merged commit 77e87ac into main May 19, 2021
@dumbledad dumbledad deleted the timregan/339-mutually-exclusive-segmentation-labels branch May 19, 2021 13:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Data loader does not check that segmentation labels are mutually exclusive
3 participants