# Face Recognition and Tracking Framework for Human-Robot Interaction
## 4 Methodology and Proposed Framework
### Face Recognition  
For the face recognition task, we utilize the additive angular margin loss (ArcFace) model by [PERSON] et al. [4] to extract the feature embeddings of the faces. ArcFace introduces an additive angular margin penalty \(m\) between the deep feature \(x_{i}\) and the target weight \(W_{y_{i}}\) to simultaneously enhance the intra-class compactness and inter-class discrepancy. It provides a more clear geometric interpretation due to its exact correspondence to geodesic distance on a hypersphere. ArcFace is inherited from the most common loss function, Softmax, and is defined as follows [4]:  
\[L_{arc}=-\frac{1}{N}\sum_{i=1}^{N}\log\frac{e^{s(cos\left(\theta_{y_{i}}+m \right))}}{e^{s(cos\theta_{y_{i}}+m))}+\sum_{j=1,j\
eq y_{i}}^{n}e^{s\cos \theta_{j}}}. \tag{2}\]  
In Equation (2), \(n\) denotes the number of classes in the training database, while \(N\) denotes the batch size. ArcFace model starts with extracting the face features \(x_{i}\) by utilizing a DCNN backbone. The backbone network is the bottleneck in terms of processing speed and model size; as in the testing, only this branch is involved so we selected the lightweight MobileFaceNet network [50] as a backbone. Then, based on the feature \(x_{i}\) and weight \(W\) normalization, we obtain the logit \(cos\theta_{j}\) for each class as \(W_{j}^{T}\,x_{i}\), and get the angle between the feature \(x_{i}\) and the ground truth weight \(W_{y_{i}}\) as \(arccos\,\theta_{y_{i}}\). After that, the angular margin penalty \(m\) is added to the target angle \(\theta_{y_{i}}\). Finally, we calculate \(cos(\theta_{y_{i}}+m)\) and multiply all logits by the feature scale \(s\). The logits then go through the softmax function and contribute to the cross-entropy loss. The results of the ablation study by [PERSON] et al. [4] showed that the performance comparison on the LFW, CALFW, and CPLFW datasets for the Arcface loss function outperformed others with 99.82%, 95.45%, and 92.08% accuracies respectively. It was performed against 11 other loss functions, including Softmax, Center Loss, SphereFace, and CosFace. This is the main reason why we selected Arcface as a loss function for the face recognition module.  
In the face recognition module, after the filtered faces are aligned, a deep face feature representation network transforms the aligned faces into a feature space. MobileFaceNet [50] was selected as a backbone for this task to handle the real-time constraints. Loss function optimization is challenging for large-scale face classification, as it is needed to strengthen the intra-class compactness and inter-class discrepancy for highly similar individual faces. For that, we used ArcFace as it outperforms the state-of-the-art functions. In addition, it enhances the discriminative power for learning deep features and maximizes the separability between face classes.  
Finally, the face recognition module outputs a 512-dimensional feature embedding, and then the predicted identity is calculated by comparing the generated embedding against the stored embeddings by calculating the cosine similarity [51]. The ArcFace model is trained on the MS1M database [14]. Given a face image, the image is aligned, scaled,and cropped before being passed to one of the models. This preprocessing is performed as described in [13] for ArcFace.