Files
post-moderation/ai-moderation/app/config/settings.py
2026-10-15 01:27:20 +03:00

46 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from pydantic_settings import BaseSettings, SettingsConfigDict
class Settings(BaseSettings):
APP_NAME: str = "AI Moderation"
APP_VERSION: str = "1.0.0"
HOST: str = "0.0.0.0"
PORT: int = 8000
DEBUG: bool = True
TEXT_TOXIC_THRESHOLD: float = 0.90
# ===== AI =====
TEXT_MODEL: str = "textdetox/bert-multilingual-toxicity-classifier"
IMAGE_MODEL: str = "Falconsai/nsfw_image_detection"
NSFW_THRESHOLD: float = 0.85
IMAGE_CLIP_MODEL: str = "openai/clip-vit-base-patch32"
CLIP_THRESHOLD: float = 0.75
WEAPON_MODEL: str = "google/owlv2-base-patch16-ensemble"
WEAPON_THRESHOLD: float = 0.40
WEAPON_MIN_AREA_FRACTION: float = 0.005
MODEL_CACHE_DIR: str = "./models"
# Максимальный размер файла картинки. Должен быть не меньше лимита бэкенда
# (10 МБ) — иначе бэкенд принимает фото, а модерация отвечает 413.
MAX_IMAGE_BYTES: int = 15 * 1024 * 1024
# Перед прогоном через модели картинка уменьшается до этой стороны: сами
# модели работают на 224–960px, а 12-Мп фото с телефона лишь замедляют
# предобработку и съедают память.
MODERATION_MAX_SIDE: int = 1280
DEVICE: str = "auto"
model_config = SettingsConfigDict(
env_file=".env",
extra="ignore"
)
settings = Settings()