{'fraction_non_alphanumeric': 0.03651767455448437, 'fraction_numerical': 0.016568590626434624, 'mean_word_length': 4.573854384740637, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
A Jointly Learned Deep Architecture for Facial Attribute Analysis and Face Detection in the Wild

Facial attribute analysis in the real world scenario is very challenging mainly because of complex face variations. Existing works of analyzing face attributes are mostly based on the cropped and aligned face images. However, this result in the capability of attribute prediction heavily relies on the preprocessing of face detector. To address this problem, we present a novel jointly learned deep architecture for both facial attribute analysis and face detection. Our framework can process the natural images in the wild and our experiments on CelebA and LFWA datasets clearly show that the state-of-the-art performance is obtained.


Introduction
The problem of automatically analyzing the facial attributes received increasing attention recently [24,15,37]. Face attributes may potentially benefit a number of realworld applications, such as face alignment [22,26,36,38], head pose estimation [40,32] and face verification [28,27]. Analyzing facial attributes still remains challenging in realworld scenarios. For example, most existing works [24] predict the facial attributes on well-cropped face images.
In an extension to real-world scenarios, those works have to utilize the face detector to localize the bounding box of human faces before facial attribute analysis.
Such a pipeline of face detection followed by facial attribute prediction is nevertheless undesirable in real-world facial attribute prediction due to two reasons. Firstly, with the preprocessing of face detector, the capability of facial attribute prediction has to heavily relies on the results of face detection. Unfortunately in an uncontrolled setting [15], the face is likely to have large out-of-plane tilting, occlusion and illumination variations, which may affect the algorithms of face detection and facial attribute analysis simultaneously. For example, the Viola-Jones face detector [29] works well for near-frontal faces, but less effective for faces in the pose far from frontal views. Second, face detection is heterogeneous but subtly correlated with facial attribute prediction, and vice versa [33]. Efficiently and effectively exploiting this correlation may help in both detecting faces and predicting facial attributes.
We propose an end-to-end deep architecture to jointly learning to detect faces and analyze facial attributes. Essentially, the two tasks share the same bottom layers (feature map in Fig. 1) in the architecture to alleviate the problems of face variations aforementioned. For instance, one face region of one image is failed to be detected as a face due to the partial occlusion, and yet the network can detect the existence of some facial attributes such as "eyeglasses", and "smiling". The face region can still be used to optimize our network and in turn help supervise the learning of the face detection part, to improve the performance of face detection part.
In this work, the deep learning architecture is proposed for both face detection and facial attribute analysis. The network structure is illustrated in Fig. 1. Given an entire image, our architecture will firstly pass the image with convolutional layers (conv1-conv5) and max pooling layers to produce the conv feature map for face region proposals. The region of interest (RoI) pooling layer and face region proposal layer are two layers introduced to facilitate the jointly learning of our architecture. A region of interest (RoI) pooling layer pools each face proposal on the conv5 feature map into a fixed-length feature vector which is further processed by two fully connected layers (fc6 and fc7). Built on the fc7 layer, each individual task of facial attribute analysis and face detection are jointly optimized. By virtue of the face detection subnet, our architecture can directly predict the facial attributes from the whole images, rather than using the well-cropped images as previous work [20,24,31]. Extensive experiments on benchmark CelebA [15] and LFWA [9,15] datasets demonstrate that our method outperforms state-of-the-art alternatives.
Contribution. Our main contribution is to propose a novel deep architecture of jointly learning of face detection and facial attribute tasks, which is capable of utilizing both tasks to better optimize the shared network and thus improve the performance of both tasks. Two layers -region of interest (RoI) pooling layer and face region proposal layer are introduced to enable learning these two tasks simultaneously. More importantly, we can predict the facial attributes in the wild and the input images do not need to be cropped and aligned as the standard practice in [24,31]. Finally, our joint deep architecture achieves state-of-the-art result on the biggest benchmark dataset for facial attribute analysis-CelebA dataset [15] and LFWA [15,9] datasets.

Related Work
Facial attribute analysis. It was first studied by Kumar et al. [13]. In term of different visual features and distinctive learning paradigm, the facial attribute analysis has been developed into three categories: (1) the methods [13] of using hand-crafted visual features, such as SIFT [16] and LBP [18]; (2) the methods of utilizing the recent deep features [15,37,31]; and (3) multi-task methods of learning facial attribute [1,24]. We here highlight the differences between our architecture and these previous works. Liu et al. [15] cascaded three deep networks pre-trained for facial attribute prediction. In contrast, we show that the tasks of face detection and facial attribute prediction are highly correlated and our jointly learning architecture can improve both tasks. Rudd et al. [24] introduced a mixed objective optimization network which utilizes distribution of attribute labels to learn each task. Abdulnabi et al. [1] proposed a multi-task CNN model sharing of visual knowledge between tasks for facial attribute analysis. Comparing with [24,1], we focus on jointly learning the face detection and facial attribute analysis; and our model can predict facial attributes on the images in the wild [24,31] i.e. without cropped and aligned, as illustrated in Fig. 1 and Fig. 5.
Face detection. The work of Viola and Jones [29,30] made face detection usable in many real world applications. The cascaded classifiers were built on Harr-like features to detect human faces. The deformable part model (DPM) [6] on top of HOG feature is a general object detector and can also be used for face detection [4]. Recent advances of deep learning architectures also inspire another category of methods for face detection. Yang [34] used the fully convolutional networks (FCN) to generate the heat map of facial parts for producing face proposals. In contrast to these works, our face detection task gets benefit from not only the well-designed architecture (in Fig. 1), but also the jointly learning process with facial attribute prediction. Further inspired by Fast-RCNN [7,23], we take the face detection as a special case of the general semi-rigid object detection. More specifically, given an image, our face detection will try to answer two questions: (1) whether this patch contains faces or not? i.e. face score task in Fig. 1. (2) can we de-tect the bounding box of faces if there is any face? i.e. face bounding box task in Fig. 1. The jointly optimizing these two sub-tasks will better solve face detection.
Multi-task learning. Our framework can be categorized as multi-task learning [35,19], which shares the information and explores the similarity of related tasks on the same data. The multi-task learning can facilitate a wide range of tasks and applications, including but not limited to action recognition [39], information retrieval [14], facial landmark detection [36,20], and facial attribute prediction [25,5,1,21,17]. The recent technical report [20] also combine face detection with the tasks of locating face landmarks and recognizing gender. However, unlike our facial attribute prediction on the images in the wild, their work still has to firstly detect face regions for the facial landmarks and predicting gender.

Our Deep Architecture
In this section, we firstly overview our network in Sec.  Figure 1 shows our framework for jointly face detection and attribute analysis. Our architecture takes an entire image as input and a set of face bounding boxes as labels for training. The whole network firstly processes the image with several convolutional layers (conv1-conv5), and max pooling layers to produce a conv feature map for face region proposal. For feature map of each proposed face, we employ a region of interest (RoI) pooling layer to pool it into a fixed-length feature vector. Each feature vector is further processed by two fully connected layers (fc6 and fc7) and thus used for the tasks of facial attribute analysis and face detection. On top layers, our architecture has face detection branch and facial attribute branch.

Overview
Our network follows the art and design of VGG-16 [3]. Particularly, the kernel size, stride and the number of filters in convolutional layers (conv1-conv5) and the two fully connected layers (fc6 and fc7) are exactly the same as the corresponding layers in VGG-16 architecture.

Task formulation
Suppose we have the labelled source training dataset D s = {I, a, L} with N training instances and M attributes. I denotes the patches of training images and L denotes the labels. We use the L matrix to both denote whether an image patch contains the face, and whether a facial attribute exists in the image patch. Particularly, for the i-th image patch I i (i = 1, · · · , N ), we use L i = 0 to indicate that this image patch does not contain a human face. If I i is a face image patch, we use L ij = +1 to denote the existence of j−th facial attribute a j (j = 1, · · · , M ); L ij = −1 otherwise.
As illustrated in Fig. 1, our network extracts the image patch to a 4096 − dim feature vector, and it is denoted as f (I; Θ), where Θ is the parameter set of the deep architecture. We have the prediction tasks of facial attribute, face score and face bounding box. Each task has their own parameters on the last layer.
Facial attribute prediction. To predict the attributes of the image I * , we need to learn a function L * ia = Ψ (I * ) to predict the facial attribute a. We thus have the predicting func- where W a ⊆ R 4096×40 for all 40 attributes. Face score. This task aims to predict the score whether an image patch is face. Essentially, we need to learn Φ (x) : where W a ⊆ R 4096×2 for binary prediction task. Face bounding box. We regress the bounding box of faces by Ω (x) : R 4096 → R 4 , and we configure the form as

Face region proposal layer
Inspired by the work of object detection [23], our network has the branch of face region proposal. Specifically, this branch takes an image of any size as input and outputs a set of rectangular face proposals. To generate the facial region proposal, we slide the branch over the convolutional feature map after the five convolutional layers (conv1-conv5) in Fig. 1. The extracted conv5 features are further fed into two sibling fully connected layers, i.e. face bounding box (bbox) and face score layer. Face bounding box layer employs the smooth L 1 loss (defined in [7]) enables a regressor to predict the facial bounding box. Face score layer utilizes the softmax loss to indicate whether the bounding box is a face. For each image, we selected top-300 face region proposals in term of the face scores computed.

The RoI pooling layer
The RoI pooling layer can convert the feature maps of face region proposal (with the size of h × w) to a fixed spatial extent of H × W , which facilitates the further process. Here, h, w, H, W are heights and widths of each rectangle region of feature map in Fig. 1. For the varying size of input feature patches, we vary the size of filters of pooling layer with the sub-window of approximate size h/H ×w/W . The RoI pooling technique is adopted from the work of object detection [7] which inspired by the SPPnets [8].

Facial attribute analysis and face detection
The fixed-length feature vector extracted from RoI Pooling layer is further fed into two fully connected layers (fc6 and fc7) in order to enable the tasks of facial attribute analysis. Particularly, built on the layers of fc6 and fc7, the multitask network structure is employed to analyze each attribute individually. This can be modeled as the minimization of the expected loss over all the training instances which is where L (I; Θ, W a , W s , W b ) is the loss function of jointly learning; and we have L (I; Θ, W a , W s , W b ) = λ 1 L a (Φ (f (I))) + λ 2 L s (Ψ (f (I))) (2) here the loss function L a (Φ (f (I))) on facial attribute prediction is the mean square error loss of all attributes; we use softmax loss L s (Ψ (f (I))) for face score task, and finally the smooth L 1 − loss L b (Ω (f (I))) [7] is employed to regress the face bounding box. We denote the shared parameters of deep architectures as Θ which are jointly optimized by all these three tasks. Since these three tasks are highly related, learning in such a way can not only greatly reduce the prediction error of each individual task, but also accelerate the convergence rate of learning the whole network. For the testing image I k , the predicted resultL kj of the j−th facial attribute a j (j = 1, · · · , M ) is thresholded bŷ where τ is the threshold parameter.

Datasets and settings
We conduct the experiments on the CelebA dataset [15] and LFWA dataset [9,15]. CelebA [15] contains approximately 200k images of 10k identities. Each image is annotated with 5 landmarks (two eyes, the nose tips, the mouth corners) and binary labels of 40 attributes. To make a fair comparison with the other facial attribute methods, the standard split is used here: the first 160k images are used for training, 20k images for validation and remaining 20k for testing. CelebA provides two types of training images, i.e., aligned and cropped face images and raw images as shown in the first and second row of Fig. 4 respectively. We use the raw images for training our joint deep architecture. Since there is no ground-truth bounding box label for faces in raw images, the face detector [4,11] is employed here to help generate the face bounding box for training images. We use the implementation of dlib toolbox [11,4] for generating labels. Note that face bounding box generation is only required in the training stages for synthesizing labels. At testing phrase, raw images are directly input for both facial attribute analysis and face detection.
LFWA [15] is constructed based on face datasets LFW [9]. It contains approximately 13143 images of 10k identities. Following [15], 50% of the images for training, and the other 50% are used for testing. LFWA has 40 binary facial attributes, the same as CelebA. We also generate face bounding box for LFWA to train our joint learning network.
Evaluation metrics. We take the attribute prediction as classification tasks and thus mean accuracy can be computed. Particularly, we evaluate the performance as comparable to [24,15] by the mean error which is defined as mean error = 1 − mean accuracy.
Implementation and Parameter settings. The τ is set as 0 in Eq (3); and square error loss is used in Eq (1). We empirically set λ 1 = λ 2 = 1, λ 3 = 2 in Eq (2). The convolutional layers and fully connected layers are initialized by the 16 layer VGG network [3] individually. We use the open source deep learning framework Caffe [10] to implement our structure. A single end-to-end model is used for all the testing. We employ the stochastic gradient descent to train our network. Dropout is used for fully connected layers and the ratio is set to 0.5. For training CelebA dataset, with initial learning rate 0.001, and gradually decreased by 1/10 at 100k, 150k iterations, the total training iterations are 180k. For training LFWA dataset, as there are only limited training images -6263, We fine-tune from pre-trained CelebA model, with initial learning rate 0.0001, and decreased by 1/10 at 40k iterations, the total training iterations is 60k. Once trained, our framework can predict the facial attributes and detect faces on the images in the wild for any testing images.

Competitors.
Our model is compared against state-of-the-art methods and several baselines. Particularly, (1) FaceTracer [12] is one of the best methods with the hand-crafted features. The features used including HOG [2] and color histograms of facial regions of interested to train SVM classifier for predicting facial attributes. (2) LNets+ANet [15] migrates two deep CNN face localization networks to one deep CNN network for facial attribute classification. (3) Walk and Learn [31] learns good representations for facial attributes by exploiting videos and contextual data (geo-location and weather) as the person walks. (4) Moon [24] is a mixed objective optimization multi-task network to learn all facial attributes, achieves the best result on CelebA dataset. (5) Cropped model is a variant of our model without using the face detection branch. The raw image is also used as the input and we crop the faces from the images by Dlib toolkit to train facial attribute models. The processed face images are utilized to train the model. (6) Aligned model uses the aligned and cropped images provided by CelebA and LFWA to train facial attribute model, which is used by most of the state-of-the-art methods. To make a fair comparison, these two baseline models are initialized by 16 layer VGG network; same as the proposed structure.

Comparison with the State of the Art
We compared our model with state-of-the-art methods: FaceTracer [12], LNets+ANet [15], Walk and Learn [31], Moon [24] and two baselines. The results on the testing split of CelebA and LFWA are reported in Tab. 1, Fig. 2 and Fig.  3, respectively. Note that please refer to the supplementary material for the full comparison results on each attribute. Comparing with all the competitors, we draw the following conclusions.
Our model beats all the other methods by the mean error on CelebA and LFWA dataset. As we can see from Fig. 2, our approach obtains the mean error 8.41% which is the lowest among all the competitors, and it outperforms all the other methods on CelebA dataset. And on LFWA dataset as shown in Fig. 3, our mean error is only 13.13% which is the lowest among all the competitors. This validates the efficacy of our joint learning architecture. Particularly, We compare the classification error in each individual attribute in Fig. 2 and Fig. 3. We note that on more than half among the total 40 attributes, our framework is significantly better than the other competitors, since our jointly learning architecture can efficiently leverage the information between face detection and facial attribute prediction. Particularly, comparing with the other works, all our attribute prediction tasks share the same deep learning architecture, i.e. conv1-conv5, feature map and fc6, fc7 layers as illustrated in Fig. 1). These shared structures implicitly model the correlations between each attribute task. Furthermore,  The second row is CelebA raw images. We train our end-to-end model on raw images. on gender attribute prediction, our framework can achieve 1.7% error on CelebA; in contrast, the error of HyperFace [20] is 3.0%. That indicates that our results can get 1.3% improvement over that of HyperFace [20].
Our model can process the images in the wild. Our face region proposal and RoI pooling layers are flexible enough to directly process the images in the wild. This thus better demonstrates the effectiveness of our models. Specifically, our model not only achieves the best performance on the benchmark dataset -CelebA and LFWA, but also our tasks of facial attribute prediction do not need to align and crop the facial images as have done in many previous work [24,12,15]. Additionally, unlike the work of Walk and Learn [31], our model is not trained by the external data; and yet still obtains better results than Walk and Learn [31].
Our model is very efficient in term of jointly learning to detect faces and predict facial attributes. Our joint learning results have greatly improved over those of two baseline models -Cropped, Aligned models. These two methods are yet another two naive baselines of directly learning the facial attribute tasks. Particularly, on CelebA dataset, our model beats the two methods on the classification error of 27 attributes (totally 40 facial attributes) as compared in Fig.  2. Figure 3 shows that our joint model hit better results than the two baseline models on all the 40 attributes. This reveals attribute prediction tasks get benefit from the face detection task. Also note that unlike LNets+ANet [15] using two networks to localize the face and another one network to extract features, we can train our model by a single endto-end network here since the shared architectures (conv1 -conv5) can explicitly model the important facial parts, again thanks to the face detection subnet.
Qualitative results. The important facial parts extracted by the shared feature map are visualized in Fig. 5. In particular, four groups of images are shown; and the feature map has higher activation on the regions of human faces. The first 3 columns are success cases, even thought the images have large pose (Column 2) or very high occlusion (Column 3). We also list some failure examples in Column 4, which are some extreme cases. Some of them are caused by ambiguous or too small view (e.g. the cat face is also similar to human's). The feature map reveals our model pay attention on the important facial parts which helps to analyze facial attributes.

Results of Face Detection
Our face detection is compared against the face detector of dlib toolbox [11], which is an implementation of the generic object detector [4] on face images. On CelebA dataset, there are only 5 landmarks of faces, but no labeled ground-truth bounding box of faces for raw images. We generate the ground truth bounding box by 5 landmark coordinates for the test set. If the IOU (Intersection over Union) of predicted bounding box and the ground truth bounding box is larger than 0.5, we assume the prediction is correct. We compare the two detectors on the testing split of CelebA.
The results are shown in Fig. 6. We compare the Precision-Recall curve for two methods. We find that both the Dlib detector and our face detector can achieve very high face detection on the CelebA test set as shown in the left subfigure of Fig. 6, which shows the efficacy of both de- tectors of solving the task of face detection. Nevertheless, our face detector still beats the Dlib detector by a relatively large margin. The AUC values of Dlib detector and ours are 0.938 and 0.982 respectively. To better show the difference, we highlight the up-right corner of PR curve in the right subfigure as shown in Fig. 6. This result further proves that our jointly learned architecture can make the face detection and face attribute tasks help each other via sharing the same parameters of the deep network. This shows that attribute learning does help for face detection also it provides more detailed information about the face.

Conclusion
In this paper, we propose a novel joint deep architecture for facial attribute prediction and face detection. Different from the previous pipeline of face detection followed by facial attribute prediction, our architecture takes an entire image as input, enables both face detection and facial attribute analysis. The proposed architecture can not only exploit the correlation of face detection and face attribute prediction, but also boost both tasks. The experimental results on CelebA and LFWA datasets show the efficacy of proposed methods over the other state-of-the-art methods.