Dlib CNN Face Detection

The Convolutional Neural Network (CNN) Face Detector in Dlib is a deep learning-based approach for detecting faces in images. Unlike traditional computer vision techniques that rely on hand-crafted features, CNNs learn to extract relevant features from the input data, which makes them more effective in dealing with complex tasks like face detection. It achieved an accuracy of 97.6% on the LFW dataset. Additionally, the model is robust to variations in lighting, pose, and expression, making it suitable for real-world applications.

Example

from dronevis.models import CNNFaceDetection

model = CNNFaceDetection()
model.load_model()
model.detect_webcam()

Dlib CNN Face Detection

class dronevis.models.CNNFaceDetection

CNN Face Detection model

__init__()

Initialize self. See help(type(self)) for accurate signature.

load_model()

Load model weights

transform_img(image)

Run image transformation

Parameters

image (np.ndarray) – Input image

Returns

Transformed image

Return type

np.ndarray

predict(image)

Run model inference on the image

Parameters

image (np.ndarray) – Input image

Returns

Image withe face annotations

Return type

np.ndarray

detect_webcam(video_index=0, window_name='CNN Face Detection')

Detect faces on webcam

Parameters
  • video_index (Tuple[int, str], optional) – Video index or path. Defaults to 0.

  • window_name (str, optional) – Window name. Defaults to “CNN Face Detection”.