1. Introduction
The capability of human emotion recognition technology has increased because of developments in artificial intelligence (AI), big data, and machine learning. This has assured accurate and effective analysis of human expressions. We use a CNN-based system in our exploration because it draws alleviation from earlier deep literacy studies of emotion recognition, i.e., the operation of Convolutional Neural Networks (CNNs) to enhance accuracy and real-time classification [3]. The disadvantages of traditional machine learning styles have been overcome by deep learning styles, particularly CNNs that have shown amenability to learning complicated facial features for emotion classification tasks [4].
This technology has practical uses in real life, similar to in security, where emotion discovery can be used as a redundant position of authentication, and in advertising, where real-time analysis of feelings assists businesses in understanding the response of guests towards products and announcements [5].
In this study, we introduce a deep learning-based model that employs a convolutional neural network architecture to classify into anger, disgust, fear, happiness, sadness, surprise, and neutrality.
Thus, we aim to improve the accuracy and applicability of automated emotion recognition systems, gives the way for a more intuitive and empathetic human-computer interaction experience [6].
2. Related Work A. Traditional Methods for Emotion Recognition The most traditional method for emotion recognition was the application of manual feature extraction and classical machine learning algorithms. These methods were based on extracting some particular facial features or action units from images and then applying standard classical machine learning algorithms to classify them. Such methods, although foundational, had severe limitations when handling the complexity of human emotions [7].
Feature-Based Methods:
Traditional approaches were primarily based on feature extraction, where specific facial landmarks or characteristics of the face were defined through human interpretation. From there, the features were interpreted to identify emotions [8].
Geometric-Based Feature Extraction:
Geometric-based methods try to identify and measure specific points in the face, including the positions of eyes, eyebrows, the mouth, and the nose. An analysis about distances, angles, or relative positioning can be used to determine expressions; for example, raised eyebrows together with distended eyes might suggest surprise [7].
Appearance-Based Feature Extraction:
The texture-related features were captured instead of the appearance of the specific facial landmark images. These features are related to the analysis of pixel intensities and textures across facial regions. Techniques like Gabor filters, Local Binary Patterns (LBP) [9], and Histogram of Oriented Gradients (HOG) have been widely used to capture the variations in skin texture and outline/area for different expressions. These methods may possibly take more minute skin texture details such as wrinkle, frown lines, or laugh lines, which are emotionbased. B. Traditional Machine Learning Extract geometric or appearance-based features: Classical machine learning algorithms were applied for emotion classification using these features. These are the standard procedures for classification of the expression using the acquired features.
Support Vector Machines (SVM):
SVM was widely applied to affective computing for emotion recognition since they are good classification algorithms, especially in scenarios with limited or small datasets. In emotion recognition, SVM performed well with geometric feature-based systems in which distances and relationships of facial landmarks could be used as input features for classification.
K-Nearest Neighbors (KNN):
KNN is an algorithm in which data points are classified by the majority class among the k-nearest data points. For emotion recognition, KNN would be useful in classifying emotions by comparing extracted features of a new face with previously labeled examples. Simple and interpretable, KNN was limited to large diverse training data as it required a comprehensive database of features for successful classification.
Random Forest and Decision Trees:
The Random Forest is an ensemble of decision trees and has been applied for its ability to handle noise and to be robust. In emotion recognition, it was helpful to discover very complicated relations between facial features and emotions without the need of a linear relation. C. Limitations and Challenges by Traditional Techniques
Handcrafted Feature Extraction:
Traditional approaches relied on handcrafted feature extraction or selection based on expert knowledge to identify salient points or regions on the face. This was time-consuming and sensitive to noise, especially when handling large datasets or varying facial expressions. Manual feature extraction further restricted the capacity for capturing complex or subtle emotional expressions since they depended on predefined kinds of landmarks as well as certain facial features.
Robustness to Environmental Factors:
Traditional methods failed with lighting variability, facial pose, and occlusions such as glasses or hats, which degraded the quality of features extracted. Minor lighting variations could significantly vary appearance-based features, while changes in pose could warp geometric relations between facial landmarks.
Limited Adaptability and Scalability:
Classical algorithms such as SVMs and KNNs were successfully applied on small, controlled datasets but cannot scale up for large, varied datasets. They have not been capable enough to generalize complex datasets with diverse subjects, ethnicities, or age groups [10]. Most importantly, the choice of features was sensitive, and it was not easy to adapt such an algorithm towards subtlety of emotions without considerable amount of personalization. D. Shift of Traditional methods to CNN While good starting points for developing automated emotion recognition, these traditional approaches also had some significant shortcomings when it came to dealing with real-world variability and complexity. The need for laborious hand-extracted features, fragility toward environmental conditions, and lack of adaptability make for a capability that fails miserably in terms of the reliable and accurate classification of emotions in any but the best controlled or dynamically static settings. These limits have given birth to deep learning techniques, like Convolutional Neural Networks (CNNs), which can automatically learn features from the data and adapt to the variety of conditions in order to make a fantastic splash in emotion recognition. 3. Methodology and Proposed Work This project deals with designing a real-time emotion recognition system using CNN [11]. It analyzes images & live feeds with face expressions. Below, we have described the dataset, preprocessing steps, CNN architecture, model training, and the real-time detection pipeline [12].
A. Dataset Source
We used an existing dataset of facial expression, which is publicly accessible, or any other dataset that had labeled pictures of various expressions through a human face. These pictures were classified based on emotions, including the state of happiness, sadness, anger, surprise, and neutrality. We then analyzed various datasets amongst which the FER2013 was most reliable dataset [13]. Classes of Emotion: The provided dataset has seven key emotions: Happy, Sad, Angry, Surprise, Disgust, Fear, and Neutral for the classification and analysis of facial expressions. Dataset Splitting: All the data was divided into a training set at 70%, and then 15% each for validation and test set that will actually be used for training and tuning and evaluation of the performance of various models [14].
B. Preprocessing
Image Standardization: The detected face is cropped using background subtraction method where the foreground image is subtracted from the background image and the facial part is cropped effectively and the image is rescaled for 48 x 48 pixels [7,15]. The input of all these images is also in grayscale because the color0020information of those images is not at all necessary for emotion detection, and with the grayscale input; it would make the input and reduce computational loads on the processor. Normalization: The pixel values were normalized to the range [0,1] using 255. It further accelerates the convergence of the model as inputs end up being uniformly distributed [16]. Data Augmentation: We have improved the size of our dataset and better the generalization of our model by using horizontal flipping, slight rotations, and brightness adjustments. This kind of augmentation would enable the network to learn robust features for simulating in real-life scenarios.
C. Feature Extraction using CNN
Automatic Feature Learning: The system automatically learns to identify edges, corners, and textures-all the features that would be necessary for distinguishing various emotions from facial images using a CNN model [17]. Therefore, the architecture of the CNN model is suited for emotion classification from facial images, as it may capture the spatial hierarchies. Face Detection: In our real-time implementation, we used OpenCV's Haar Cascade Classifier, and we cropped the faces from live video frames before they went into the CNN model. This ensured that the network was interested only in the region concerned with a face, thus increasing the accuracy and efficiency of the prediction.
D. Model Architecture
Convolutional Neural Network Design:
The CNN architecture utilizes different layers of convolution and max pooling followed by a ReLU activation function in order to introduce non-linearity and enhance feature extraction [18]. Convolutional Layers: The three layers of convolutions in the CNN model are using filter sizes progressively increased for capturing complex patterns, like 32, 64, and 128[19]. Pooling Layers: A max pooling is applied after the activation function following each convolutional layer. It will reduce spatial dimensions, which help in making a model less computationally complex and less prone to overfitting. Flatten and Dense Layers: The flattened output from the final pooling layer is then passed through the dense layers. These layers merge features, which eventually come into play for classification. Output Layer: SoftMax activation in the output layer is used, giving the probabilities to each one of the seven emotion classes, meaning that the model will classify each input image into one of its emotion classes.
E. Training and Evaluation
Training Configuration:
Optimizer: Used is the Adam optimizer. This has adaptive learning rates that help improve convergence speed. Loss Function: The categorical cross-entropy loss function was chosen because it applies best for multi-class classification problems [7,9,20]. Training Parameters: The model is trained for 30 epochs while maintaining a batch size of 32, along with tracking the validation loss to avoid overfitting. Evaluation Metrics: The effectiveness of the model is monitored using accuracy, precision, recall, and F1-score; these helps to determine each emotion that the model has identified correctly. This is derived from the testing set so that the model has a good view of unseen data.
F. Real-Time Emotion Detection Pipeline
Face Detection in Video Feed: It uses a live webcam feed where faces are being detected through Haar cascades. Their presence is located and cropped for each frame with pre-processes tailored towards the requested input format the CNN model requires [21].
Emotion Prediction and Display:
For each face, he resizes to 48x48 pixels, converts to grayscale, and feeds into the CNN model. Each face will be associated with a prediction emotion, and the result will be rendered in real-time with an accompanying bounding box and its predicted emotion label above the person's face. Optimized for low latency, this system ensures live video frames are processed in real-time with accurate emotion detection in changing environments.
Figure 2. Flow Chart Figure 3. Labelled Dataset of various image In our research, we observed that the emotion images in the FER 2013 dataset were not proportionally balanced across all sevenemotion categories [7]. To enhance the model's learning capability and performance, we adjusted the dataset to ensure a more balanced distribution of emotions. After training our CNN model on this refined dataset, we achieved following results:
CNN:
Figure 4, illustrates the training and validation accuracy (left) and loss (right) for the CNN model. The accuracy curve shows how the model improves over time, with the validation accuracy stabilizing, indicating reduced overfitting. The loss graph demonstrates a decreasing trend, suggesting that the CNN is learning effectively.
Figure 5 (CNN Performance Metrics Table) presents the precision, recall, and F1-score for different emotions classified by the CNN model. The high values across all metrics indicate that CNN performs well in recognizing emotions [7], with particularly strong performance in detecting "disgust" (F1-score = 1.00) and "surprise" (F1-score = 0.98). Figure 6, confusion matrix visualizes the performance of the CNN model in predicting different emotions. Each row represents the actual emotion, while each column represents the predicted emotion. The diagonal values show correct predictions, with higher values indicating better classification accuracy.
RNN:
Resnet50:
VGG-16:
CNN: RNN:
Resnet50: VGG-16:
Figure 26. VGG-16 New Testing Accuracy After 7 epochs of testing, the first model, VGG-16, had a 54% accuracy rate, whereas the second model had a 69% accuracy rate after about 40 epochs [7,26]. The CNN model achieved a 74% accuracy on the FER2013 dataset [7,26], outperforming VGG-16, which reached only 55.6% accuracy on the same dataset [7]. These results highlight the superior performance of custom CNN architectures over pre-trained models like VGG-16 for emotion recognition tasks.
4. Conclusion
References
- M. F. Ali, M. Khatun, and N. A. Turzo, "Facial emotion detection using neural network," Int. J. Sci. Eng. Res., vol. 11, no. 8, pp. 1485–1491, Aug. 2020.