Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

197 convertannotationstomask doesnt give an empty mask when there are no annotations #198

Conversation

moerlemans
Copy link
Contributor

Fixes #197 by adding an extra parameter to the ConvertAnnotationsToMask

Setting this parameter to true solves the issue that annotations can be empty lists when sampling tiles without annotations. In some usecases such as foreground-background segmentation this is useful.
@BPdeRooij
Copy link
Contributor

Throwing an error only when annotations are None might be better. The ConvertAnnotationsToMask outputs a mask with only zeros for the empty list now, which works like intended. Libraries that use this functionality, like ahcore, might expect "annotation_data" to exist. For example thePreTransformTaskFactory will fail on OneHotEncodeMask when returning a TileSample. Although a function like AllowCollate could be used to fix this, it would have to be called directly after ConvertAnnotationsToMask instead of at the end of the pre-transforms. It seems like a ValueError when sample["annotations"] is None would be appropriate behaviour for ConvertAnnotationsToMask.

Copy link
Contributor

@BPdeRooij BPdeRooij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference between handling empty annotations and NoneType for sample["annotations"] seems appropriate in this way. LGTM, can be merged.

@jonasteuwen jonasteuwen merged commit 7a92749 into main Nov 23, 2023
8 checks passed
@jonasteuwen jonasteuwen deleted the 197-convertannotationstomask-doesnt-give-an-empty-mask-when-there-are-no-annotations branch November 23, 2023 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ConvertAnnotationsToMask doesn't give an empty mask when there are no annotations
3 participants