store arbitrary sub labels

This commit is contained in:
Nicolas Mowen 2024-04-15 16:12:57 -06:00
parent d7ae0eedf8
commit bf809b3280

View File

@ -46,8 +46,9 @@ class PendingReviewSegment:
frame_time: float, frame_time: float,
severity: SeverityEnum, severity: SeverityEnum,
detections: dict[str, str], detections: dict[str, str],
zones: set[str] = set(), sub_labels: set[str],
audio: set[str] = set(), zones: set[str],
audio: set[str],
): ):
rand_id = "".join(random.choices(string.ascii_lowercase + string.digits, k=6)) rand_id = "".join(random.choices(string.ascii_lowercase + string.digits, k=6))
self.id = f"{frame_time}-{rand_id}" self.id = f"{frame_time}-{rand_id}"
@ -55,6 +56,7 @@ class PendingReviewSegment:
self.start_time = frame_time self.start_time = frame_time
self.severity = severity self.severity = severity
self.detections = detections self.detections = detections
self.sub_labels = sub_labels
self.zones = zones self.zones = zones
self.audio = audio self.audio = audio
self.last_update = frame_time self.last_update = frame_time
@ -111,6 +113,7 @@ class PendingReviewSegment:
ReviewSegment.data: { ReviewSegment.data: {
"detections": list(set(self.detections.keys())), "detections": list(set(self.detections.keys())),
"objects": list(set(self.detections.values())), "objects": list(set(self.detections.values())),
"sub_labels": list(self.sub_labels),
"zones": list(self.zones), "zones": list(self.zones),
"audio": list(self.audio), "audio": list(self.audio),
}, },
@ -181,6 +184,7 @@ class ReviewSegmentMaintainer(threading.Thread):
segment.detections[object["id"]] = object["sub_label"][0] segment.detections[object["id"]] = object["sub_label"][0]
else: else:
segment.detections[object["id"]] = f'{object["label"]}-verified' segment.detections[object["id"]] = f'{object["label"]}-verified'
segment.sub_labels.add(object["sub_label"][0])
# if object is alert label # if object is alert label
# and has entered required zones or required zones is not set # and has entered required zones or required zones is not set
@ -235,6 +239,7 @@ class ReviewSegmentMaintainer(threading.Thread):
if len(active_objects) > 0: if len(active_objects) > 0:
has_sig_object = False has_sig_object = False
detections: dict[str, str] = {} detections: dict[str, str] = {}
sub_labels = set()
zones: set = set() zones: set = set()
severity = None severity = None
@ -245,6 +250,7 @@ class ReviewSegmentMaintainer(threading.Thread):
detections[object["id"]] = object["sub_label"][0] detections[object["id"]] = object["sub_label"][0]
else: else:
detections[object["id"]] = f'{object["label"]}-verified' detections[object["id"]] = f'{object["label"]}-verified'
sub_labels.add(object["sub_label"][0])
# if object is alert label # if object is alert label
# and has entered required zones or required zones is not set # and has entered required zones or required zones is not set
@ -292,6 +298,7 @@ class ReviewSegmentMaintainer(threading.Thread):
frame_time, frame_time,
SeverityEnum.alert if has_sig_object else SeverityEnum.detection, SeverityEnum.alert if has_sig_object else SeverityEnum.detection,
detections, detections,
sub_labels=sub_labels,
audio=set(), audio=set(),
zones=zones, zones=zones,
) )
@ -435,6 +442,7 @@ class ReviewSegmentMaintainer(threading.Thread):
severity, severity,
{}, {},
set(), set(),
set(),
detections, detections,
) )
elif topic == DetectionTypeEnum.api: elif topic == DetectionTypeEnum.api:
@ -445,6 +453,7 @@ class ReviewSegmentMaintainer(threading.Thread):
{manual_info["event_id"]: manual_info["label"]}, {manual_info["event_id"]: manual_info["label"]},
set(), set(),
set(), set(),
set(),
) )
if manual_info["state"] == ManualEventState.start: if manual_info["state"] == ManualEventState.start: