Face detection
This experiment is a demonstration on how users use the pretrained cascade image classification module on AML to detect face on image data.
The ‘pretrained cascade image classification’ module utilizes OpenCV frontal face detection library. Data used in this experiment are images uploaded from individual users. The output of the experiment is whether there is a face in the image or not.
Experiment
There are three main steps in this experiment.
1. Loading images to work studio. The ‘image reader’ module can load images from Azure blob storage into a dataset used in AML studio.
1.a. Facts about image reader module
• The image formats that ‘image reader’ currently support are:
*.bmp, *.dib, *.jpeg, *.jpg,*.jpe,*.jp2,*.png, *.pbm,*.pgm,*.ppm,*.sr, *.ras,*.tiff, *.tif
• The limitation of image size that can be used for ‘image reader’ is: 65536. If the image is square, the pixel size for each dimension can not exceed 256. Failure to down sampling the image would lead to error in loading images.
• The output format of image reader is:
First column: image name
All other columns: image intensity for each pixel in the order of red, green and blue.
1.b. Instructions to fill out Azure blob parameters:
• Select ‘account’ for field ‘please specify authentication’
• Put Azure storage account name for field ‘account name’
• Account key is the key associated with Azure storage account
• Put the path to container
2. Use ‘pretrained cascade image classification’ module as the trained model to detect face
The ‘pretrained cascade image classification’ module utilizes OpenCV frontal face detection library. The original algorithm is Haar cascade face detection, which is robust and fast implementation of frontal face detection, while with limitations that it is sensitive to light condition and not applicable to side face detection.
There are two main parameters to be tuned in this module:
• Scale factor: It specifies how quickly OpenCV should increase the scale of search window between subsequent scans.This parameter may have a value of 1.1, 1.2,1.3 or 1.4.
• Minimum number of neighbors: it sets the cutoff level for discarding or keeping rectangle groups as ‘face’ or not, based on how many raw detections are in the group. The parameter’s value ranges from 0 to 1.
The default parameters (scale=1.1, min_neighbors=3) are tuned for accurate but slow detection. For faster implementation, settings can be changed to scale=1.3, min_neighbors=2.
3. Use R module to select the classification result.
As AML can not display more than 100 columns of data and the column number for image is usually exceed 100, the last two columns of detection result ‘Scored Labels’ and ‘Scored Probabilities’ can not be easily viewed. The customized R module would select only these two columns together with image name as the output of the face detection experiment.
The sample R code is:
dataset1 <- maml.mapInputPort(1)
new=cbind(dataset1["Image Name"],dataset1["Scored Labels"],dataset1["Scored Probabilities"]);
maml.mapOutputPort("new");
4. Note:
Right now, the size limit for web service input on Azure ML is 1000 columns. Therefore the input image format of web service for this face detection module should be in BASE64, a format which changes the intensity of image into string. At the same time, in the workstudio, there should be a decoding code to decode Base64 image to normal intensity image.
Contact: Ye Xing Email: yexing@microsoft.com