File size: 1,299 Bytes
bd659a9 | 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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | from dataclasses import dataclass
from pathlib import Path
from typing import Optional
# Update this once to point at the checkpoint you want the easy-mode API to use.
CHECKPOINT_PATH = (
"trained_model/tamil/fusion/"
"custom_tamil_llamavit_fusion_element_lr1e-05_epoch4_bs16_20260425_231136.pth"
)
LOCAL_MODEL_ROOT = "local_models"
HOST = "127.0.0.1"
PORT = 8000
DEVICE = "auto"
THRESHOLD = None
MAX_LENGTH = None
@dataclass(frozen=True)
class LocalAPIConfig:
checkpoint_path: Path
local_model_root: Path
host: str
port: int
device: str
threshold: Optional[float]
max_length: Optional[int]
def repo_root() -> Path:
return Path(__file__).resolve().parents[1]
def resolve_repo_path(raw_path: str) -> Path:
path = Path(raw_path)
if path.is_absolute():
return path
return (repo_root() / path).resolve()
def load_local_api_config() -> LocalAPIConfig:
return LocalAPIConfig(
checkpoint_path=resolve_repo_path(CHECKPOINT_PATH),
local_model_root=resolve_repo_path(LOCAL_MODEL_ROOT),
host=str(HOST),
port=int(PORT),
device=str(DEVICE).strip().lower(),
threshold=None if THRESHOLD is None else float(THRESHOLD),
max_length=None if MAX_LENGTH is None else int(MAX_LENGTH),
)
|