Face detection

The face detection module is a fully convolution deep learning model which means it accepts any image size as input. The model was trained to detect faces with size ranging from 16px to 640px. You’d have poor accuracy if you provide images with faces larger than 640px or lower than 16px. One way to avoid the poor accuracy issue is to resize all input images to a target size equal to 640px. Resizing (up or down) the input images ensure that no face will be larger than 640px but some faces may become lower than 16px after down-scaling. Faces with size lower than 16px may be missed by the detector which is not an issue for our main use case (KYC). Other use cases (e.g. video surveillance) requires detecting small faces (far away persons) which means no target size should be defined.

The faces returned by the detector are sorted by sized, from the largest to the smallest.

Target size

The target size is defined using the configuration entry detect_target_size. Let’s experiment the target size using the reference image at world_largest_selfie.jpg with size 2048x1150.

Using target_size=-1 which means “no resize”, we find a total of 518 faces after threshold filtering:

_images/world_largest_selfie_target_size=-1.jpg

Using target_size=640, we find 88 faces after threshold filtering:

_images/world_largest_selfie_target_size=640.jpg

Using target_size=3000, we find 647 faces after threshold filtering:

_images/world_largest_selfie_target_size=3000.jpg
Analysis:
  • target_size=-1 (no resize): all faces with size within 16px and 640px are returned, small ones (far away) are missed.

  • target_size=640: down-scaling the image made some faces smaller and no longer detectable. That’s why we have less faces detected.

  • target_size=3000: up-scaling the image made some faces larger and detectable. That’s why we have more faces detected.

Setting the target size to 640 is the recommended option specially if you’re using the SDK in a KYC application.