3cf4a9a40a
python / test (push) Failing after 8s
- Updated README.md to reflect new features and API changes. - Introduced versioning in app initialization. - Enhanced configuration management in app/config.py with new validation functions. - Refactored main.py to improve request handling and response generation. - Added new models in app/models.py for structured API responses. - Implemented a dedicated UI rendering function in app/ui.py. - Improved Docker configuration for better security and health checks. - Updated tests to cover new validation rules and response formats. - Added CLAUDE.md for project guidelines and working rules.
50 lines
1017 B
Python
50 lines
1017 B
Python
from __future__ import annotations
|
|
|
|
from enum import StrEnum
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class Detector(StrEnum):
|
|
FACE = "face"
|
|
ANIMAL = "animal"
|
|
PERSON = "person"
|
|
SUBJECT = "subject"
|
|
|
|
|
|
class BoundingBoxResponse(BaseModel):
|
|
x: int = Field(ge=0)
|
|
y: int = Field(ge=0)
|
|
w: int = Field(gt=0)
|
|
h: int = Field(gt=0)
|
|
|
|
|
|
class SourceSizeResponse(BaseModel):
|
|
width: int = Field(gt=0)
|
|
height: int = Field(gt=0)
|
|
|
|
|
|
class FocusResponse(BaseModel):
|
|
filename: str
|
|
detector: Detector
|
|
method: str
|
|
buffer_ratio: float = Field(ge=0.0, le=0.6)
|
|
detected_bbox: BoundingBoxResponse
|
|
square_bbox: BoundingBoxResponse
|
|
source_size: SourceSizeResponse
|
|
mime_type: str
|
|
crop_data_url: str
|
|
annotated_data_url: str
|
|
|
|
|
|
class HealthResponse(BaseModel):
|
|
ok: bool = True
|
|
env: str
|
|
version: str
|
|
docs_enabled: bool
|
|
test_ui_enabled: bool
|
|
auth_enabled: bool
|
|
auth_header: str | None
|
|
max_upload_bytes: int
|
|
allowed_mime_types: list[str]
|