27 lines
824 B
Python
27 lines
824 B
Python
"""Restorer interface — "un-censor" detected regions of an image.
|
|
|
|
A Restorer takes an image plus the detected censored regions and returns a new
|
|
image with those regions reconstructed/filled. This mirrors the ``Detector``
|
|
abstraction so different engines (classic inpaint now; a generative model like
|
|
DeepMosaics / LADA later) plug in behind the same interface.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from abc import ABC, abstractmethod
|
|
|
|
import numpy as np
|
|
|
|
from ..detection.types import Detection
|
|
|
|
|
|
class Restorer(ABC):
|
|
@property
|
|
def name(self) -> str:
|
|
return type(self).__name__
|
|
|
|
@abstractmethod
|
|
def restore(self, image: np.ndarray, detections: list[Detection]) -> np.ndarray:
|
|
"""Return a copy of ``image`` with the detected regions reconstructed."""
|
|
raise NotImplementedError
|