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

[ANOMALY] Use is_anomalous attribute instead of string matching #1120

Merged
merged 2 commits into from
May 31, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,8 @@ class AnomalyClassificationToAnnotationConverter(IPredictionToAnnotationConverte

def __init__(self, label_schema: LabelSchemaEntity):
labels = label_schema.get_labels(include_empty=False)
self.normal_label = [label for label in labels if label.name == "Normal"][0]
self.anomalous_label = [label for label in labels if label.name == "Anomalous"][
0
]
self.normal_label = [label for label in labels if not label.is_anomalous][0]
self.anomalous_label = [label for label in labels if label.is_anomalous][0]

def convert_to_annotation(
self, predictions: np.ndarray, metadata: Dict[str, Any]
Expand Down Expand Up @@ -290,10 +288,8 @@ class AnomalySegmentationToAnnotationConverter(IPredictionToAnnotationConverter)

def __init__(self, label_schema: LabelSchemaEntity):
labels = label_schema.get_labels(include_empty=False)
self.normal_label = [label for label in labels if label.name == "Normal"][0]
self.anomalous_label = [label for label in labels if label.name == "Anomalous"][
0
]
self.normal_label = [label for label in labels if not label.is_anomalous][0]
self.anomalous_label = [label for label in labels if label.is_anomalous][0]
self.label_map = {0: self.normal_label, 1: self.anomalous_label}

def convert_to_annotation(
Expand Down Expand Up @@ -327,10 +323,8 @@ def __init__(self, label_schema: LabelSchemaEntity):
:param label_schema: Label Schema containing the label info of the task
"""
labels = label_schema.get_labels(include_empty=False)
self.normal_label = [label for label in labels if label.name == "Normal"][0]
self.anomalous_label = [label for label in labels if label.name == "Anomalous"][
0
]
self.normal_label = [label for label in labels if not label.is_anomalous][0]
self.anomalous_label = [label for label in labels if label.is_anomalous][0]
self.label_map = {0: self.normal_label, 1: self.anomalous_label}

def convert_to_annotation(
Expand Down