INNER CODE UNIT · Python
DepthEstimator
BrokenSource/DepthFlow · depthflow/estimators/__init__.py:17
class DepthEstimator(BaseModel, ABC):
@abstractmethod
def __hash__(self) -> int:
"""Deterministic hash for current settings"""
...
def estimate(self, image: np.ndarray) -> np.ndarray:
hasher = xxhash.xxh3_64()
hasher.update(self.__hash__().to_bytes(8))
hasher.update(image.tobytes())
key: int = hasher.intdigest()
# Grab only rgb channels
if (image.shape[-1] == 4):
image = image[..., :3]
# Avoid expensive methods when cached