Skip to content

altomator/Introduction_to_Deep_Learning-2-Face_Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

91 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Introduction to Deep Learning #2

Facial detection

Use case: face detection on heritage images

Goals

Annotation of visages on heritage material can be useful for information retrieval scenario, digital humanities research objectives, etc.

Face detection on engraving material

ark:/12148/btv1b10544068q

Facial recognition, a technology capable of matching a human face from a digital image, is not covered here.

Hands-on session

Out of the box and easy to use systems are available for face detection.

OpenCV/dnn

The OpenCV/dnn module can be used to try some pretrained neural network models imported from frameworks as Caffe or Tensorflow.

Hands-on This Python 3 script uses dnn to call a ResNet SSD network (see this post or this notebook for details). The model can be easily downloaded from the web.

The images of a Gallica document are first loaded thanks to the IIIF protocol. The detection then occurs and annotated images are generated, as well as the CSV data. Users may play with the confidence score value and look for the impact on the detection process. A basic filter on very large (and improbable) detections is implemented.

Display the Jupyter notebook with nbviewer

Launch the notebook with Binder Binder

Evaluating performances

A final stage of evaluation of the quality of the detection is carried out, using the intersection over union (IOU) method. A basic Python implementation is performed, processing only images that include a single face. For an effective method, see this implementation. Ground truth images are annotated thanks to the VGG Image Annotator.

IOU result on a test image

Google Cloud Vision

The Google Cloud Vision API may be used to perform face and gender detection.

Hands-on The Perl script described here calls the API to perform visual recognition of content or human faces.

First, we have to build a JSON request:

{
	"requests": [{
		"image": {
			"content": "binary image content"
		},
		"features": [{
			"type": "FACE_DETECTION",
			"maxResults": "30"
		}],
		"imageContext": {
			"languageHints": ["fr"]
		}
	}]
}

Then the API endpoint is simply called with a curl command:

curl --max-time 10 -v -s -H "Content-Type: application/json" https://vision.googleapis.com/v1/images:annotate?key=your_key --data-binary @/tmp/request.json

Note: IBM Watson no longer offers facial detection.

MTCNN

This script is a Python3 implementation of the MTCNN face detector for TensorFlow, based on the paper Zhang, K et al. (2016). It requires OpenCV>=3.2 and Tensorflow>=1.4.0.

See it in action on school years photos.

Others approaches

These deep learning systems are well known for facial detection or recognition:

Use cases

Front pages analysis: faces and genders

Averaging of faces

The real face of White Australia

Resources