"""Restorer factory: build a Restorer from the app config. - ``inpaint``: cv2 baseline (no weights, no GPU; fills, doesn't reconstruct). - ``deepmosaics``: real generative mosaic removal. The DeepMosaics network code is vendored (``_deepmosaics/``, GPL-3.0) and run in-process; the user supplies only the clean weights (+ ``mosaic_position.pth`` alongside). A CUDA GPU is recommended. """ from __future__ import annotations from typing import TYPE_CHECKING from .base import Restorer from .inpaint import InpaintRestorer if TYPE_CHECKING: # avoid importing AppConfig at runtime here (not needed) from ...config import AppConfig def build_restorer(name: str = "inpaint", config: "AppConfig | None" = None) -> Restorer: if name == "inpaint": return InpaintRestorer() if name == "deepmosaics": from .deepmosaics import DeepMosaicsRestorer if config is None: raise ValueError("Для DeepMosaics нужны настройки (config).") return DeepMosaicsRestorer( config.dm_dir, config.dm_model, config.dm_python, config.dm_gpu ) if name == "lada": raise ValueError( "Движок LADA пока не подключён. Используйте DeepMosaics или inpaint. См. README." ) raise ValueError(f"Неизвестный режим восстановления: {name!r}")