Spaces:
Sleeping
Sleeping
File size: 1,165 Bytes
d725335 8536e24 d725335 f005306 d725335 f005306 d725335 20905e1 d725335 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 | from __future__ import annotations
from typing import Any, Literal
from pydantic import BaseModel, Field
class Detection(BaseModel):
frame_index: int = Field(ge=0)
timestamp_sec: float = Field(ge=0.0)
label: str
confidence: float = Field(ge=0.0, le=1.0)
bbox_xyxy: tuple[float, float, float, float]
bbox_xyxy_norm: tuple[float, float, float, float]
track_id: int | None = None
class FrameSample(BaseModel):
frame_index: int = Field(ge=0)
timestamp_sec: float = Field(ge=0.0)
class VideoProcessResult(BaseModel):
output_video_path: str
classes: list[str]
detections: list[Detection]
frames: list[FrameSample] = Field(default_factory=list)
processed_frames: int
source_fps: float
output_fps: float
frame_stride: int
sample_interval_sec: float | None = None
class ActionEvent(BaseModel):
rule: str
action: str
type: Literal["simulate", "webhook"]
frame_index: int
timestamp_sec: float
status: str = "pending"
url: str | None = None
payload: dict[str, Any] = Field(default_factory=dict)
response_status: int | None = None
error: str | None = None
|