Models.face_detector_ultraface package

Submodules

Models.face_detector_ultraface.FaceDetector module

class Models.face_detector_ultraface.FaceDetector.FaceDetector(model_path: Path, input_size: Tuple[int, int], confidence_threshold: float = 0.7, use_cuda: bool = False)[source]

Bases: object

UltraFace face detector.

Create the face predictor and load the model.

Parameters:
  • model_path (Path) – Path to the onnx model file.

  • input_size (Tuple[int, int]) – Model input size. (640, 480) or (320, 240).

  • confidence_threshold (float, optional) – Confidence threshold. Defaults to 0.7.

  • use_cuda (bool, optional) – If True, execute the model on a CUDA device. Defaults to False.

predict(image: ndarray) List[Instance][source]

Detect faces on an image and return its bounding boxes.

Parameters:

image (np.ndarray) – A BGR uint8 image of shape (H, W, 3).

Returns:

A list of Instances with the following fields:
  • bounding_box (BoundingBox): A BoundingBox object with the

    position of the detected face

  • confidence (float): The detection confidence.

Return type:

List[Instance]

Module contents