{'fraction_non_alphanumeric': 0.026033322652995836, 'fraction_numerical': 0.010333226529958347, 'mean_word_length': 4.618586858685869, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Deep Feature-based Face Detection on Mobile Devices

We propose a deep feature-based face detector for mobile devices to detect user's face acquired by the front facing camera. The proposed method is able to detect faces in images containing extreme pose and illumination variations as well as partial faces. The main challenge in developing deep feature-based algorithms for mobile devices is the constrained nature of the mobile platform and the non-availability of CUDA enabled GPUs on such devices. Our implementation takes into account the special nature of the images captured by the front-facing camera of mobile devices and exploits the GPUs present in mobile devices without CUDA-based frameorks, to meet these challenges.


Introduction
Current methods of authenticating users on mobile devices are mostly PIN or pattern based, which provides authentication only during the initial login. Password-based methods are susceptible, because people sometimes set passwords that are easy to guess or are repetitive [1] and pattern-based systems are vulnerable to smudge attacks [2]. Once the attacker successfully bypasses the initial authentication barrier, the phone has no way of blocking or denying the attacker. Continuous authentication systems deal with this issue by continuously monitoring the user identity after the initial access to the mobile device based on how the user interacts with the mobile device. Examples of such systems include touch gesture-based systems [3], [4], [5], face-based systems [6], [7], [8], gait-based systems [9], stylometrybased methods [10], speech and face-based method [11] [12] and sensor-based methods [13], [14]. It has been shown that face-based recognition can be very effective for continuous authentication [11], [7], [15], [8].
Face detection is a very important step in face-based authentication systems. There has been substantial progress in detecting faces in images, which have impressive performances on challenging real-world databases [16]. But such databases are predominantly composed of general surveillance or media type images and not specifically of images captured using front-facing cameras of smartphones. As we shall discuss later, face images captured using the frontfacing cameras of mobile devices possess some unique features that can be used as powerful prior information to simplify the task of face detection on mobile platforms. This paper proposes a deep convolutional neural network (DCNN)-based face detection scheme for mobile platforms.

Motivation
State of the art face detection techniques are based on DCNNs [17], [18]. Variations of DCNNs have been shown to perform well in various datasets like Face Detection Dataset and Benchmark (FDDB) [19] and Annotated Face in-the-Wild (AFW) [20]. Though DCNN-based methods can run on serial processors like CPUs, they are prohibitively slow without parallel processors like GPUs. Mobile devices and consumer electronics products like cameras often have in-built face detection systems, but since they do not have much computational horsepower, simpler detection algorithms are implemented on them, which do not have as high a performance as DCNN-based methods but can run on low power mobile platforms. Thus, there is a tradeoff between high performance and hardware and power constraints. This paper seeks to reconcile the two competing objectives and studies the feasibility and effectiveness of DCNN-based face detection methods in mobile platforms. Clearly, the most powerful DCNN-based face detectors that are designed to run on desktop environments will not be a good candidate for a DCNN-based detector for mobile platforms. Below are a few differences between the two tasks.
1. Differences in hardware and software setup:

Differences in dataset:
• Generic face databases may have images with multiple small faces while the front-facing camera captures face images when the user is using the phone and hence may have one large face image. Therefore, we can restrict ourselves to detecting a single face only. Also, given the typical distance at which the user interacts with his or her phone, we can make assumptions about the maximum and minimum sizes of the captured faces.
• The images captured by the front-facing camera usually have the user's face in a frontal pose. Extreme pose variations are rare and one can focus on detecting faces with minor pose variations.
• Faces captured by the front-facing camera, however, tend to be partial. A mobile face detector should be equipped to detect partial faces, which is not the focus of many generic face detectors.
This paper makes the following contributions: • Exploiting the unique nature of the face detection problem on mobile platforms, we design an effective, simplified DCNN-based algorithm for mobile platforms that need not be as powerful as general face detectors, but is fine-tuned to work in a mobile setting.
• Most of the existing implementations of DCNNs use a CUDA backend, but most mobile GPUs are not Nvidia GPUs, hence they do not support CUDA. We develop libraries (in OpenCL and RenderScript) to implement DCNN-based algorithms on GPUs without resorting to CUDA, so that the algorithm is portable across multiple platforms.
Rest of the paper is organized as follows. We first survey related works that have influenced the current algorithm and discuss their advantages and disadvantages. Section 2 introduces the algorithm in full details and ends with a discussion on the salient features of the algorithm. Section 3 explores the details of the actual implementation of the algorithm on a mobile platform. Section 4 presents evaluation results of the algorithm on two datasets, UMD-AA and MO-BIO. Finally we draw some conclusions about the algorithm and suggest some future directions.

Related Work
Cascade classifiers form an important and influential family of face detectors. Viola-Jones detector [21] is a classic method, which provides realtime face detection, but works best for full, frontal, and well lit faces. Extending the work of cascade classifiers, some authors [22] have trained multiple models to address pose variations. An extensive survey of such methods can be found in [16].
Modeling of the face by parts is another popular approach. Zhu et al. [20] proposed a deformable parts model that detected faces by identifying face parts and modeling the whole face as a collection of face parts joined together using 'springs'. The springs like constraints were useful in modeling deformations, hence this method is somewhat robust to pose and expression changes.
As mentioned before, current state-of-the-art methods involve deep networks, which have been extensively adopted and studied both by the academic community and industry. Current face detectors at commercial companies like Google and Facebook use massive datasets to train very deep and complex networks that work well on unconstrained datasets, but they require huge training datasets and powerful hardware to run.
Recent studies have shown that in the absence of massive datasets or hardware infrastructure, transfer learning can be effective as it allows one to introduce deep networks without having to train it from scratch. This is possible as lower layers of deep networks can be viewed as feature extractors, while higher layers can be tuned to the task at hand. Therefore, one can use the lower layers of common deep networks like AlexNet [23] to extract general features, that can then be used to train other classifiers. Works of Bengio et al. [24] have studied how transfer learning works for deep networks.
Specific to the mobile platform, Hadid et al. [6] have demonstrated a local binary pattern (LBP)-based method on a Nokia N90 phone. Though it is fast, it is not a robust method and was designed for an older phone. Current phones have more powerful CPUs and more importantly, even GPUs, which can implement DCNNs.
Finally, let us consider the datasets used for mobile face detection. While there are many face databases available, they are not suitable for evaluating mobile face detection algorithms. MOBIO is a publicly available mobile dataset [11] which consists of bi-modal (audio and video) data taken from 152 people, but it is a very constrained one as users are asked to keep their faces within a certain region, so that full faces are captured. A more suitable dataset for our purpose is the semi-constrained UMD-AA dataset [7], which shall be described in a later section.

Deep Features-based Face Detection on Mobile Devices
As mentioned briefly before, transfer learning is an effective way to incorporate the performance of deep networks. The first step of the Deep Features based Face De- tection on Mobiles (DFFDM) algorithm is to extract deep features using the first 5 layers of Alexnet. Different sized sliding windows are considered, to account for faces of different sizes and an SVM is trained for each window size to detect faces of that particular size. Then, detections from all the SVMs are pooled together and some candidates are suppressed based on an overlap criteria. Finally, a single bounding box is output by the detector. In the following subsections, the details of the algorithm and model training are provided. Figure 1 provides an overview of the entire system.

Dataset
The UMD-AA dataset is a database of 720p videos and touch gestures of users that are captured when the user performs some given tasks on a mobile device (iPhone) [7]. There are 50 users (43 males and 7 females) in the database, who perform 5 given tasks (eg, typical tasks like scrolling, reading, viewing images etc.) in three illumination conditions (a room with natural light, a well-lit room and a poorly lit room). A total of 8036 images, spread over all users and all sessions, were extracted from these video recordings and manually annotated with bounding boxes for faces. Of these 6429 images had user's faces in the frame and 1607 were without faces, or with faces at extreme poses, with eyes and nose not visible or a very small partial face visible in the frame, which are all the cases when we can safely say there is no face present in the frame.

Training SVMs
For training, 5202 images from the UMD-AA database is used. Analysing the distribution of face sizes, we find that the height of faces vary from around 350 to 700 and the width varies from 300 to 600. A 2D histogram of the height and widths of the faces in the dataset are shown in Figure 2.
Now the images are captured at 720p resolution (1280 rows x 720 columns). But since that resolution is too high for our purpose, we resize it to 640 x 360. Therefore typical faces range from 175 to 350 rows and 150 to 300 columns in this reduced resolution.
First we extract deep features from these resized images by forwarding them through AlexNet [23]. We tap the network at the 5th convolutional layer (after max-pooling). The standard AlexNet reduces an image by a factor of 16 in both dimensions. Thus, if the k th input image is of size p k × q k , the output is of dimensions w k × h k × 256, where the feature space width w k and height h k are given by (1) The 3rd dimension is 256 because the 5 th layer of AlexNet uses 256 filters. Given the typical face dimensions in the last paragraph, they are reduced by a factor of 16 in the feature space to heights ranging from 10 to 22 and widths ranging from 9 to 19 approximately. Obviously, a single sized sliding window cannot account for these varying sizes, therefore we consider windows of width starting from 8 and increasing to 20 in steps of 2, and height starting from 9 and increasing in steps of 2 to 23. In total we get 56 different window sizes for which we need to train 56 different SVMs. We denote a window by W ij , where i denotes its window height and j denotes its window width.
Let w k and h k , as defined in (1), denote the width and height of the deep feature for the face in the k th training image. The face from the k th training image is used as a positive sample for the SVM W ij , if Eq. (2) is satisfied.
for some threshold for selecting positive samples, t p . That is, we select those faces for W ij whose sizes are comparable and close to the window's dimensions.
For negative samples, we extract random patches of size i × j from those training samples which have no faces. If the k th training sample has a face of size w k × h k , and for a particular window W ij , if (3) holds, for some threshold for selecting negative samples, t n , then we extract a few random patches from the k th training sample that act as negative samples for W ij . That is, if the face in an image is of a very different size from the current window W ij under consideration, we extract negative samples from it, so that W ij gives a negative response of faces of different size. Finally, since the UMD-AA database does not have many images with no faces, we extract some random negative patches from images of the UPenn Natural Image Database [25].
Once we have extracted the positive and negative samples for each window size, we discard those window sizes which do not have enough positive examples. Then we convert the three dimensional deep feature patches into a single dimensional feature vector. Thus for W ij , we get a feature vector of length i × j × 256. We estimate the mean and standard deviation of features from each window, which are used to normalize the features.
Next we train linear SVMs for each window. Since we get a very long feature vector, it is difficult to train an SVM with all positive and negative samples together. To make the training tractable, we divide the samples into batches and train over many cycles. Specifically, let p ij be the number of positive samples for W ij . Then we choose a small number of negative samples say n ij and train the SVM. Then we find the scores of the n ij negative training samples using the weights we get after training and retain only those that are close to the separating hyperplane and discard the rest. We refill the negative samples batch with new negative samples and continue this cycle multiple times. This procedure is performed for each SVM.

Full Face Detection Pipeline
After the SVMs are trained, we can scan the deep feature extracted from the given image k in a sliding window fashion for each SVM. Specifically for an image of size w k × h k , the deep feature is of h k rows and w k columns as given by (1) and 256 depth. Therefore, for W ij , we can slide the window from position (1, 1), which is the top left, to (h k − i, w k − j). Let (r ij , c ij ) denote the position where the SVM yields highest score. Then we say that a bounding box, whose top left is at 16 × (r ij , c ij ) and has width 16 × j and height 16 × i is the prediction from W ij . Note that we multiply by 16, because the feature space's height and width is approximately 16 times smaller than that of the original image.
Now that we have 1 prediction from each of the 56 SVMs, we need to combine them to get a single prediction. A modified version of the non maximal suppression scheme used by Girshick et al. [26] is used for this purpose. First we sort the 56 proposals by their scores and then pick the candidate with the highest score. Boxes that overlap significantly with it and have a considerably lower score than it are ignored. This is continued for the next highest scoring candidate in the list, till all boxes are checked. After this we process the remaining candidates by size. If a larger box significantly overlaps a smaller box, but the larger box has a slightly lower score than the smaller box, we suppress the smaller box. This is useful in the following scenario: A smaller SVM may give a strong response for part of a full face, while the larger SVM responsible for detecting faces of that size may give a slightly lower response. But clearly the larger SVM is making the correct prediction, so we need to suppress the overlapping smaller SVM's candidate. After performing these suppressions, we pick the SVM's candidate that has the highest score. We then choose a suitable threshold, and if final candidate's score is larger than that, we declare a face is present at that location, else declare that there is no face present.

Salient Features
Sliding window approaches usually work on the principle of extracting appropriate features and then sliding a window and deciding if an object is present in that window or not. The proposed algorithm, DFFDM, can be thought of as using DCNNs to extract the features for the sliding window approach. However, to make the sliding window approach work for detecting faces of varying scales, we need to ex-tract features across scaled versions of the input image. The approach followed by Ranjan et al. in [17] is based on extracting deep features at multiple resolutions of the image and then training a single SVM to detect faces.
Clearly extracting deep features is a very costly operation because of the sheer number of convolutions involved. Passing the image at multiple resolutions through the network increases the workload even more. Therefore, the proposed algorithm passes the image through the DCNN only once, but trains SVMs of different sizes to achieve scale invariance. Also, the different SVM sizes help in detecting partial faces. For example, tall and thin windowed SVMs are usually trained with left half or right half faces, while short and fat windowed SVMs are trained for top half of faces. SVMs whose aspect ratio match a normal full face's aspect ratio are trained on full faces. Thus, different sized windows help in scale invariance as well as in detecting partial faces.

Implementation
Current popular deep learning platforms include Caffe, Theano and Torch. Although, these platforms have a CPU only version, they are significantly slower than the GPU enabled versions. These platforms have a CUDA based backend that offloads the heavy, but parallelizable, computations involved in a convolutional deep network to an Nvidia GPU. Nvidia has been actively developing and supporting deep learning research and has released optimized libraries such as cuDNN. Thus, although there are multiple frameworks in the deep learning system, the computational backend is dominated by CUDA based-code and Nvidia GPUs.
Unfortunately, CUDA is proprietary and works only for Nvidia's CUDA enabled GPUs. Therefore, existing deep learning frameworks are difficult to port on to GPUs made by other vendors. Current mobile devices have GPUs that are predominantly provided by Adreno, Mali and PowerVR. Nvidia's mobile processor Tegra does power some phones and tablets, and these devices support CUDA, but the overwhelming majority of devices do not have CUDA enabled GPUs.
OpenCL [27] is an open standard, developed by Khronos Group, to support multiple vendors and facilitate cross platform heterogeneous and parallel computing. All major vendors like Qualcomm, Samsung, Apple, Nvidia, Intel and ARM conform to the OpenCL standard. Thus OpenCL is a portable option for implementing convolutional networks in GPUs other than those made by Nvidia. Recently though, Google has developed RenderScript to facilitate heterogeneous computing on the Android platform.
Mobile devices are obviously not an ideal platform to perform training on massive datasets. But once the model has been trained, we can hope to run the forward pass on mobile platforms. Thus to harness GPUs of mobile devices to perform the convolution heavy forward pass, we have implemented OpenCL and RenderScript-based libraries. The OpenCL library is general and should work on any GPU, while the RenderScript library is specifically tailored for Android. An Android specific example is the use of Schraudolp's fast exponentiation [28] to approximately but quickly compute the normalization layer in AlexNet. Full exponentiation takes a significant amount of time and can become bottlenecks in weaker mobile GPUs.
The OpenCL and RenderScript libraries implement the primary ingredients for a basic convolutional deep network: convolution and activation layers, max pooling layers and normalization layers, each of which can be parallelized on GPUs. By appropriately stacking up these layers in the correct combination and initializing the network with pretrained weights we can build a CNN easily. For our purpose we have implemented the AlexNet network as described earlier, but we can easily build other networks given its weights and parameters. For an image of size 360x640, a single forward pass, running on a machine with 4th generation Intel Core i7 and Nvidia GeForce GTX 850M GPU, takes about 1 second for the OpenCL implementation. For an image of the same size, on the Renderscript implementation running on different phones, we summarize the run time results in Table 1. Only about 10% or less of this run time is due to max-pooling layer, normalization layer, SVMs and non maximum suppression. The rest of the time is due to the heavy computations of the convolutional layers. Continuously running the algorithm on a Nexus 5 drains the battery at 0.45% per minute, while leaving the phone undisturbed drains the battery at around 0.16% per minute.

Phone
Runtime

Evaluation and Results
For evaluation, we consider common metrics like Precision-Recall plots, F1 scores and Accuracy. We compare the performance of our algorithm on the UMD-AA [7] and MOBIO [12] [11] datasets with Deep Pyramid De- formable Part Model (DP2MFD) [17], which is among the state-of-the-art algorithms for some challenging datasets like AFW and FDDB, deformable part model for face detection (DPM) [20] and Viola Jones detector (VJ) [21].
We compute detections based on 50% intersection over union criteria. Let d be the detected bounding box, g be the ground truth box and s be the associated score of the detected box d. Then for declaring a detection to be valid, we need Eq. (4) to be satisfied for some threshold t

UMD-AA Dataset
Results on UMD-AA dataset are summarized in Table 2 To check the robustness of the detector, we vary the intersection-over-union threshold as defined in Eq. (4) from 0.1 to 0.9 and plot the resulting F1 score in Figure 4 and accuracy in Figure 5. We see that the DFFDM algorithm gives better performance at higher overlap thresholds too.
A few example positive and negative detections are shown in Figure 7. The detections are marked in red, while The third row shows some false detections, or detections with score lesser than 1. The detector is quite robust to illumination change and is able to detect partial or extremely posed faces.

MOBIO Dataset
Results on MOBIO dataset are summarized in Table 3. The MOBIO dataset has full frontal faces only, therefore we get very high performance. DP2MFD beats our algorithm for this dataset, which can be attributed to the fact that DP2MFD is one of the best algorithms, trained on a large, varied dataset, and for full frontal faces it has near perfect performance over multiple scales. For DFFDM, SVMs of different sizes were trained, based on the typical size of faces captured by the front camera. But sometimes for very large or small faces, the training dataset of UMD-AA may not have enough samples, therefore for extremely scaled faces, DFFMD may fail. This can be remedied by training on a larger database, and also by training SVMs on more scales. A few example positive and negative detections are shown in Figure 7. The first row shows positive detections while the second row shows failures.

Conclusion and Future Directions
This paper presents a deep feature based face detector for locating faces in images taken by a mobile device's front camera. Keeping the constrained nature of the problem in mind, the algorithm performs only one forward pass per image and shifts the burden of achieving scale invariance to the multiple SVMs of different sizes. As is expected from DCNN-based algorithms, it outperforms traditional featurebased schemes at the cost of a longer run time. Thus although DCNN based methods do not seem suitable for real time monitoring due to their run times on mobile devices, they can still be used as a backup in case a simpler detector fails. However there is much scope of optimizations and also mobile hardware has been getting more and more powerful, which looks promising.
This study also produced OpenCL and RenderScript based libraries for implementing DCNNs, that are more portable and suitable for mobile devices than CUDA based frameworks currently in popular use.
Future directions of inquiry includes code optimizations to make the GPU utilization faster thus speeding up the whole process. Also, we wish to explore simpler DCNNs that may be more suited to the mobile environment than a full blown AlexNet. Finally, the libraries used for this algorithm are more portable than CUDA based libraries and we hope to expand on them to facilitate research on deep networks on mobile GPUs.