This study involved secondary analysis and re-annotation of facial images and video frames obtained exclusively from the pre-existing AffectNet and DAiSEE datasets. No new data were collected from human participants, and the study did not involve direct interaction with or recruitment of human participants. The data used for model development and evaluation did not include personally identifying information beyond the labels provided with the source datasets. Under the institutional policy of Vignan’s Institute of Information Technology (A), Visakhapatnam, this secondary analysis of pre-existing data did not require institutional ethical review; therefore, no ethics approval was sought for the present study. Details of the datasets, software, pretrained model weights, computing hardware, and other research resources used in this study are provided in the Table of Materials.
Dataset building
Obtaining authentic instructional video data is very difficult due to the logistics involved (i.e. obtaining proper display conditions, ethics approval, and considerable time needed for annotations). To make an annotated dataset of large scale, we used photos and video frames provided in two publicly available datasets on Kaggle, AffectNet and DAiSEE. AffectNet3 has more than 1 million photographs of faces labeled across 8 emotion classifications and with continuous valence/arousal scores, and DAiSEE22 is a video dataset with labeled video from virtual learning experiences of students labeled as engaged, bored, confused, or frustrated. We extracted still frames from the videos in the DAiSEE collection to create a more comprehensive and ecologically valid training dataset to improve the learning models we intend to use.
A key insight has been that the facial expressions associated with the emotions of disgust, surprise, and sadness looks very similar to the facial expressions exhibited by the students when they are exhibiting cognitive confusion/difficulty, disinterest, and distraction. Based on literature in educational psychology1,2,4,13, we developed our relabeling techniques and created 4 engagement categories based on the facial muscle movement patterns that make up the various facial expressions associated with each category of emotion.
Attentive
For this category, we used images labeled as neutral or satisfied in AffectNet; as well as calm forward-facing frames in DAiSEE, showing active attention and processing of information (evidenced by looking forward with widened eyes and relaxed facial muscle tone).
Confused
For this category, we used photos labeled as surprise and/or disgust in AffectNet, as well as confusion labeled frames in DAiSEE. Confused facial expressions typically has frowning eyebrows, a little tension on one side of mouth, and eye movement patterns.
Disengaged
For this category, we used photos labeled as sadness and/or sleepy in AffectNet, and from the boredom/disengaged frames in DAiSEE. Typical disengaged facial expressions are characterized by eyelids drooping and/or jaws relaxed with very little muscle tone, and the label for a disengaged facial expression was additionally supported by determining EAR thresholds18.
Distracted
This category relied on facial expressions labeled as low arousal and/or contempt in AffectNet, and from the distracted frames in DAiSEE in which the student was gazing away from the learning activity. Typical distracted facial expressions show little movement in the facial muscles.
Relabeling protocol
The relabeling was completed by two research assistants trained in educational psychology, following a structured protocol. Each image or extracted video frame was independently assigned to one of our four engagement labels according to the fixed mapping given in Table 1. Disagreements (less than 3% of the images) were adjudicated by a third author who assigned a consensus label to the images or excluded the image from the dataset. Only images with full agreement among the annotators were retained. Inter-rater reliability was measured across a random selection of 500 images, yielding a Cohen’s κ = 0.87, demonstrating high reliability. The original source label to engagement category mapping can be found in Table 1.
Note: Images where source labels mapped ambiguously across two engagement categories were reviewed by the third expert and either assigned a consensus class or excluded (< 3% of source images).
| Engagement Class | AffectNet Emotions | DAiSEE Labels | Visual Cues |
| Attentive | Neutral, Happy/Satisfied | Engaged | Open eyes, relaxed face |
| Confused | Surprise, Disgust | Confused | Furrowed brow, tense mouth |
| Disengaged | Sadness, Sleepy | Bored/Frustrated | Droopy eyelids, slack jaw |
| Distracted | Contempt, Low arousal | Disengaged | Averted gaze, flat affect |
Table 1: Fixed label mapping from source datasets to engagement categories.
All images were resized to 224 × 224 pixels and normalized using ImageNet mean and standard deviation values. A data augmentation strategy was applied during training including horizontal flipping, rotation within ± 15°, brightness/contrast jitter (± 20% / ± 15%), and random crop with resizing. These transformations simulate variation in lighting, head angle, and partial occlusion as encountered in real classrooms. A total of 3,600 images were used in the dataset (88.9% training, 11.1% testing), as described in Table 2.
The precise RGB normalization parameters that were utilized are mean = [0.485, 0.456, 0.406] and standard deviation = [0.229, 0.224, 0.225], the commonly used constants for normalization in ImageNet, which were performed on pixel intensity values normalized to [0, 1] after the resizing operation of the input of size 224 × 224.
| Engagement State | Training Samples | Testing Samples | Total | Source |
| Attentive | 760 | 95 | 855 | AffectNet + DAiSEE |
| Confused | 688 | 86 | 774 | AffectNet + DAiSEE |
| Disengaged | 832 | 104 | 936 | AffectNet + DAiSEE |
| Distracted | 920 | 115 | 1035 | AffectNet + DAiSEE |
| Total | 3200 | 400 | 3600 | |
Table 2: Dataset split for engagement classification experiments. Per-class image counts for the training and test partitions, the class totals, and the source dataset for each class.
The statement regarding the right partition is that this is an 88.9% and 11.1% separated dataset made up of 3600 images – out of these, 3200 images form the training set and 400 images form the test set; the images belong to four different classes based on socio-emotional engagement such that the ratio is maintained properly among the various classes.
The original and re-stamped images came from two different datasets: AffectNet (static facial expression images) and DAiSEE (video frames labeled at 1 fps). The Source column in Table 2 indicates which of the two datasets contributed the images for each engagement class.
Overview of system architecture
Facial landmark detection framework is an open-source computer vision framework that provides a connection between live video streams and real-time facial landmark detection. An overview of the system architecture is shown in Figure 1: (Figure 1A) the complete system architecture, (Figure 1B) the ResNet-50 architecture, and (Figure 1C) the end-to-end Engagement Insights pipeline. Fusion of Deep Learning Branch and Heuristic EAR/MAR Branch occurs at Decision Fusion Module as shown below.

