NVR with realtime local object detection for IP cameras
TypeScript aicameragoogle-coralhome-assistanthome-automationhomeautomationmqttnvrobject-detectionrealtimertsptensorflow
Handle percentage as int (#22370)
Nicolas Mowena0b82715324d
diff --git a/frigate/data_processing/post/types.py b/frigate/data_processing/post/types.pyindex beb746658c..6906f4a4ee 100644--- a/frigate/data_processing/post/types.py+++ b/frigate/data_processing/post/types.py@@ -15,7 +15,6 @@ class ReviewMetadata(BaseModel):)confidence: float = Field(ge=0.0,- le=1.0,description="Confidence in the analysis, from 0 to 1.",)potential_threat_level: int = Field(diff --git a/frigate/genai/__init__.py b/frigate/genai/__init__.pyindex 95e1ca046a..272420dab9 100644--- a/frigate/genai/__init__.py+++ b/frigate/genai/__init__.py@@ -181,6 +181,10 @@ Each line represents a detection state, not necessarily unique individuals. Paretry:metadata = ReviewMetadata.model_validate_json(clean_json)+ # Normalize confidence if model returned a percentage (e.g. 85 instead of 0.85)+ if metadata.confidence > 1.0:+ metadata.confidence = min(metadata.confidence / 100.0, 1.0)+# If any verified objects (contain parentheses with name), set to 0if any("(" in obj for obj in review_data["unified_objects"]):metadata.potential_threat_level = 0