Handle percentage as int (#22370)
Some checks failed
CI / AMD64 Build (push) Has been cancelled
CI / ARM Build (push) Has been cancelled
CI / Jetson Jetpack 6 (push) Has been cancelled
CI / AMD64 Extra Build (push) Has been cancelled
CI / ARM Extra Build (push) Has been cancelled
CI / Synaptics Build (push) Has been cancelled
CI / Assemble and push default build (push) Has been cancelled

This commit is contained in:
Nicolas Mowen 2026-03-10 07:35:00 -06:00 committed by GitHub
parent 5254bfd00e
commit a0b8271532
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 1 deletions

View File

@ -15,7 +15,6 @@ class ReviewMetadata(BaseModel):
) )
confidence: float = Field( confidence: float = Field(
ge=0.0, ge=0.0,
le=1.0,
description="Confidence in the analysis, from 0 to 1.", description="Confidence in the analysis, from 0 to 1.",
) )
potential_threat_level: int = Field( potential_threat_level: int = Field(

View File

@ -181,6 +181,10 @@ Each line represents a detection state, not necessarily unique individuals. Pare
try: try:
metadata = ReviewMetadata.model_validate_json(clean_json) 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 0 # If any verified objects (contain parentheses with name), set to 0
if any("(" in obj for obj in review_data["unified_objects"]): if any("(" in obj for obj in review_data["unified_objects"]):
metadata.potential_threat_level = 0 metadata.potential_threat_level = 0