config.py 812 B

1234567891011121314151617181920212223242526272829303132
  1. from pathlib import Path
  2. from pydantic import BaseSettings
  3. from .schemas import ModelType
  4. class Settings(BaseSettings):
  5. cache_folder: str = "/cache"
  6. classification_model: str = "microsoft/resnet-50"
  7. clip_image_model: str = "clip-ViT-B-32"
  8. clip_text_model: str = "clip-ViT-B-32"
  9. facial_recognition_model: str = "buffalo_l"
  10. min_tag_score: float = 0.9
  11. eager_startup: bool = True
  12. model_ttl: int = 0
  13. host: str = "0.0.0.0"
  14. port: int = 3003
  15. workers: int = 1
  16. min_face_score: float = 0.7
  17. test_full: bool = False
  18. class Config:
  19. env_prefix = "MACHINE_LEARNING_"
  20. case_sensitive = False
  21. def get_cache_dir(model_name: str, model_type: ModelType) -> Path:
  22. return Path(settings.cache_folder, model_type.value, model_name)
  23. settings = Settings()