-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
28 lines (21 loc) · 1.01 KB
/
config.py
File metadata and controls
28 lines (21 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from __future__ import annotations
import os
from dataclasses import dataclass
def _get_bool(name: str, default: bool) -> bool:
value = os.getenv(name)
if value is None:
return default
return value.lower() in {"1", "true", "yes", "on"}
@dataclass(frozen=True)
class Settings:
host: str = os.getenv("SAM_ADAPTER_HOST", "0.0.0.0")
port: int = int(os.getenv("SAM_ADAPTER_PORT", "8080"))
inference_mode: str = os.getenv("SAM_ADAPTER_INFERENCE_MODE", "sam2")
log_level: str = os.getenv("SAM_ADAPTER_LOG_LEVEL", "INFO")
model_checkpoint: str = os.getenv("SAM2_CHECKPOINT", "/models/sam2_hiera_base_plus.pt")
model_config: str = os.getenv("SAM2_MODEL_CONFIG", "configs/sam2.1/sam2.1_hiera_b+.yaml")
device: str = os.getenv("SAM2_DEVICE", "cuda")
threshold: float = float(os.getenv("SAM_ADAPTER_MASK_THRESHOLD", "0.0"))
force_cpu: bool = _get_bool("SAM_ADAPTER_FORCE_CPU", False)
allow_fallback: bool = _get_bool("SAM_ADAPTER_ALLOW_FALLBACK", True)
settings = Settings()