Spaces:
Running
Running
| from functools import lru_cache | |
| from typing import List | |
| from pydantic_settings import BaseSettings | |
| class Settings(BaseSettings): | |
| """Application settings optimized for CPU deployment.""" | |
| # Application metadata | |
| app_name: str = "Vision" | |
| app_version: str = "1.0.0" | |
| # Model settings - Using official ONNX model with Q4 for speed | |
| model_id: str = "LiquidAI/LFM2.5-VL-1.6B-ONNX" | |
| encoder_variant: str = "q4" | |
| decoder_variant: str = "q4" | |
| # Server settings (same as lfm-text for consistency) | |
| host: str = "0.0.0.0" | |
| port: int = 7860 | |
| # CORS settings | |
| cors_origins: List[str] = ["*"] | |
| # Vision processing settings | |
| min_image_tokens: int = 64 | |
| max_image_tokens: int = 256 | |
| do_image_splitting: bool = True | |
| # Supported image formats | |
| supported_formats: List[str] = ["jpeg", "jpg", "png", "gif", "webp", "bmp"] | |
| max_image_size_mb: int = 10 | |
| # Generation defaults (from LiquidAI recommendations) | |
| temperature: float = 0.1 | |
| top_k: int = 50 | |
| top_p: float = 0.5 | |
| min_p: float = 0.15 | |
| max_tokens: int = 2024 | |
| repetition_penalty: float = 1.05 | |
| # CPU optimization | |
| num_threads: int = 2 # Optimized for 2 vCPU | |
| # Logging | |
| log_level: str = "info" | |
| class Config: | |
| env_prefix = "LFMVL_" | |
| def get_settings() -> Settings: | |
| """Get cached settings.""" | |
| return Settings() | |
| settings = get_settings() | |