Refactor annotation handling and inference processing: Update 'time' attribute in Annotation class to private, streamline video time formatting in main processing function, and adjust annotations dictionary access in detection conversion. Ensure consistency in handling input frames during inference.

This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-03-26 00:40:02 +02:00
parent 4afa1a4eec
commit 1e4ef299f9
6 changed files with 7 additions and 17 deletions
+3 -8
View File
@@ -109,10 +109,9 @@ class AIConfigDto(BaseModel):
def detection_to_dto(det) -> DetectionDto:
import constants_inf
ann = constants_inf.get_annotations_dict()
label = ""
if det.cls in ann:
label = ann[det.cls].name
if det.cls in constants_inf.annotations_dict:
label = constants_inf.annotations_dict[det.cls].name
return DetectionDto(
centerX=det.x,
centerY=det.y,
@@ -178,14 +177,10 @@ def _post_annotation_to_service(token_mgr: TokenManager, media_id: str,
try:
token = token_mgr.get_valid_token()
image_b64 = base64.b64encode(annotation.image).decode() if annotation.image else None
total_seconds = annotation.time // 1000 if annotation.time else 0
hours = total_seconds // 3600
minutes = (total_seconds % 3600) // 60
seconds = total_seconds % 60
payload = {
"mediaId": media_id,
"source": 0,
"videoTime": f"{hours:02d}:{minutes:02d}:{seconds:02d}",
"videoTime": f"00:00:{annotation.time // 1000:02d}" if annotation.time else "00:00:00",
"detections": [d.model_dump() for d in dtos],
}
if image_b64: