# Real-Time Pre-Identification and Cascaded Detection for Tiny Faces
## 3 Proposed Method
### Multitask Face Detector  
Before detecting the face, we pre-processed the image to reduce the size of the input. The detector is a shallow neural network, but the depth is enough to learn useful features of tiny faces, because the input of the detector is preprocessed, and background information and other interferences is greatly reduced. Another benefit of shallow neural networks is that the parameters are much smaller than deeper detectors, resulting in fast operation and real-time performance.  
Each image pyramid is passed to the face detector to detect the coordinates of the face. The real coordinates are calculated based on the detected coordinates of bounding boxes and the image pyramid scales. Finally, the NMS method is used to eliminate the redundant bounding boxes by getting multiple overlapped bounding boxes and reducing them to only one. The structure of our face detector is shown in Figure 1. The stride of the convolutional layer is 1, and the step size of the pooling layer is 2.  
Different convolutional kernel sizes may result in different feature extraction effects. Considering that the detected target is a tiny face with the input size is \(12\times 12\), we apply a \(3\times 3\) filter for all the convolutional layers. There are two tasks in the face detector, face classification and bounding box regression. Compared to other complex multiclass objection classification and detection methods, the input of our proposed network is the image pyramid generated from the set of RoI candidates and the number of classes is only 2, face and non-face, so this network does not need a deep network structure and a lot of convolutional kernels in each layer. ReLU is applied as nonlinearity activation function in this detector, which is:  
\[\rm{f(x)}=\left\{\begin{array}{ll}0,&x\leq 0\\ \rm{x},&x<0\end{array}\right.. \tag{3}\]  
Face classification is a binary classification problem, so we use the cross-entropy logistic regression function as the loss function. The function is designed as follows:  
\[\rm{L_{i}}=-\Big{(}y_{i}\log p_{i}+\Big{(}1-y_{i}\Big{)}\Big{(}1-\log p_{i} \Big{)}\Big{)}, \tag{4}\]  
where \(\rm{p_{i}}\) is the possibility calculated based on the input \(\rm{x_{i}}\); \(\rm{y_{i}}\) is the predicted class, \(\rm{y_{i}}\in\{1,\ 0\}\).  
For the task of bounding box regression, we employ the Euclidean loss of the offset between the predicted bounding box and the nearest ground truth. Predicted by the network are the upper-left coordinate, width, and length. The loss function is given by:  
\[G_{i}=\parallel\hat{b_{i}}-b_{i}\parallel^{2}, \tag{5}\]  
where \(\hat{b_{i}}\) is the class that the network predicts and \(b_{i}\) is the ground-truth coordinate. We use four values to represent a bounding box, i.e., the upper-left coordinate, width, and length. So \(\hat{b_{i}}\) and \(b_{i}\) are four-dimensional vectors.  
The total loss of this network is the weighted sum of the loss values of the above two functions. Faces are contained in RoI candidates after we preprocess the input of the multitask detector, therefore we give the face detector a high tolerance for features of tiny faces. This trick makes the tiny faces pass to the classification task of the multitask detector with a low threshold. Therefore, we give a big weight to the loss function of the bounding box. In addition, the total loss function is as follows:  
\[\text{Loss}_{i}=t_{1}\times L_{i}+t_{2}\times G_{i}, \tag{6}\]  
where \(L_{i}\) and \(G_{i}\) are the losses of face classification and bounding box regression respectively; \(t_{1}\) and \(t_{2}\) are the weights of each task. Here, \(t_{1}\) is set to 0.3 and \(t_{2}\) is set to 0.7.