schemas.py 837 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. from enum import StrEnum
  2. from typing import TypeAlias
  3. import numpy as np
  4. from pydantic import BaseModel
  5. def to_lower_camel(string: str) -> str:
  6. tokens = [token.capitalize() if i > 0 else token for i, token in enumerate(string.split("_"))]
  7. return "".join(tokens)
  8. class TextModelRequest(BaseModel):
  9. text: str
  10. class TextResponse(BaseModel):
  11. __root__: str
  12. class MessageResponse(BaseModel):
  13. message: str
  14. class BoundingBox(BaseModel):
  15. x1: int
  16. y1: int
  17. x2: int
  18. y2: int
  19. class ModelType(StrEnum):
  20. IMAGE_CLASSIFICATION = "image-classification"
  21. CLIP = "clip"
  22. FACIAL_RECOGNITION = "facial-recognition"
  23. ndarray_f32: TypeAlias = np.ndarray[int, np.dtype[np.float32]]
  24. ndarray_i64: TypeAlias = np.ndarray[int, np.dtype[np.int64]]
  25. ndarray_i32: TypeAlias = np.ndarray[int, np.dtype[np.int32]]