A driver expression recognition method based on a lightweight model
By designing a StarGAN v2 augmented dataset and a lightweight driver expression recognition model, the robustness and accuracy issues of driver expression recognition models under limited resources and real-world driving scenarios were addressed, achieving accurate recognition even in occluded and pose-changing environments.
Patent Information
- Application Number
- CN202410076162.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-18
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2044-01-18
AI Technical Summary
Existing driver facial expression recognition models are difficult to deploy in resource-constrained cockpit environments and have low robustness in real-world driving scenarios. Facial occlusion and pose changes have a significant impact, and the scarcity of datasets leads to insufficient recognition accuracy.
We expanded the driver facial expression dataset using StarGAN v2 to build a lightweight driver expression recognition model. Using EfficientNet_b0 as the base, we combined a hybrid multi-scale feature extraction module and a feature fusion module, and improved the center loss function to enhance the model's robustness and recognition performance.
The model achieves accurate recognition of driver facial expressions in real-world environments with occlusion and changing postures. It is lightweight and has good recognition performance, enabling real-time recognition in resource-constrained scenarios and improving the model's generalization ability and robustness.
Smart Images

Figure CN118072292B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of computer vision technology, and relates to human facial expression recognition, and in particular to a driver facial expression recognition method based on a lightweight model. Background Technology
[0002] Research has found that drivers' emotional states, such as anger or excessive excitement, are key factors contributing to traffic accidents. Therefore, the ability to quickly and effectively identify emotions that may affect safe driving and help drivers maintain emotional stability is an important measure to improve road safety.
[0003] Driver emotion detection can be divided into invasive and non-invasive methods. Invasive emotion detection usually requires direct contact between the individual and the detection device, which may distract the driver and affect driving safety. Therefore, non-invasive methods, such as facial expression recognition using cameras, are more preferable in this cockpit environment. The main steps are: first, to capture images of the driver's facial expressions during driving using a camera installed in the vehicle; then, to input these images into a recognition model for identification; and finally, to take appropriate measures based on the recognition results. The most crucial step is the model recognition process. In recent years, with the rise of deep learning, its use in facial expression recognition has become mainstream. However, current facial expression recognition models generally have a large number of parameters, which is not conducive to deployment in resource-constrained cockpit environments. The scarcity of driver facial expression datasets is also a significant challenge. Furthermore, although significant progress has been made in facial expression recognition technology in laboratory environments, the unique challenges of real-world driving scenarios, such as facial occlusion due to hats or sunglasses, and changes in posture, place certain demands on the robustness of the model. Simultaneously, the intra-class differences and inter-class similarities of facial expressions also require a certain level of recognition capability from the model. Therefore, solving these problems is of great significance for improving the accuracy and practicality of driver facial expression recognition. Summary of the Invention
[0004] In order to overcome the shortcomings of the prior art, the present invention aims to provide a driver facial expression recognition method based on a lightweight model. The first objective is to solve the problem of the scarcity of driver facial expression datasets, and the second objective is to solve the problem of low robustness of the recognition model in actual driving situations, thereby achieving lightweight recognition model and better recognition performance.
[0005] This invention utilizes StarGAN v2 to expand the driver facial expression dataset. This method effectively alleviates the current problem of scarce driver facial expression datasets. The designed driver expression recognition model features a small number of parameters and low computational resource requirements. Furthermore, the model exhibits good robustness to occlusion and pose changes that may occur in real-world driving environments. The improved center loss not only narrows the distance between similar expressions but also widens the distance between different expression classes, further enhancing the model's discriminative ability. Therefore, the method proposed in this invention alleviates the problem of scarce datasets while simultaneously achieving lightweight model design and good recognition performance.
[0006] To achieve the above objectives, the technical solution adopted by the present invention is as follows: A first aspect of the present invention provides a driver facial expression recognition method based on a lightweight model, comprising the following steps: Step 1: Prepare the driver facial expression dataset and preprocess the images in the driver facial expression dataset; Step 2: Use StarGAN v2 to generate driver facial expression images and perform offline augmentation to increase the number of samples in the driver facial expression dataset; Step 3: Construct a lightweight driver facial expression recognition model. The model includes a basic feature extraction module, a hybrid multi-scale feature extraction module, and a feature fusion module. Input the driver's facial expression image into the model for feature extraction. Step 4: Train the lightweight driver expression recognition model and use the trained model to recognize driver expressions.
[0007] A second aspect of the present invention provides a driver facial expression recognition device based on a lightweight model, comprising: The data acquisition unit is located in the driver's cab and acquires real-time video of the driver's face and segments it into images frame by frame, or periodically acquires facial images of the driver. The facial expression recognition unit loads a lightweight driver facial expression recognition model trained by the driver facial expression recognition method based on the lightweight model; the facial expression recognition unit communicates with the data acquisition unit, preprocesses the obtained image, and then uses the trained lightweight driver facial expression recognition model to recognize the driver's facial expression in the image.
[0008] A third aspect of the present invention provides a safe driving assistance device, including a main control unit and an alarm unit; The main control unit is connected to the expression recognition unit of the driver expression recognition device based on the lightweight model, and receives the driver's facial expression results recognized by the expression recognition unit; The main control unit is connected to the alarm unit, the vehicle braking unit, and the vehicle acceleration unit. Based on different identification results, it sends an alarm signal to the alarm unit, a braking signal to the vehicle braking unit, and an acceleration restriction signal to the vehicle acceleration unit.
[0009] Compared with the prior art, the beneficial effects of the present invention are: (1) At present, there is a lack of facial expression datasets for drivers. The common method is to augment the data. Unlike traditional methods such as horizontal flipping, random cropping, and translation, this invention uses StarGAN v2 to generate diverse and realistic facial expression images. It can also create facial expression images with different styles. Compared with the original StarGAN, StarGAN v2 replaces the domain labels with style encoding of specific domains. At the same time, it introduces a mapping network and a style encoder, and the generated images are more realistic.
[0010] (2) The hybrid multi-scale feature extraction module of the present invention can extract features with different receptive fields, thereby increasing the diversity and robustness of global features, enhancing key feature information, and effectively alleviating the problems of occlusion and pose change. In the feature fusion module, the intermediate layer features capture the intermediate abstract information of the image, such as certain regional features of the face (eyes, mouth, etc.). These features contain key information for distinguishing different facial expression details. The deep features can capture higher-level semantic information, that is, the global concept of the entire facial expression. Combining these two models can simultaneously utilize local details and global context to more accurately identify expressions.
[0011] (3) The driver expression recognition model of the present invention is based on the lightweight model EfficientNet_b0. The hybrid multi-scale feature extraction module and feature fusion module both use depthwise separable convolution, which has the characteristics of few parameters and can achieve real-time recognition in scenarios with limited deployment resources.
[0012] (4) The improved center loss function of this invention can reduce the distance between similar expressions while expanding the distance between different classes. Combined with cross-entropy loss for joint supervision, it improves the model’s discrimination ability. Attached Figure Description
[0013] Figure 1 This is a flowchart of the present invention.
[0014] Figure 2 Sample images for augmenting the driver facial expression dataset using StarGAN v2.
[0015] Figure 3 This is a diagram showing the overall structure of a lightweight driver facial expression recognition model.
[0016] Figure 4This is a diagram of the MBconv structure.
[0017] Figure 5 This is a structural diagram of the hybrid multi-scale feature extraction module.
[0018] Figure 6 This is a structural diagram of the feature fusion module. Detailed Implementation
[0019] The embodiments of the present invention will now be described in detail with reference to the accompanying drawings and examples.
[0020] This invention presents a driver facial expression recognition method based on a lightweight model. This method features a small number of parameters and low computational resource requirements, and can accurately recognize driver facial expressions in real-world environments with occlusion or changing postures. Furthermore, it utilizes StarGAN v2 to expand the driver facial expression dataset, enhancing the model's generalization ability. This invention achieves both lightweight model design and good recognition performance. Figure 1 This is a flowchart of the present invention. The specific implementation steps of this embodiment are as follows; Step 1: Prepare the driver facial expression dataset and perform preprocessing operations on the images in the driver facial expression dataset.
[0021] Currently, driver facial expression datasets are relatively scarce, with the KMU-FED dataset being the most commonly used. For the KMU-FED driver facial expression dataset, the dataset is first divided. The KMU-FED dataset contains 1106 driver facial expression images, which can be categorized into six expressions based on their labels: anger, disgust, fear, happiness, sadness, and surprise. To train and evaluate model performance, the dataset is divided into training and testing sets in an 8:2 ratio, as used in this embodiment. Since some images in this dataset have uneven brightness, this embodiment uses adaptive histogram equalization to enhance image contrast and make the images clearer. Furthermore, some images have background interference, and some face images are not aligned. This embodiment uses Retinaface for face detection and alignment to center the faces in the image. Finally, the images are cropped to the same resolution, which is 224 in this embodiment. With a fixed resolution of 224 pixels, Retinaface performs the following steps on the image to be inspected: 1.1 First, the basic feature information of the face is extracted using the Mobilenet 0.25 lightweight backbone model.
[0022] 1.2, then Feature Pyramid Network (FPN) and Single Stage Headless (SSH) are used to further enhance feature extraction. The Feature Pyramid Network processes the feature layers output by the backbone network through 1... The 1-channel convolution adjusts the number of channels and uses upsampling and feature fusion operations to enhance feature extraction; SSH uses three parallel convolutions: the first is 3... 3. Ordinary convolution; the second uses 3 twice. 3 ordinary convolutions instead of 5 The first is a regular convolution with 5, the second is a convolution with 3 times. 3 ordinary convolutions instead of 5 5 is a regular convolution.
[0023] 1.3 Next, ClassHead, BoxHead, and LandmarkHead networks are used to obtain prediction results from features. ClassHead extracts whether the prior bounding box contains a face, BoxHead detects the prior location, and LandmarkHead detects the location of facial landmarks. These three networks are composed of fully connected layers or ordinary convolutions.
[0024] 1.4 Finally, the prediction results are decoded and duplicate detection values are removed using NMS (non-maximum suppression) to obtain the final result.
[0025] By using Retinaface to preprocess the driver facial expression dataset, we obtained face images that have undergone face detection, alignment, and cropping. These driver expression images have had background and irrelevant information removed, while retaining the driver's facial features, which is helpful for subsequent expression recognition tasks.
[0026] Step 2: Use StarGAN v2 to generate driver facial expression images and perform offline augmentation to increase the number of samples in the driver facial expression dataset.
[0027] This step inputs the preprocessed driver facial expression image from step 1 into StarGAN v2 for offline augmentation to increase the number of samples. StarGAN v2 mainly includes a generator (G), a mapping network (F), a style encoder (E), and a discriminator (D). The present invention describes using StarGAN v2 to generate driver facial expression images and perform offline augmentation to increase the number of samples in the driver facial expression dataset, specifically including: The generator G receives source facial expression images and target facial expression style codes, and generates new facial expression images that match the target domain. The discriminator D determines whether the input image is a real facial expression image from the training samples or a facial expression image generated by the generator G, and determines the domain to which the input image belongs, which helps the generator generate more realistic facial expression images. The mapping network F maps random noise vectors to style codes in the latent space, and these style codes are then used to guide the generator G in domain transformation. The style encoder E extracts style codes from real facial expression images, which allows the StarGAN v2 model to capture the style of a specific image and apply this style to the image generation process in another domain.
[0028] This invention trains the StarGAN v2 model based on a preprocessed dataset of driver facial expressions. The preprocessed dataset is input into the StarGAN v2 model. During training, adversarial loss, style reconstruction loss, cycle consistency loss, and diversity loss are used to supervise the training of StarGAN v2. The adversarial loss trains the generator G to generate realistic images while simultaneously training the discriminator D to distinguish between real and generated images. The style reconstruction loss ensures that the generator G applies the style encoding of the target domain to the generated images. The cycle consistency loss ensures that the source image is transformed to the target domain and then back to the original domain while maintaining the consistency of image content. The diversity loss encourages StarGAN v2 to generate stylistically different images given the same source image but different random noise or style encoding. These loss functions work together during the training of StarGAN v2, each optimizing different aspects of the network. The training is iterated multiple times, resulting in the generated driver facial expression images. In this embodiment, 100,000 iterations are used.
[0029] The specific training steps for StarGAN v2 can be described as follows: Step 2.1: Given an original facial expression image and its corresponding expression category, input it into the StarGAN v2 generative model. During training, randomly sample a random noise vector. z ∈ Z and a target domain y ∈ Y Target style codes are generated through the mapping network F. Generator G will generate facial expression images x and target style encoding As input, and learned through an adversarial loss function, an output facial expression image G( is generated). x , The formula is as follows:
[0030] In the above formula, x This represents the original facial expression image. This indicates that it corresponds to the target domain. y The output of generator D, and the mapping network F provide the target domain. style coding in And the generator G learns to utilize And generate the target domain The distribution of real facial expression images in G( x , ).
[0031] Step 2.2: In order to force the generator G to generate the facial expression image G( x , Use style coding when ) The style reconstruction loss function is used for constraint, as shown in the following formula:
[0032] In the above formula, G( x , ) is the target facial expression image generated by generator G, which is processed by style encoder E. x , Regenerate style codes, and the style reconstruction loss is expected to be the original style codes. and after passing through the style encoder E to G ( x , The generated style codes should be as similar as possible, hopefully The smaller the better.
[0033] Step 2.3: To further enable the generator G to produce different facial expression images and increase the diversity of expressions, a diversity loss function is used for constraint, as shown in the following formula:
[0034] The target facial expression style encoding in the above formula and The mapping network F uses two random latent codes in the same target domain. and Generator G is generated under the following conditions. Generate emojis ,pass To generate emoticons and The purpose of diversity loss is to enable generator G to generate different styles within the same type of expression when generating the same type of expression. This is achieved by calculating... The difference between them should be as large as possible, so that the generator G can produce different facial expression images.
[0035] Step 2.4: To ensure that the facial expression image G( generated by generator G) is... x , It can correctly preserve the features of its original input facial expression image, constrained by the cycle consistency loss function, as shown in the following formula:
[0036] In the formula x The original input facial expression image, It is to input an emoji image. x The style code generated by style encoder E is the obtained It is the style encoding of its original image, which encourages the generator G to use the style encoding of the original image. Reconstructing the input facial expression image x This enables the generator G to learn to preserve facial expression images. x The original features, that is, the ability of the facial expression image generated by the generator G to reconstruct its original facial expression image, the cycle consistency loss function hopes that the two are as close as possible, the smaller the better.
[0037] Step 2.5: Finally, the four loss functions from Step 1.1 (adversarial loss function), Step 1.2 (style reconstruction loss function), Step 1.3 (diversity loss function), and Step 1.4 (cycle consistency loss function) are combined to form a total loss function for supervised training. The total loss function is shown in the following formula:
[0038] In the formula , and These are the hyperparameters for each item, set to [specific parameters] in the experiment. =1.0, =1.0, =1.0. To prevent overfitting during training, StarGAN v2 uses a 100,000-round loop. After training, the final generated result is the expanded driver facial expression dataset. To further verify the reliability and practicality of StarGAN v2, six expressions, the same as those in KMU-FED, are selected for training on the RAF-DB dataset. This dataset contains real-world images from the internet, offering greater diversity and challenge. The generated images are as follows... Figure 2As shown, the first two rows are images of the generated KMU-FED dataset, and the last two rows are images of the generated RAF-DB dataset. Compared with traditional data augmentation methods, using StarGAN v2 to offline augment the driver facial expression dataset can provide more diverse and realistic training samples, increase the richness of the dataset, improve the generalization ability and robustness of the model, and help improve the performance and effectiveness of the driver expression recognition model.
[0039] Step 3: Construct a lightweight driver expression recognition model. The model mainly includes a basic feature extraction module, a hybrid multi-scale feature extraction module, and a feature fusion module. Input the driver's facial expression image into the model for feature extraction.
[0040] The lightweight driver facial expression recognition model constructed in this invention is based on the lightweight model EfficientNet_b0, and the overall structure of the model is as follows: Figure 3 As shown, it mainly includes 9 stages: Stage 1 consists of a convolution with a stride of 2 and a kernel size of 3. Stage 3 consists of ordinary convolutions, Batch Normalization (BN) layers, and the Swish activation function. Stages 2 through 5 are repeated stacked MBConv structures, each composed of the basic feature extraction module. Stages 6 through 8 each consist of the hybrid multi-scale feature extraction module. The feature fusion module fuses the intermediate features of Stage 6 and the deep features of Stage 8. Stage 9 consists of a 1 It consists of a regular convolution (mainly including a BN layer and a Swish activation function), an average pooling layer, and a fully connected layer, and finally outputs after passing through a softmax layer.
[0041] The basic feature extraction module of this invention is the MBConv structure in the EfficientNet_b0 lightweight model, as shown in the figure below. Figure 4 As shown, its input is a shallow feature map obtained after preliminary feature extraction in Stage 1. The main steps of inputting the shallow feature map into the basic feature extraction module include: firstly, through a 1 Dimensionality is increased by performing a regular convolution of size 1, and then passed through a 3-dimensional convolution. 3 or 5 Feature extraction is performed using a depthwise separable convolution of 5, followed by an SE attention mechanism module to extract important features, and then a 1-bit convolution is used. Dimensionality reduction is performed using a standard convolutional layer (1), followed by a Dropout layer and a residual connection to output the feature map through the MBConv structure. Stages 2 through 5 consist of repeatedly stacked MBConv structures: once in Stage 2, twice in Stage 3, twice in Stage 4, and three times in Stage 5. Feature extraction is performed using these multiple MBConv structures from Stages 2 to 5, resulting in a feature map size of 28. 28 80. The feature map gradually evolves from shallow features to intermediate features, and has a larger receptive field.
[0042] The structure of the hybrid multi-scale feature extraction module is as follows: Figure 5 As shown, it adopts a symmetrical structure with complementary left and right sides, divided into two parallel branches, the left branch denoted as... The right branch is denoted as The input to the hybrid multi-scale feature extraction module is the feature map after Stage 2 to Stage 5. At this stage, the feature map has a larger receptive field and richer semantic information. The main steps for inputting the feature map into the hybrid multi-scale feature extraction module include: In both branches, the input feature map first passes through a 1... A regular convolution of 1 is used to increase the dimensionality, dividing the feature map into three feature subsets along the channel dimension. The three feature subsets of the left branch are denoted as follows: , , The three feature subsets of the right branch are denoted as follows: , , Each of the above feature subsets has the same size as the upgraded feature map, but the number of channels is 1 / 3 of the original. This structure ensures that both the preceding and following feature subsets contain richer scale information.
[0043] For each feature subset or , where i Each feature subset will be integrated with information from the previous feature subset before undergoing a 3-step process. A depthwise separable convolution of 3 is then input into the Coordinate Attention (CA) module. The feature map after passing through the CA module undergoes a concat operation along the channel dimension, followed by a channel shuffle operation to reassemble the channels. Thus, after... and Multi-scale feature extraction yielded two complementary and symmetrical feature maps. and Finally, the two feature maps are added element by element, represented as P = + The output is after passing through a Dropout layer and residual connections.
[0044] Specifically, for , Through 3 A depth of 3 allows for the output of separable convolutions. Fusion After the features, then through 3 A depth of 3 allows for the output of separable convolutions. Fusion After the features, then through 3 The output is obtained after a depthwise separable convolution of 3. 3-depth separable convolution feature extraction , , The outputs are then processed through three CA attention mechanism modules. , , Perform a concat operation on the channel dimension to restore the channel count to the AND value. Similarly, the channels are then reassembled using a channel shuffle operation, and the feature map obtained after multi-scale feature extraction is denoted as... , can be represented as:
[0045] for ,and The order of depthwise separable convolution is reversed. Through 3 A depth of 3 allows for the output of separable convolutions. Fusion After the features, then through 3 A depth of 3 allows for the output of separable convolutions. Fusion After the features, then through 3 The output is obtained after a depthwise separable convolution of 3. 3-depth separable convolution feature extraction , , The outputs are then processed through three CA attention mechanism modules. , , Perform a concat operation on the channel dimension to restore the channel count to the AND value. Similarly, the channels are then reassembled using a channel shuffle operation, and the feature map obtained after multi-scale feature extraction is denoted as... , can be represented as:
[0046] After the above... and Multi-scale feature extraction yielded two complementary and symmetrical feature maps. and Finally, the two feature maps are added element by element, which can be expressed as P = + Then, after passing through a Dropout layer and residual connections, the output is the feature map after hybrid multi-scale feature extraction. In Stage 6, the hybrid multi-scale feature extraction module is stacked 3 times; in Stage 7, it is stacked 4 times; and in Stage 8, it is stacked 1 time. The output feature map size is 7. 7 160. The feature map after hybrid multi-scale feature extraction has richer scale awareness and semantic information, while maintaining the importance of the original features and possessing a certain degree of robustness and generalization ability.
[0047] The structure of the feature fusion module is as follows: Figure 6 As shown: First, the feature map output by Stage6 is passed through a convolutional kernel of size 3. 3. Perform a downsampling operation using a regular convolution with a stride of 2, adjusting the size of the feature map from Stage 6 to be the same as that from Stage 8. Then, concatenate the Stage 6 feature map with the output feature map from Stage 8 along the channel dimension. The concatenated feature map is then divided into two parallel branches, left and right. The left branch goes through a global average pooling layer, two fully connected layers, and then multiplies the original feature map by the sigmoid function before outputting the result, which can be represented as:
[0048] The right branch passes through two 3s A depthwise separable convolution of 3 and a 1 A simple convolution of 1, followed by multiplication with the original feature map using the sigmoid function, can be represented as:
[0049] Finally, the outputs from the two parallel branches are added together. The output of the feature fusion module is the intermediate layer features, which can represent the basic semantic abstraction of the original input and are robust to noise. The deep layer features can capture more complex semantic information and have a larger receptive field. By fusing features from different levels, richer semantic information and multi-scale receptive fields can be provided, thereby improving the robustness of the model. The fused feature map is input into Stage9, and finally, after passing through softmax, the probability of different expressions can be obtained.
[0050] Step four: Train the lightweight driver expression recognition model and use the trained model to recognize driver expressions.
[0051] This step is based on the driver facial expression dataset augmented by StarGAN v2, and uses a combination of an improved center loss function and a cross-entropy loss function for joint supervised training. The improved center loss can be expressed as the following formula:
[0052] In the above formula, the distance between different classes is constrained by mapping sample features to the feature space, minimizing the Euclidean distance between sample features and their class centroids, and calculating the standard deviation of the class centroid matrix formed by each class centroid vector in the feature space. This approach aims to both reduce the distance between similar expressions and increase the distance between different classes. , ,and Representing the number of samples in the current batch, the number of samples in the first batch, and the number of samples in the second batch, respectively. i The feature vector of the training sample and the first training sample i The center vector of the feature space of the class to which each training sample belongs. The standard deviation of the class center matrix in the feature space. The hyperparameter was set to 0.03 in the experiment. Compared with the original center loss, the improved center loss also encourages the expansion of the distance between different classes, and the class center matrix has been obtained in the previous calculation, so it will not add any additional computational overhead.
[0053] The cross-entropy loss function can be expressed as:
[0054] in, n Indicates the number of categories. Indicates a true tag. Let represent the predicted probability. The final total loss function can be expressed as:
[0055] in, This is a hyperparameter used to control the proportion of the improved center loss; in the experiment, it was set to 0.01. The cross-entropy loss function is used. By combining the improved center loss function with the cross-entropy loss function for joint supervised training, the problems of intra-class differences and inter-class similarities in driver expression recognition can be effectively alleviated, thereby improving the model's recognition efficiency.
[0056] This invention uses a KMU-FED driver facial expression dataset (1600 images) augmented with StarGAN v2 for training. The training is iteratively conducted for 100 epochs with a batch size of 128 and dropout set to 0.2. During training, the Adam optimizer is used, along with online data augmentation techniques, including random rotation (angle range from -15° to 15°), vertical translation, horizontal flipping, and random cropping. The initial learning rate (lr) is set to 0.001. The learning rate optimization strategy is as follows: during training, if the loss value on the validation set does not decrease within 10 epochs, the learning rate (lr) is reduced to 0.1 times its original value.
[0057] This invention also provides a driver facial expression recognition device based on a lightweight model, comprising: The data acquisition unit, located in the driver's cab, acquires real-time video of the driver's face and segments it into images frame by frame, or periodically acquires images of the driver's face. The main function of the data acquisition unit is to identify the target. This invention is designed for the driver's cab environment, and a camera facing the driver can be placed in a suitable position such as in front of the driver's cab or around the steering wheel to achieve real-time video or image acquisition.
[0058] The facial expression recognition unit loads a lightweight driver facial expression recognition model trained using the lightweight model-based driver facial expression recognition method described in this invention. The facial expression recognition unit communicates with the data acquisition unit; the two can be integrated into one unit, or the recognition unit can be integrated into any processor within the vehicle with processing capabilities. After preprocessing the acquired image, the facial expression recognition unit uses the trained lightweight driver facial expression recognition model to recognize the driver's facial expressions in the image.
[0059] After the identification is completed, in order to utilize the identification results, the present invention also provides a safe driving assistance device, including a main control unit and an alarm unit.
[0060] The main control unit is connected to the expression recognition unit of the driver expression recognition device based on the lightweight model, and receives the driver's facial expression results recognized by the expression recognition unit. In some embodiments, the main control unit and the expression recognition unit can be integrated into a single processor, which can save resources, but will place higher demands on the processor's computing power.
[0061] The main control unit is connected to the alarm unit, the vehicle braking unit, and the vehicle acceleration unit. Based on different identification results, it sends an alarm signal to the alarm unit, a braking signal to the vehicle braking unit, and an acceleration restriction signal to the vehicle acceleration unit.
[0062] The main control unit can be the core processing part of the car. Under normal circumstances, it can recognize the results of facial expressions that may hinder safe driving, such as anger or fear, and issue warnings. The warning methods include in-vehicle voice prompts or text prompts on the instrument panel and central control display. Furthermore, it can control the vehicle's braking unit to slow / emerge braking or limit further acceleration based on the possible level of obstruction. These logics regarding braking and acceleration limitation can be associated with the driving scenario, especially the recognition results of objects outside the vehicle, and put forward higher requirements for the facial expression recognition of the driver inside the vehicle. Specific applications need further research.
[0063] To verify the recognition efficiency of the lightweight driver facial expression recognition model proposed in this invention, training and validation were performed on the KMU-FED driver facial expression dataset and the RAF-DB real-world dataset according to the above training steps. Since the KMU-FED dataset has a small number of samples, a 5-fold cross-validation method was used for the experiment. The experimental results are shown in Table 1, and the comparison with existing algorithms is shown in Tables 2 and 3.
[0064] Table 1. Accuracy of the model proposed in this invention on different datasets. Dataset Recognition accuracy Number of parameters (M) FLOPs (GMac) KMU-FED 97.51% 2.15 0.3G RAF-DB 87.84% 2.15 0.3G Table 2 compares the algorithm with existing algorithms on the KMU-FED dataset. Model Recognition accuracy Number of parameters (M) FLOPs (GMac) SqueezeNet 89.70% 1.25 0.17 MobileNetV2 93.80% 3.4 0.3 MobileNetV3 94.90% 4.21 0.35 This invention 97.51% 2.15 0.3 Table 3 compares the algorithm with existing algorithms on the RAF-DB dataset. Model Recognition accuracy Number of parameters (M) FLOPs (GMac) Separate-Loss 86.40% 11.2 1.8 SCN 87.00% 11.18 1.85 RAN 86.90% 11.19 14.6 LDL-ALSG 85.50% 23.5 4.1 This invention 87.84% 2.15 0.3 The experimental results above demonstrate that the lightweight driver expression recognition model proposed in this invention achieves good recognition performance while maintaining a lightweight design, enabling real-time recognition even in resource-constrained scenarios.
Claims
1. A driver facial expression recognition method based on a lightweight model, characterized in that, Includes the following steps: Step 1: Prepare the driver facial expression dataset and preprocess the images in the driver facial expression dataset; Step 2: Use StarGAN v2 to generate driver facial expression images and perform offline augmentation to increase the number of samples in the driver facial expression dataset; Step 3: Construct a lightweight driver facial expression recognition model. The model includes a basic feature extraction module, a hybrid multi-scale feature extraction module, and a feature fusion module. Input the driver's facial expression image into the model for feature extraction. The lightweight driver facial expression recognition model is based on the lightweight model EfficientNet_b0 and includes 9 stages. Stage 1 consists of a convolutional layer with a stride of 2 and a kernel size of 3. The system consists of 3 convolutional and batch normalization (BN) layers and a Swish activation function. Each stage (Stages 2-5) is composed of the basic feature extraction module, and each stage (Stages 6-8) is composed of the hybrid multi-scale feature extraction module. The feature fusion module integrates the intermediate features of Stage 6 and the deep features of Stage 8. Stage 9 consists of a 1... It consists of a convolutional layer of 1, an average pooling layer, and a fully connected layer, and finally passes through a softmax layer for output. The basic feature extraction module is the MBConv structure in the EfficientNet_b0 lightweight model. In this module: the feature map is first processed through a 1... 1-dimensionality convolution is used for dimensionality upscaling, and then a 3-dimensionality convolution is performed. 3 or 5 Feature extraction is performed using a depthwise separable convolution of 5, followed by feature extraction through an SE attention mechanism module, and then through a 1 The dimensionality is reduced by a convolution of 1, and finally output after passing through a Dropout layer and residual connections; The hybrid multi-scale feature extraction module adopts a symmetrical structure with complementary left and right sides, divided into two parallel branches, the left branch denoted as... The right branch is denoted as In the module: In both branches, the input feature maps are first passed through a 1 The convolution of 1 is used to increase the dimensionality, dividing the feature map into three feature subsets along the channel dimension. The three feature subsets of the left branch are denoted as follows: , , The three feature subsets of the right branch are denoted as follows: , , Each feature subset has the same size as the upgraded feature map, but the number of channels is 1 / 3 of the original. or , where i Each feature subset will be integrated with information from the previous feature subset before undergoing a 3-step process. A depthwise separable convolution of 3 is then input into the CA attention module. The feature map after passing through the CA attention module undergoes a concat operation along the channel dimension, followed by a channel shuffle operation to reassemble the channels. Thus, after... and Multi-scale feature extraction yielded two complementary and symmetrical feature maps. and Finally, the two feature maps are added element by element, represented as P = + The output is after passing through a Dropout layer and a residual connection; In the feature fusion module: the feature map output by Stage6 is processed by a convolutional layer with a stride of 2 and a kernel size of 3. 3 convolutions are used to perform downsampling operations, and then concatenated with the feature map output from Stage8 in the channel dimension. The concatenated feature map is then divided into two parallel branches, left and right. The left branch goes through a global average pooling layer and two fully connected layers, and then the sigmoid function is multiplied with the original feature map before output. The right branch passes through two 3s A depthwise separable convolution of 3 and a 1 The convolution is performed with a value of 1, then the sigmoid function is multiplied by the original feature map and the result is output; finally, the outputs of the two parallel branches are added together and the result is output. Step 4: Train the lightweight driver expression recognition model and use the trained model to recognize driver expressions.
2. The driver facial expression recognition method based on a lightweight model according to claim 1, characterized in that, The preparation of the driver facial expression dataset involves preprocessing the images in the dataset, including: The KMU-FED dataset was used and divided into training and test sets proportionally. Enhance image contrast through adaptive histogram equalization; Retinaface is used for face detection and alignment, and the aligned images are cropped to the same resolution.
3. The driver facial expression recognition method based on a lightweight model according to claim 1, characterized in that, The StarGAN v2 includes a generator G, a mapping network F, a style encoder E, and a discriminator D; The process of generating driver facial expression images using StarGAN v2 and performing offline augmentation to increase the number of samples in the driver facial expression dataset includes: The generator G receives source facial expression images and target facial expression style codes, and generates new facial expression images that match the target domain. The discriminator D determines whether the input image is a real facial expression image from the training samples or a facial expression image generated by the generator G, and determines the domain to which the input image belongs. The mapping network F maps random noise vectors to style codes in the latent space, and the style codes are used to guide the generator G in domain transformation. The style encoder E extracts style codes from real facial expression images, enabling StarGAN v2 to capture the style of a specific image and apply this style to the image generation process of another domain.
4. The driver facial expression recognition method based on a lightweight model according to claim 3, characterized in that, Based on a preprocessed dataset of driver facial expressions, StarGAN v2 was trained under supervised supervision using adversarial loss, style reconstruction loss, cycle consistency loss, and diversity loss. The adversarial loss was used to train the generator G to generate realistic-looking images, while simultaneously training the discriminator D to distinguish between real and generated images. The style reconstruction loss ensured that the generator G applied the style encoding of the target domain to the generated images. The cycle consistency loss ensured that the source image was transformed to the target domain and then back to the original domain while maintaining the consistency of image content. The diversity loss encouraged StarGAN v2 to generate stylistically distinct images given the same source image but different random noise or style encodings. Multiple rounds of iterative training were conducted, resulting in the generated driver facial expression images.
5. The driver facial expression recognition method based on a lightweight model according to claim 1, characterized in that, Training the lightweight driver facial expression recognition model includes: Based on the driver facial expression dataset expanded with StarGAN v2, training is jointly supervised using an improved center loss function combined with a cross-entropy loss function; the improved center loss function is expressed as: in , ,and Representing the number of samples in the current batch, respectively, and the number of samples in the first batch. i The feature vector of the training sample and the first training sample i The center vector of the feature space of the class to which each training sample belongs. The standard deviation of the class center matrix in the feature space. For hyperparameters; The cross-entropy loss function is expressed as: in, n Indicates the number of categories. Indicates a true tag. Indicates the predicted probability; The overall loss function is expressed as: in, This is a hyperparameter.
6. The driver facial expression recognition method based on a lightweight model according to claim 1 or 5, characterized in that, Online data augmentation was used during training, including the application of random rotation, vertical translation, horizontal flipping, and random cropping.
7. A driver facial expression recognition device based on a lightweight model, characterized in that, include: The data acquisition unit is located in the driver's cab and acquires real-time video of the driver's face and segments it into images frame by frame, or periodically acquires facial images of the driver. The expression recognition unit loads a lightweight driver expression recognition model trained according to the driver expression recognition method based on a lightweight model as described in any one of claims 1 to 6; the expression recognition unit communicates with the data acquisition unit, preprocesses the obtained image, and then uses the trained lightweight driver expression recognition model to recognize the driver's facial expression in the image.
8. A safe driving assistance device, characterized in that, Includes a main control unit and an alarm unit; The main control unit is connected to the expression recognition unit of the driver expression recognition device based on the lightweight model as described in claim 7, and receives the driver's facial expression results recognized by the expression recognition unit; The main control unit is connected to the alarm unit, the vehicle braking unit, and the vehicle acceleration unit. Based on different identification results, it sends an alarm signal to the alarm unit, a braking signal to the vehicle braking unit, and an acceleration restriction signal to the vehicle acceleration unit.
