"""Restorer factory: build a Restorer from the app config. Only DeepMosaics is supported (the cv2 inpaint baseline was removed — it filled but did not reconstruct). The DeepMosaics network code is vendored (``_deepmosaics/``, GPL-3.0) and run in-process; the user supplies only the weights (+ ``mosaic_position.pth`` alongside). A CUDA GPU is recommended. - ``deepmosaics``: per-frame generative mosaic removal (image model). - ``deepmosaics_video``: temporal variant (BVDNet) that uses neighbouring frames for coherence — needs the ``clean_*_video.pth`` weights and a contiguous frame sequence. """ from __future__ import annotations from typing import TYPE_CHECKING from .base import Restorer if TYPE_CHECKING: # avoid importing AppConfig at runtime here (not needed) from ...config import AppConfig def build_restorer(name: str = "deepmosaics", config: AppConfig | None = None) -> Restorer: if config is None: raise ValueError("Для DeepMosaics нужны настройки (config).") if name == "deepmosaics": from .deepmosaics import DeepMosaicsRestorer return DeepMosaicsRestorer( config.dm_dir, config.dm_model, config.dm_gpu ) if name == "deepmosaics_video": from .deepmosaics import DeepMosaicsVideoRestorer return DeepMosaicsVideoRestorer( config.dm_dir, config.dm_model, config.dm_gpu ) if name == "lada": raise ValueError( "Движок LADA пока не подключён. Используйте DeepMosaics. См. README." ) raise ValueError(f"Неизвестный режим восстановления: {name!r}")