mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-05-03 06:50:58 +00:00
Compare commits
3 Commits
3feca459c7
...
ca38705ea5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ca38705ea5 | ||
|
|
32bd32cf50 | ||
|
|
d5424c0b25 |
@ -85,7 +85,7 @@ class ReviewDescriptionProcessor(PostProcessorApi):
|
||||
return
|
||||
elif (
|
||||
final_data["severity"] == "detection"
|
||||
and not self.config.cameras[camera].review.detections
|
||||
and not self.config.cameras[camera].review.genai.detections
|
||||
):
|
||||
self.tracked_review_items.pop(id)
|
||||
return
|
||||
|
||||
@ -3,10 +3,10 @@ from pydantic import BaseModel, Field
|
||||
|
||||
class ReviewMetadata(BaseModel):
|
||||
scene: str = Field(
|
||||
description="A concise summary of the overall scene. This should be a single string of text."
|
||||
description="A comprehensive description of the setting and entities, including relevant context and plausible inferences if supported by visual evidence."
|
||||
)
|
||||
action: str = Field(
|
||||
description="A concise description of the primary action or event happening in the scene. This should be a single string of text."
|
||||
confidence: float = Field(
|
||||
description="A float between 0 and 1 representing your overall confidence in this analysis."
|
||||
)
|
||||
potential_threat_level: int | None = Field(
|
||||
default=None,
|
||||
|
||||
@ -39,25 +39,34 @@ class GenAIClient:
|
||||
) -> None:
|
||||
"""Generate a description for the review item activity."""
|
||||
context_prompt = f"""
|
||||
Please analyze the image(s), which are in chronological order, strictly from the perspective of the {review_data['camera'].replace('_', ' ')} security camera.
|
||||
Your task is to provide a **neutral, factual, and objective description** of the scene and the objects interacting with it.
|
||||
Focus solely on observable actions, visible entities, and the environment.
|
||||
Please analyze the image(s), which are in chronological order, strictly from the perspective of the {review_data["camera"].replace("_", " ")} security camera.
|
||||
Your task is to provide a **neutral, factual, and objective description** of the scene, while also including **reasonable, evidence-based inferences** about the likely context or activity — but do not make unfounded assumptions.
|
||||
|
||||
When forming your description:
|
||||
- Base all statements on visible details in the images.
|
||||
- You may deduce plausible intent or context only if supported by clear, observable evidence (e.g., someone carrying tools toward a car may indicate vehicle maintenance).
|
||||
- Avoid implying hostility, criminal intent, or other strong judgments unless the visual evidence is unambiguous.
|
||||
- Distinguish between what is certain (facts) and what appears likely (reasonable inference).
|
||||
|
||||
Here is some information we already know:
|
||||
- the following activity occurred at {review_data['timestamp'].strftime('%I:%M %p')}
|
||||
- the following objects were detected: {review_data['objects']}
|
||||
- the following recognized objects were detected: {review_data['recognized_objects']}
|
||||
- the activity happened in the following zones: {review_data['zones']}
|
||||
- The activity occurred at {review_data["timestamp"].strftime("%I:%M %p")}
|
||||
- The following objects were detected: {review_data["objects"]}
|
||||
- The following recognized objects were detected: {review_data["recognized_objects"]}
|
||||
- The activity happened in the following zones: {review_data["zones"]}
|
||||
|
||||
Your response **MUST** be a flat JSON object with the following fields:
|
||||
- `scene` (string): A single, comprehensive description of the entire visual scene.
|
||||
- `action` (string): A single description of any key actions or movements.
|
||||
- `potential_threat_level` (integer, optional): An integer from 0 to 3. Only include if a clear security concern is visible. Omit if no threat.
|
||||
- `scene` (string): A comprehensive description of the setting and entities, including relevant context and plausible inferences if supported by visual evidence.
|
||||
- `confidence` (float): A float between 0 and 1 representing your overall confidence in this analysis.
|
||||
- `potential_threat_level` (integer, optional): 1–3 scale. Only include if a clear security concern is visible:
|
||||
- 1 = Unusual but not overtly threatening
|
||||
- 2 = Suspicious or potentially harmful
|
||||
- 3 = Clear and immediate threat
|
||||
Omit this field entirely if there is no observable security concern.
|
||||
|
||||
**IMPORTANT:** The value for each field (e.g., "scene", "action") must be a plain string or integer, NOT another JSON object or a description of the field itself.
|
||||
|
||||
Provide the response in the exact JSON format specified by this schema:
|
||||
{ReviewMetadata.model_json_schema()['properties']}
|
||||
**IMPORTANT:**
|
||||
- Values for each field must be plain strings or integers — no nested objects or explanatory text.
|
||||
- The JSON must strictly match this structure:
|
||||
{ReviewMetadata.model_json_schema()["properties"]}
|
||||
"""
|
||||
logger.info(f"processing {review_data}")
|
||||
logger.info(f"Got GenAI review: {self._send(context_prompt, thumbnails)}")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user