将检测任务迁移python
This commit is contained in:
40
python-inference-service/app/models.py
Normal file
40
python-inference-service/app/models.py
Normal file
@@ -0,0 +1,40 @@
|
||||
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]
|
||||
Reference in New Issue
Block a user