Figure 1: Engagement insights system architecture. (A) Complete system architecture. (B) ResNet-50 model with the modified four-class engagement head. (C) End-to-end pipeline in which the deep learning branch and the heuristic EAR/MAR branch are combined at the decision fusion module. Please click here to view a larger version of this figure.
The engagement tracking system gives us an entire view of the process of counting a student's level of engagement based upon the student's features through facial expression (i.e., determining how serious a student is). This engagement tracking activity starts with video from a live camera, where the facial landmark detection framework program receives the video, and with the first part of transforming each face seen in the video into a face mesh with 468 points (landmarks). Subsequent to mesh creation, the two output branches are created: (1) the deep learning branch provides the predicted class through a ResNet-based classifier, which outputs a predicted class from the softmax output of four classes; and (2) the heuristic branch uses the 468 facial landmark detection framework to determine the opening of the eyes (EAR) and mouth (MAR). The output from both branches will then be combined to generate a single engagement label. Finally, the final output (bounding box, predicted class and confidence score) will be displayed in real time as an overlay on each video frame being viewed as shown in Figure 1A.
ResNet-50 model architecture
The final choice for using a deep learning model was ResNet23 because of the depth to efficiency ratio that is created through the use of residual skip connections. Furthermore, we evaluated two different types of ResNet architecture: ResNet-18 (11.2 M parameters) and ResNet-50 (23.5 M parameters). Both models were initially started from pre-trained weights on ImageNet rather than being trained from the ground up, which was very advantageous since our dataset is quite small compared to traditional datasets used to train CNNs.
ResNet-18/ResNet-50 were chosen due to their superior trade-off of accuracy and latency when implemented on CPU-based hardware and their available ImageNet pre-trained models, which are a good fit for our small-sized dataset (3600 images). We did not run any measurements on more recent models (like ViT, based on Mamba or any other lighter vision architecture), nor did we compare parameters, FLOPs, or latency against them.
We removed the original 1000-class ImageNet head and replaced it with a four-class engagement head that uses the following features: (i) global average pooling over the last convolution feature map producing either a 512-d vector for ResNet-18 or a 2048-d vector for ResNet-50; (ii) a Dropout layer (p = 0.2) before the last linear layer; and finally (iii) a fully connected layer with four output neurons, activated using Softmax. Each of these four output neurons corresponds to one of the four classes of engagement: Attentive, Confused, Disengaged and Distracted. An overall diagram of the ResNet-50 architecture with the modified head is shown in Figure 1B.
The cross-entropy loss function used for training is:
L = −(1/N) × Σi Σj yij × log(ŷij) (1)
where yi is the ground truth one-hot label and ŷi is the predicted probability for sample i and class j. All models used Adam29 with a learning rate of 0.001 and standard momentum parameters (β1 = 0.9, β2 = 0.999), trained for up to 50 epochs in batches of 32. A StepLR scheduler decayed the learning rate by 0.1 every 10 epochs.
Heuristic geometric cue module
We created a geometric module to detect physical signs of disengagement such as closed eyes and yawning. This geometric module uses facial landmark detection framework24 to extract 468 3D facial landmarks from each frame in real-time.
It calculates two metrics:
Eye Aspect Ratio (EAR)
Quantifies the degree of eye openness from the ratio of vertical to horizontal eye distances. For a given eye with landmarks p₂ through p₆.
EAR = (‖p₂−p₆‖ + ‖p₃−p₅‖) / (2 × ‖p₁−p₄‖) (2)
For each frame the mean EAR was calculated across both eyes. If it went below 0.25 (the drowsiness threshold established in prior blink-detection work18), the student was flagged as disengaged.
Mouth Aspect Ratio (MAR)
Quantifies mouth opening to detect yawning behavior.
MAR = (‖m₂−m₈‖ + ‖m₃−m₇‖ + ‖m₄−m₆‖) / (2 × ‖m₁−m₅‖) (3)
To find the mean aspect ratio (MAR), we use the coordinates of the landmarks at the outer lip (m₁ - m₈). If the value of the MAR is greater than 0.6, then the subject is flagged as disengaged due to yawning19, regardless of the prediction made by the deep model. Eye aspect ratio (EAR) and MAR landmark coordinates (as defined by facial landmark detection framework 468) are mapped as follows, for EAR, the left and right eye indices are mapped using the typical six-point eye contour definition, while for MAR, the outer lip contour indices are used. No influence from head pose (yaw angle) is included in the current implementation.
For the sake of complete reproducibility, the exact facial landmark detection framework (468 points) indices utilized in this study can be seen in Figure 1C. In terms of EAR, for each eye, there are six points (p1 - p6) defined in Eq. 2 the left eye corresponds to the following indices [362 (p1, outer corner), 385 (p2), 387 (p3), 263 (p4, inner corner), 373 (p5), 380 (p6)] and the indexes for the right eye are [33 (p1, outer corner), 160 (p2), 158 (p3), 133 (p4, inner corner), 153 (p5), 144 (p6)]. It is important to note that EAR is computed independently for each eye, and their values are averaged over each frame. In the case of MAR, the eight outer-lip points appearing in Eq. 3 can be defined as follows m1 = 61 (left mouth corner), m5 = 291 (right mouth corner), (m2, m8) = (39, 181), (m3, m7) = (0, 17), (m4, m6) = (269, 405). All these indices follow the standard facial landmark detection framework outer-eye-contour and outer-lip-contour indices that were employed in previously developed EAR/MAR methods.
Decision fusion and real-time processing
If the EAR threshold or MAR threshold has been met, the final output will be Disengaged, which is a complete override of any overall considerations of the deep learning model (e.g., ResNet, etc.)18. The geometric signal contains the most accurate information for the Disengagement event and will be considered as the final authority on the validity of the serious disengagement cues, when neither threshold fires, the ResNet will provide the label based on the softmax argmax of the four classes.
All frames go through the identical process in the following order
- Face detection and extraction of 468 facial landmarks using facial landmark detection framework,
- Cropping the face and resizing/normalizing it to 224 × 224 pixels in size
- Generating a four-class softmax output using ResNet
- Calculating the EAR and MAR in parallel
- Using the fusion rule to determine the final label
- Annotating and drawing a bounding box around the result received from fusion.
Overall, the system processes frames in 33 ms on average (~30 FPS) on a standard CPU with no GPU.
The training utilized programming language 3.11, deep-learning framework 2.x, and an GPU (8 GB + VRAM) with 16 GB of RAM. Inference does not need to be performed with a GPU the released implementation runs at 30 frames per second (FPS) on a normal CPU. The reported inference timings were all measured with a batch size of one on the following test machine CPU, 16 GB RAM, operating system (OS) 11, programming language 3.11, deep-learning framework 2.x, and facial landmark detection framework. The mean and standard deviation of the inference times were calculated over 10 runs of 60 s each, as reported in the Results. A breakdown of the time spent on CNN inference and in the geometric module is given in the Results. The configuration of hyper parameters presented in Table 3 was kept constant for all of the reported results. No 20% validation split was created due to the relatively small size of the dataset (3,600 images); rather, the learning rate and the dropout rate were set to values commonly reported in the FER literature rather than being cross-validated on held-out data, and the stability of the model was verified through five repeated runs.
Summary of the experiment set up
Data partition used is a stratified split of 88.9% / 11.1%. (3200 images for training and 400 images for testing). The model was trained on both ResNet-18 and the ResNet-50 architecture, in each case with ImageNet pre-training and Dropout. Also, Adam optimizer with a learning rate of 0.001 has been used along with the batch size of 32. A maximum of 50 epochs are allowed for training and StepLR decay of 0.1 is used after 10 epochs. Configuration of the hardware to be used is GPU with a minimum of 8GB VRAM and 16 GB RAM. Benchmarking for inferencing is done on a CPU with OS 11.
The process of inference consists of the following steps:
- Facial landmark detection framework extraction
- ResNet softmax classification
- Multiple EAR/MAR computations executed in parallel
- The decision is taken by fusion of results
Evaluation process includes 5 training runs and testing performed on 400 images test data along with macro and weighted F1, AUC values.
The relevant configurations, parameters, hardware, and operating conditions for both training and inference procedure training are summarized in Table 3. Data for inference time were collected with some fixed operating conditions (batch size = 1, CPU-only machine, and the average time for conducting 10 runs 60 sec-long), while the related operating conditions for using the models in the course of training (GPU, count of epochs, batch size, settings of an optimizer) are provided in the table.
The following additional settings that were not outlined above are given in order to provide complete information. To make use of either ResNet-18 or ResNet-50, the two backbones were both initialized with the help of standard ImageNet-trained checkpoints available from the torchvision library only, making random initialization for only their brand-new four-class classification head (Kaiming uniform initialization was employed in the current case). Each of the five repetitions took place with regard to individual seeding of weight initialization and shuffling position of data-loaders in order to make sure that the achieved accuracy was showing variations across initializations rather than representing one run outcome only. Early stopping was not used as well; each of the constructed models was trained for as many epochs as necessary to finish the training process, meaning that the last checkpoint will be used in evaluation as there is no validation dataset that would use the best validation dataset loss only.
| Hyperparameter | Value |
| Framework | PyTorch 2.x / Python 3.11 |
| Architecture variants | ResNet-18 (11.2M params), ResNet-50 (23.5M params) |
| Input image size | 224 x 224 x 3 (RGB) |
| Pretrained weights | ImageNet (torchvision) |
| Batch size | 32 |
| Optimizer | Adam (β1=0.9, β2=0.999) |
| Initial learning rate | 0.001 |
| LR decay schedule | StepLR (step=10, γ=0.1) |
| Training epochs | 50 |
| Dropout rate | p = 0.2 (pre-FC layer) |
| Loss function | Cross-Entropy |
| Data augmentation | Flip, Rotation ±15°, Color Jitter, Random Crop |
| EAR threshold (τ_EAR) | 0.25 |
| MAR threshold (τ_MAR) | 0.6 |
| Real-time libraries | OpenCV 4.x, MediaPipe 0.10 |
| Train/test split | 88.9%/11.1% stratified hold-out (single split) |
| Inference hardware (test) | Intel Core i7-10750H, 16 GB RAM, Windows 11 |
Table 3: Hyperparameter configuration. Learning rate, batch size, number of epochs, optimizer, and scheduler settings used for all reported results.