40 lines
883 B
Python
40 lines
883 B
Python
|
|
from pydantic import BaseModel
|
||
|
|
from typing import List, Optional
|
||
|
|
|
||
|
|
|
||
|
|
class Detection(BaseModel):
|
||
|
|
"""Object detection result"""
|
||
|
|
label: str
|
||
|
|
confidence: float
|
||
|
|
x: int
|
||
|
|
y: int
|
||
|
|
width: int
|
||
|
|
height: int
|
||
|
|
color: int = 0x00FF00 # Default green color
|
||
|
|
|
||
|
|
|
||
|
|
class DetectionRequest(BaseModel):
|
||
|
|
"""Request for model inference on image data"""
|
||
|
|
model_name: str
|
||
|
|
image_data: str # Base64 encoded image
|
||
|
|
|
||
|
|
|
||
|
|
class DetectionResponse(BaseModel):
|
||
|
|
"""Response with detection results"""
|
||
|
|
model_name: str
|
||
|
|
detections: List[Detection]
|
||
|
|
inference_time: float # Time in milliseconds
|
||
|
|
|
||
|
|
|
||
|
|
class ModelInfo(BaseModel):
|
||
|
|
"""Model information"""
|
||
|
|
name: str
|
||
|
|
path: str
|
||
|
|
size: List[int] # [width, height]
|
||
|
|
backend: str = "ONNX"
|
||
|
|
loaded: bool = False
|
||
|
|
|
||
|
|
|
||
|
|
class ModelsResponse(BaseModel):
|
||
|
|
"""Response with available models"""
|
||
|
|
models: List[ModelInfo]
|