# Fine-Tuning of Pre-Trained Deep Face Sketch Models Using Smart Switching Slime Mold Algorithm
## 3 Proposed SMA-Based Method
### Fine-Tuning of Pre-Trained Deep-Face Sketch Using S\({}^{2}\)Sma
#### 3.3.1 Fine-Tuning of Single Pre-Trained Deep Models  
Figure 7 shows the main procedures of fine-tuning a single deep-face model. As indicated, there are three stages, which are feature extraction, feature tuning, and fitness evaluation. In the first stage, all training sketches and the corresponding photos have their features extracted and converted into output vectors. The size of the output vector depends on the model used. In this study, four models were used: FaceNet [21], ArcFace [22], VGG-Face [23], and DeepFace [24]. It is important to note that the output vector size for each deep-face model is different: 128, 512, 2622, and 4096, respectively, as can be seen in Figure 7; note that the feature array has two dimensions, \(M\) and \(N\), where \(M\) represents the number of training images and \(N\) represents the number of features in each image (e.g., if we have 10 training images, then the feature array will contain 20 vectors: 10 pairs of sketches and their corresponding photos).  
Figure 6: Flow chart of the proposed method.  
In the second stage, S\({}^{2}\)SMA will generate a \"features tuning\" vector with random values between 1 and 2. The size of the features tuning vector and the output vector are similar. The output vector and the features tuning vector will be multiplied (element by element), and the result will be saved in the output features array. In other words, there are a lot of features in each image, but there are some features that have a greater impact during the face sketch recognition process for each model. S\({}^{2}\)SMA attempts to discover the effectiveness of all features and their impact on performance during face sketch recognition. Thus, the optimizer has tuned the features based on how much they are affected. It is worth noting that all deep-face models mentioned above are dedicated only to face recognition [25]. As a result, the suggested algorithm tuned the deep-face models to make them suitable for face sketch recognition.  
Figure 7: The illustration shows the suggested technique for face sketch recognition using a single deep-face model. The upper portion represents the training phase, while the lower portion represents the testing phase.  
Finally, based on the features tuned in the previous step, the final step calculates the similarities between each sketch and all photos. This study computes the similarity task using the cosine distance measure, which is defined in Equation (12):  
\[\text{Cos}(\text{S},\text{P})=\frac{\sum_{i=1}^{\text{N}}\text{S}_{i}\text{P}_{i }}{\sqrt{\sum_{i=1}^{\text{N}}\text{S}_{i}^{2}}\sqrt{\sum_{i=1}^{\text{N}}\text {P}_{i}^{2}}} \tag{12}\]  
where Cos is the cosine similarity measure. Variables S and P represent the input feature vector from the input sketched image and the photo, respectively. Subsequently, the fitness is calculated based on separation using Equation (13):  
\[\text{fitness}=-1*(\text{mean\_seperation}) \tag{13}\]  
where mean_seperation denotes the distance between the input sketch and the nearest incorrect photo, as depicted in Figure 8, where S2 SMA aims to maximize this distance. Moreover, every agent will repeat the second and third steps.