Abstract
Facial Expression Recognition (FER) in real-world "in-the-wild" environments remains a significant challenge due to variations in lighting, occlusions, and head postures. This paper presents a robust two-stage framework that integrates the real-time detection capabilities of YOLOv8 with a deep Convolutional Neural Network (CNN) for expression classification. By precisely isolating facial regions before feature extraction, the proposed model achieves a 91.5% accuracy and a 93.1% recall on the RAF-DB dataset, significantly outperforming traditional methods and previous-generation deep learning architectures.
Introduction
While FER has achieved high performance in controlled laboratory settings, its efficacy often degrades in complex, real-world scenes. Factors such as dramatic lighting changes, partial facial occlusions (e.g., masks or hands), and varied head postures introduce noise that traditional manual feature extraction methods, like SIFT or LBP, fail to handle. Even standard deep learning models struggle when they attempt to recognize expressions without precise face localization in cluttered backgrounds. This research addresses these limitations by proposing a high-speed, high-accuracy pipeline suitable for real-time applications in unpredictable environments.
Methodology
The proposed system utilizes a hybrid two-stage pipeline designed to maximize both detection precision and classification accuracy.
Stage 1: Face Detection via YOLOv8
The first stage employs YOLOv8 to isolate the facial region from the background. YOLOv8 is selected for its state-of-the-art object detection capabilities, specifically its use of the Complete IoU (CIoU) loss function. CIoU improves bounding box regression by accounting for overlap area, central point distance, and aspect ratio. Furthermore, the integration of a Feature Pyramid Network (FPN) allows the model to detect faces across multiple scales, ensuring robustness against varying distances from the camera.
Stage 2: Feature Extraction and Classification
Once the face is localized, the region is cropped and normalized. This "cleaned" input is then processed by a deep CNN. The network architecture consists of multiple convolutional layers designed to extract high-level features—such as the specific curvature of the mouth or the furrowing of the brow—followed by pooling layers to reduce dimensionality and mitigate overfitting. Finally, a Softmax layer classifies the features into seven basic emotion categories: Surprise, Fear, Disgust, Happiness, Sadness, Anger, and Neutral.
Experimental Setup and Datasets
The model was trained and validated using the Real-world Affective Faces Database (RAF-DB), which contains 29,670 images captured in diverse real-world conditions. For this study, a subset of 15,339 images was utilized (12,271 for training and 3,068 for testing). The dataset is particularly valuable for its inclusion of diverse ages, genders, races, and complex environmental factors like occlusions.
Results and Discussion
The YOLOv8+CNN hybrid model demonstrated superior performance compared to several baseline models, including EfficientNet, YOLOv5, and traditional SVM+HOG approaches.
| Method | Accuracy (%) | Recall (%) | F1-Score (%) |
|---|---|---|---|
| YOLOv8+CNN (Proposed) | 91.5 | 93.1 | 92.2 |
| EfficientNet | 89.0 | 88.5 | 88.6 |
| YOLOv5 | 86.5 | 85.2 | 85.7 |
| VGG16 | 80.0 | 81.1 | 80.5 |
| SVM+HOG (Traditional) | 74.0 | 72.5 | 73.2 |
A key finding is the model's high recall (93.1%), indicating its effectiveness in identifying expressions even under adverse conditions. However, performance varied across emotion categories. The model performed best on "Happiness" (94.1%) and "Neutral" expressions, while "Fear" (87.8%) proved more challenging due to its lower frequency in the training data (only 2.3% of the dataset).
Conclusion
By decoupling face detection from expression classification, the YOLOv8+CNN framework provides a robust solution for FER in complex scenes. The use of YOLOv8 as a front-end effectively filters out background noise, allowing the subsequent CNN to focus on discriminative facial features. Future work will focus on addressing dataset imbalance and refining the model for lower-latency performance in edge computing environments.
Summary updated