Map verified objects to their sub label directly

This commit is contained in:
Nicolas Mowen 2025-10-09 16:48:41 -06:00
parent 24a1874225
commit 3a576d1c88
2 changed files with 14 additions and 4 deletions

View File

@ -256,18 +256,21 @@ def run_analysis(
objects = []
verified_objects = []
named_objects = []
for label in set(final_data["data"]["objects"] + final_data["data"]["sub_labels"]):
if "-verified" in label:
verified_objects.append(label)
continue
if label in labelmap_objects:
objects.append(label.replace("_", " ").title())
else:
verified_objects.append(label.replace("_", " ").title())
for label in verified_objects:
named_objects.append(f'{label.replace("_", " ").title()} ({label.replace("-verified", "")})')
analytics_data["objects"] = objects
analytics_data["recognized_objects"] = verified_objects
analytics_data["recognized_objects"] = named_objects
metadata = genai_client.generate_review_description(
analytics_data,

View File

@ -63,6 +63,12 @@ class GenAIClient:
else:
return ""
def get_verified_objects() -> str:
if review_data["recognized_objects"]:
return "\n - " + "\n - ".join(review_data["recognized_objects"])
else:
return " None"
context_prompt = f"""
Please analyze the sequence of images ({len(thumbnails)} total) taken in chronological order from the perspective of the {review_data["camera"].replace("_", " ")} security camera.
@ -102,7 +108,8 @@ Sequence details:
- Frame 1 = earliest, Frame {len(thumbnails)} = latest
- Activity started at {review_data["start"]} and lasted {review_data["duration"]} seconds
- Detected objects: {", ".join(review_data["objects"])}
- Verified recognized objects: {", ".join(review_data["recognized_objects"]) or "None"}
- Verified recognized objects (use these names when describing these objects):
{get_verified_objects()}
- Zones involved: {", ".join(z.replace("_", " ").title() for z in review_data["zones"]) or "None"}
**IMPORTANT:**