2023-06-25 05:18:09 +02:00
|
|
|
from pathlib import Path
|
|
|
|
|
2023-06-18 05:49:19 +02:00
|
|
|
from pydantic import BaseSettings
|
|
|
|
|
2023-06-25 05:18:09 +02:00
|
|
|
from .schemas import ModelType
|
|
|
|
|
|
|
|
|
2023-06-18 05:49:19 +02:00
|
|
|
class Settings(BaseSettings):
|
|
|
|
cache_folder: str = "/cache"
|
|
|
|
classification_model: str = "microsoft/resnet-50"
|
|
|
|
clip_image_model: str = "clip-ViT-B-32"
|
|
|
|
clip_text_model: str = "clip-ViT-B-32"
|
|
|
|
facial_recognition_model: str = "buffalo_l"
|
|
|
|
min_tag_score: float = 0.9
|
|
|
|
eager_startup: bool = True
|
|
|
|
model_ttl: int = 300
|
|
|
|
host: str = "0.0.0.0"
|
|
|
|
port: int = 3003
|
|
|
|
workers: int = 1
|
|
|
|
min_face_score: float = 0.7
|
2023-06-28 01:21:33 +02:00
|
|
|
test_full: bool = False
|
2023-06-18 05:49:19 +02:00
|
|
|
|
|
|
|
class Config(BaseSettings.Config):
|
2023-06-25 05:18:09 +02:00
|
|
|
env_prefix = "MACHINE_LEARNING_"
|
2023-06-18 05:49:19 +02:00
|
|
|
case_sensitive = False
|
|
|
|
|
|
|
|
|
2023-06-25 05:18:09 +02:00
|
|
|
def get_cache_dir(model_name: str, model_type: ModelType) -> Path:
|
|
|
|
return Path(settings.cache_folder, model_type.value, model_name)
|
|
|
|
|
|
|
|
|
2023-06-18 05:49:19 +02:00
|
|
|
settings = Settings()
|