iris / backend /experimental /settings.py
github-actions[bot]
Automated Deploy: 67450540d340eb0a4ccb37442d1c451866cc1fd5
f65c627
Raw History Blame Contribute Delete
1.29 kB
"""Validated server-side switches for controlled learned-engine experiments."""
from dataclasses import dataclass
import os
@dataclass(frozen=True)
class LearnedSettings:
matcher: str = 'loftr'
max_size: int = 800
patches: str = 'auto'
adaptive_mask: bool = False
@classmethod
def from_env(cls):
matcher = os.environ.get('IRIS_MATCHER', 'loftr')
patches = os.environ.get('IRIS_PATCH_VALIDATION', 'auto')
adaptive = os.environ.get('IRIS_ADAPTIVE_MASK', 'false').lower()
try:
size = int(os.environ.get('IRIS_MATCH_MAX_SIZE', '800' if matcher=='loftr' else '1600'))
except ValueError as exc:
raise RuntimeError('IRIS_MATCH_MAX_SIZE must be an integer.') from exc
if matcher not in {'loftr', 'lightglue'} or patches not in {'auto', 'single', 'multiscale', 'geometry'}:
raise RuntimeError('Invalid learned matcher or patch-validation configuration.')
if adaptive not in {'true', 'false'}:
raise RuntimeError('IRIS_ADAPTIVE_MASK must be true or false.')
if not 400 <= size <= (1200 if matcher=='loftr' else 2200):
raise RuntimeError('IRIS_MATCH_MAX_SIZE exceeds the supported range.')
return cls(matcher, size, patches, adaptive=='true')