phase 4
This commit is contained in:
39
core/gpu/config.py
Normal file
39
core/gpu/config.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""
|
||||
Runtime config — loaded from env, mutable via API.
|
||||
|
||||
The UI config panel is just a visual editor for these same values.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
_config = {
|
||||
"device": os.environ.get("DEVICE", "auto"),
|
||||
"yolo_model": os.environ.get("YOLO_MODEL", "yolov8n.pt"),
|
||||
"yolo_confidence": float(os.environ.get("YOLO_CONFIDENCE", "0.3")),
|
||||
"vram_budget_mb": int(os.environ.get("VRAM_BUDGET_MB", "10240")),
|
||||
"strategy": os.environ.get("STRATEGY", "sequential"),
|
||||
"ocr_languages": os.environ.get("OCR_LANGUAGES", "en").split(","),
|
||||
"ocr_min_confidence": float(os.environ.get("OCR_MIN_CONFIDENCE", "0.5")),
|
||||
}
|
||||
|
||||
|
||||
def get_config() -> dict:
|
||||
return _config
|
||||
|
||||
|
||||
def update_config(changes: dict) -> dict:
|
||||
_config.update(changes)
|
||||
return _config
|
||||
|
||||
|
||||
def get_device() -> str:
|
||||
device = _config["device"]
|
||||
if device != "auto":
|
||||
return device
|
||||
try:
|
||||
import torch
|
||||
return "cuda" if torch.cuda.is_available() else "cpu"
|
||||
except ImportError:
|
||||
return "cpu"
|
||||
Reference in New Issue
Block a user