# Thermal Image Generation for Robust Face Recognition
## 5 Thermal-FaceNet  
This section implements the FaceNet model to perform face recognition with the synthetic thermal images obtained with our generation model. However, as FaceNet works with visible images, it must be trained using thermal images to create Thermal-FaceNet. We have more than 100k thermal images to carry out this task. FaceNet is a deep neural network system capable of performing facial recognition tasks using image embedding. This embedding allows representing the face to be classified using a distance comparison or classifiers. FaceNet training is based on three image L2 distance optimization: the anchor, positive and negative. The FaceNet loss function (Equation (5)) is called triple loss, and it is composed of a function \(f(x)\) that refers to the embedding of the image, \(\alpha\) which represents the margin between positive and negative images. The prefixes \"\(a\), \(p\), \(n\)\" refer to \"anchor, positive and negative\". Given an image \(x\), we want to minimize the loss function in relation to the distance between the anchor and the positive image. We also want to maximize the distance between the anchor and the negative image. FaceNet ensures that the images of different people are kept further apart while the images of the same person are closer in the embedding space. \[\sum_{i}^{N}\Bigl{[}||f(x_{i}^{\,a})-f(x_{i}^{\,p})||_{2}^{\,2}-||f(x_{i}^{\,a })-f(x_{i}^{\,n})||_{2}^{\,2}+\alpha\Bigr{]} \tag{5}\]  
FaceNet uses two types of CNNs, one called the Zeiler and Fergus architecture [56] and the other based on Google's Inception models [57]. [PERSON] and Fergus can see the internal CNN process, which allows the visualization of layers and operations. The inception model uses multiple convolutions simultaneously in parallel and concatenated. This work uses  
Figure 7: Examples of synthetic thermal face images obtained with the proposed system. the implementation proposed in the original article [8] in TensorFlow but retraining the system using thermal imaging. The face recognition experiment consists of training a FaceNet system with thermal images to correctly recognize the faces of every subject in the database. The thermal database was divided into two sets, one for the training and the other to perform a test, with data not used in the training phase. The size for the training database was 97,991 images, while for the test, it was 5146 thermal images. All the images are squares of size 256 \(\times\) 256 pixels, and the number of classes was 3327. Table 3 shows the parameters used to train the Thermal-FaceNet system. We use the validation rate to evaluate the model, such as in FaceNet [8]. For the classification of the images, a squared L2 distance threshold \(D(x_{i},x_{j})\) is used with a pair of two faces. All face pairs \((i,j)\) of the same identity are denoted with \(P_{same}\). We can define \(TA(d)\) as all the face pairs that were correctly classified as the same as threshold \(d\). Thus, the validation rate \(VAL(d)\) is defined in Equation (6) as:  
\[VAL(d)=\frac{|TA(d)|}{|P_{same}|} \tag{6}\]  
Figure 8 shows the model's training results, where the convergence of the model for the accuracy and loss is appreciated. We use the \(VAL(d)\) as the system accuracy. Note that the model is capable of learning, and, after about 5000 steps, the model has already reached its convergence, obtaining a high value of accuracy, almost 100% accuracy. We tested the already-trained Thermal-FaceNet model with a set of 5146 thermal images of 256 \(\times\) 256 pixels. The results are presented in Table 4, showing the excellent results obtained by Thermal-FaceNet, allowing robust recognition of people's faces from the created database. The accuracy of the model is almost 100%. Figure 8: Thermal-FaceNet model training charts for accuracy and loss.