Rajhuggingface4253 commited on
Commit
8aa3dc8
·
verified ·
1 Parent(s): 6480984

Create config.py

Browse files
Files changed (1) hide show
  1. config.py +59 -0
config.py ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from functools import lru_cache
2
+ from typing import List
3
+
4
+ from pydantic_settings import BaseSettings
5
+
6
+
7
+ class Settings(BaseSettings):
8
+ """Application settings optimized for CPU deployment."""
9
+
10
+ # Application metadata
11
+ app_name: str = "Vision"
12
+ app_version: str = "1.0.0"
13
+
14
+ # Model settings - Using official ONNX model with Q4 for speed
15
+ model_id: str = "LiquidAI/LFM2.5-VL-1.6B-ONNX"
16
+ encoder_variant: str = "q4"
17
+ decoder_variant: str = "q4"
18
+
19
+ # Server settings (same as lfm-text for consistency)
20
+ host: str = "0.0.0.0"
21
+ port: int = 7860
22
+
23
+ # CORS settings
24
+ cors_origins: List[str] = ["*"]
25
+
26
+ # Vision processing settings
27
+ min_image_tokens: int = 64
28
+ max_image_tokens: int = 256
29
+ do_image_splitting: bool = True
30
+
31
+ # Supported image formats
32
+ supported_formats: List[str] = ["jpeg", "jpg", "png", "gif", "webp", "bmp"]
33
+ max_image_size_mb: int = 10
34
+
35
+ # Generation defaults (from LiquidAI recommendations)
36
+ temperature: float = 0.1
37
+ top_k: int = 50
38
+ top_p: float = 0.5
39
+ min_p: float = 0.15
40
+ max_tokens: int = 1024
41
+ repetition_penalty: float = 1.05
42
+
43
+ # CPU optimization
44
+ num_threads: int = 2 # Optimized for 2 vCPU
45
+
46
+ # Logging
47
+ log_level: str = "info"
48
+
49
+ class Config:
50
+ env_prefix = "LFMVL_"
51
+
52
+
53
+ @lru_cache()
54
+ def get_settings() -> Settings:
55
+ """Get cached settings."""
56
+ return Settings()
57
+
58
+
59
+ settings = get_settings()