Skip to content

Commit

Permalink
added raise error
Browse files Browse the repository at this point in the history
  • Loading branch information
kprokofi committed May 27, 2024
1 parent f2a2bc8 commit 3beac1b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/otx/core/types/label.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,14 @@ class SegLabelInfo(LabelInfo):

ignore_index: int = 255

def __post_init__(self):
if len(self.label_names) <= 1:
msg = (
"The number of labels must be larger than 1. "
"Please, check dataset labels and add background label in case of binary segmentation."
)
raise ValueError(msg)

Check warning on line 291 in src/otx/core/types/label.py

View check run for this annotation

Codecov / codecov/patch

src/otx/core/types/label.py#L291

Added line #L291 was not covered by tests

@classmethod
def from_num_classes(cls, num_classes: int) -> LabelInfo:
"""Create this object from the number of classes.
Expand Down

0 comments on commit 3beac1b

Please sign in to comment.