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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Run PyCharm's code cleanup tools on your Python files.(I'm using VS Code)Added/Changed/Removed/... in the "Upcoming" section.
and if needed a motivation why that change was required.