base.py 1017 B

1234567891011121314151617181920212223242526272829303132
  1. # Copyright 2025 Yakhyokhuja Valikhujaev
  2. # Author: Yakhyokhuja Valikhujaev
  3. # GitHub: https://github.com/yakhyo
  4. from abc import ABC, abstractmethod
  5. import numpy as np
  6. class BaseLandmarker(ABC):
  7. """
  8. Abstract Base Class for all facial landmark models.
  9. """
  10. @abstractmethod
  11. def get_landmarks(self, image: np.ndarray, bbox: np.ndarray) -> np.ndarray:
  12. """
  13. Predicts facial landmarks for a given face bounding box.
  14. This method defines the standard interface for all landmark predictors.
  15. It takes a full image and a bounding box for a single face and returns
  16. the predicted keypoints for that face.
  17. Args:
  18. image (np.ndarray): The full source image in BGR format.
  19. bbox (np.ndarray): A bounding box of a face [x1, y1, x2, y2].
  20. Returns:
  21. np.ndarray: An array of predicted landmark points with shape (N, 2),
  22. where N is the number of landmarks.
  23. """
  24. raise NotImplementedError