## 4 Implementation
### VGG Architectures  
The task of FER was based on fine-tuned transfer learning from pre-trained VGG16 and VGG19 architectures. The VGG architecture, developed by [PERSON] and [PERSON], achieved significant success as the runner-up in the ImageNet Large Scale Visual Recognition Competition (ILSVRC) in 2014. This architecture was chosen for several reasons: (i) demonstrable success on a variety of image classification tasks, (ii) native support provided by Keras, 5 which offers pre-trained models with publicly available weights, and (iii) a simpler implementation.  
However, more complex models such as ResNet50 or DenseNet121 might face the problem of overfitting issues given a smaller dataset size. We employed VGG16 and VGG19, pre-trained on the ImageNet dataset, for classification purposes. In our approach, we unfroze the last four layers of VGG16 and the last five layers of VGG19, while freezing the remaining layers. This strategy allowed us to update the pre-trained ImageNet [78] weights with the weights learned from our specific datasets, enhancing the model's ability to learn more effectively.  
Following the basic VGG architecture, we added a global average pooling layer, a dropout layer, a dense layer with ReLU activation, another dropout layer, and, finally, a dense layer with softmax activation to classify the emotions. The proposed VGG16 and VGG19 model architectures are detailed in Tables 2 and 3, respectively.  
For comparison purposes, our experiment was structured in three distinct setups. Firstly, we maintained all layers of the base VGG19 and VGG16 models frozen, without applying any histogram equalization. Secondly, we fine-tuned the VGG19 and VGG16 architectures by unfreezing the last four layers of VGG16 and the last five layers of VGG19, while keeping the remaining layers frozen. This setup also did not include any histogram equalization. Lastly, we incorporated histogram equalization into the final experimental setup, along with fine-tuning the models as described in the second setup. For the KDEF dataset, our initial step involved optimizing the data for histogram equalization by converting the images to grayscale. Subsequently, to obtain the RGB format suitable for a  
\begin{table}
\begin{tabular}{c c c c} \hline \hline
**Layer (Type)** & **Output Shape** & **Trainable Parameters** & **Non-Trainable Parameters** \\ \hline \hline \multicolumn{3}{c}{**VGG16 Base Model \({}^{*}\)**} & 7,635,264 & 7,079,424 \\ Global AveragePooling 2D & (None, 512) & 0 & 0 \\ Dropout & (None, 512) & 0 & 0 \\ (Dense + ReLU) & (None, 1024) & 525,312 & 0 \\ Dropout & (None, 1024) & 0 & 0 \\ (Dense + Softmax) & (None, 7) & 7175 & 0 \\ \hline \hline \multicolumn{3}{c}{**Trainable Parameters**} & 7,611,911 & 0 \\
**Non-trainable Parameters** & & 0 & 7,635,264 \\ \hline \hline \multicolumn{3}{c}{**Total Parameters**} & 15,247,175 \\ \hline \hline \end{tabular}  
\({}^{*}\)The layers of the VGG16 model, excluding the last four, were frozen.  
\end{table}
Table 2: The proposed modified VGG16.  
pre-trained VGG network, we further transformed the grayscale images into RGB format. During this process, each pixel in the grayscale image replicated its intensity value across all three color channels. A general overview of our framework can be found in Figure 1.