Spaces:
Sleeping
Sleeping
| """ | |
| Pydantic response models for the REST API. | |
| """ | |
| from __future__ import annotations | |
| from typing import Any, Optional | |
| from pydantic import BaseModel, Field | |
| class StatsResponse(BaseModel): | |
| fps: float = Field(0.0, description="Current pipeline FPS") | |
| avg_detection_ms: float = Field(0.0, description="Average detection latency (ms)") | |
| avg_total_ms: float = Field(0.0, description="Average total frame latency (ms)") | |
| frame_count: int = Field(0, description="Total processed frames") | |
| uptime_seconds: float = Field(0.0, description="Pipeline uptime (seconds)") | |
| class_counts: dict[str, int] = Field(default_factory=dict) | |
| caption: dict[str, Any] = Field(default_factory=dict) | |
| buffer: dict[str, Any] = Field(default_factory=dict) | |
| class TrackInfo(BaseModel): | |
| track_id: int | |
| class_id: int | |
| label: str | |
| confidence: float | |
| bbox: list[int] # [x1, y1, x2, y2] | |
| caption: str = "" | |
| state: str = "Confirmed" | |
| class DetectionResult(BaseModel): | |
| """Result from image upload / still capture.""" | |
| detections: list[dict[str, Any]] = Field(default_factory=list) | |
| count: int = 0 | |
| processing_ms: float = 0.0 | |
| class SourceConfig(BaseModel): | |
| type: str = "camera" # camera | rtsp | file | |
| camera_index: int = 0 | |
| rtsp_url: str = "" | |
| class HealthResponse(BaseModel): | |
| status: str = "ok" | |
| version: str = "1.0.0" | |
| pipeline_running: bool = False | |
| opencv_version: str = "" | |
| class ErrorResponse(BaseModel): | |
| error: str | |
| detail: Optional[str] = None | |