This commit is contained in:
2026-03-30 09:53:10 -03:00
parent 4220b0418e
commit aac27b8504
32 changed files with 1068 additions and 329 deletions

View File

@@ -2,7 +2,7 @@
Serializers for detection pipeline runtime models.
Special handling:
- Frame.image (np.ndarray → S3, excluded from JSON)
- Frame.image (np.ndarray, ephemeral — only metadata serialized)
- TextCandidate.frame (object ref → frame_sequence integer)
Everything else uses dataclasses.asdict() via safe_construct.
"""
@@ -24,7 +24,7 @@ from ._common import safe_construct, serialize_dataclass, serialize_dataclass_li
# ---------------------------------------------------------------------------
# Frame — image goes to S3 separately
# Frame — metadata only (image is ephemeral, re-extracted from chunks)
# ---------------------------------------------------------------------------
def serialize_frame_meta(frame: Frame) -> dict:
@@ -34,21 +34,9 @@ def serialize_frame_meta(frame: Frame) -> dict:
return result
def serialize_frames_with_upload(frames: list[Frame], job_id: str) -> tuple[list[dict], dict[int, str]]:
"""Upload frame images to S3, return metadata + manifest."""
from core.detect.checkpoint.frames import save_frames
manifest = save_frames(job_id, frames)
meta = [serialize_frame_meta(f) for f in frames]
return meta, manifest
def deserialize_frames_with_download(meta: list[dict], manifest: dict, job_id: str) -> list[Frame]:
"""Load frames from S3 + metadata."""
from core.detect.checkpoint.frames import load_frames
int_manifest = {int(k): v for k, v in manifest.items()}
return load_frames(int_manifest, meta)
def serialize_frames_meta(frames: list[Frame]) -> list[dict]:
"""Serialize frame metadata for all frames."""
return [serialize_frame_meta(f) for f in frames]
# ---------------------------------------------------------------------------