Lightweight distracted driving detection method

By hierarchical improvements to the YOLOv8s model, including module replacement, attention mechanism addition and loss function improvement, the existing distracted driving detection methods have solved the problem of large computing resources and inaccurate detection, and achieved lightweight and efficient detection of the model Accuracy.

CN119418310APending Publication Date: 2025-02-11WUXI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411433910.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-15
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

The existing distracted driving detection methods consume a lot of computing resources, are difficult to deploy in embedded vehicle-mounted equipment, and are inaccurate in complex driving environments.

Method used

The YOLOv8s model was improved using a hierarchical improvement mechanism, including replacing the modules of the backbone, neck and detection head part of the model, adding modules of the detection head connection part, adding attention mechanism, and improving the loss function. Specific measures include replacing the C2f module with the FasterNet module, adding the PConv module, adding the NAM attention mechanism, and using the Focal-EIoU loss function.

Benefits of technology

The model is lightweighted, with a 21.6% reduction in parameter volume, a 2.8G reduction in FLOPs, a 1.2% improvement in detection accuracy, and an 81.6% improvement in mAP. It is suitable for deployment in resource-constrained vehicle equipment and perform well in complex driving environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119418310A_ABST
    Figure CN119418310A_ABST
Patent Text Reader

Abstract

The invention discloses a lightweight distracted driving detection method. Relates to the field of safety detection of an intelligent traffic system and an automatic driving assistance system, in particular to the technical field of distracted driving behavior detection based on deep learning. The problems that according to an existing detection method, the number of computing resources is large, lightweight application cannot be carried out, and inaccurate detection is likely to occur are solved. The method comprises the following steps: S1, data acquisition and division: collecting distraction driving behavior images, and dividing the distraction driving behavior images into a training set, a verification set and a test set; and S2, constructing a distracted driving detection model, and improving the existing YOLOv8s model framework by adopting a hierarchical improvement mechanism. S3, training the distraction driving detection model: training the distraction driving detection model through the training set and the verification set, and testing a training result through the test set to obtain the distraction driving detection model which can be applied; and S4, detecting the driving behavior by adopting the distraction driving detection model which can be applied.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of safety detection of intelligent transportation systems and automatic driving assistance systems, and in particular to the field of distracted driving behavior detection technology based on deep learning. Background Art

[0002] With the progress of society and the improvement of people's living standards, driving has become one of the mainstream travel modes. As a result, the traffic volume on the road is large, the frequency of driving behavior increases, and the driving time becomes longer. People inevitably have some distracted driving behaviors during driving. At present, distracted driving behavior is one of the main causes of traffic accidents. Common distracting behaviors such as using mobile phones, drinking water, smoking, etc. while driving will seriously affect the driver's driving attention.

[0003] Therefore, real-time monitoring and identification of these distracted driving behaviors while driving can effectively reduce traffic accidents caused by distracted driving. Traditional methods for detecting driver distracted driving behaviors are usually based on computer vision and machine learning technologies, but there are still many challenges in terms of real-time performance and accuracy. The introduction of deep learning technology has brought significant progress in distracted driving detection, especially the application of target detection algorithms based on YOLO (You Only Look Once) technology, which has greatly improved the accuracy and speed of driver behavior detection. However, although advanced target detection algorithms such as YOLOv8 have outstanding performance in detection accuracy and efficiency, the high complexity of the model leads to more computing resources required, which poses a challenge to deployment in resource-constrained embedded vehicle devices.

[0004] In addition, existing detection technologies are prone to inaccurate detection when faced with complex changes in the driver's facial and hand movements, especially in low-light or complex background driving environments, where performance is significantly reduced. Summary of the invention

[0005] In order to solve the problem that the existing detection method has too much computing resources to be used in a lightweight manner and is prone to inaccurate detection when facing complex facial and hand movements of the driver, the present invention provides a lightweight distracted driving detection method, which includes the following steps:

[0006] S1. Data collection and division:

[0007] Collect distracted driving behavior images and divide them into training set, validation set and test set;

[0008] S2. Construction of distracted driving detection model, specifically:

[0009] A hierarchical improvement mechanism is used to improve the existing YOLOv8s model framework. The hierarchical improvement mechanism is specifically as follows:

[0010] First layer: Reduce the number of parameters and complexity by replacing modules in the model's trunk, neck, and detection head;

[0011] The second layer: improves detection accuracy by adding modules in the part connected to the model detection head;

[0012] The third layer: improve detection accuracy by adding attention mechanism;

[0013] The fourth layer: improve the detection accuracy by improving the loss function;

[0014] S3. Distracted driving detection model training: The distracted driving detection model is trained through the training set and the validation set, and the training results are tested through the test set to obtain a distracted driving detection model that can be applied;

[0015] S4. Use an applicable distracted driving detection model to detect driving behavior.

[0016] Furthermore, the replacement of modules in the trunk, neck and detection head parts of the model is specifically: replacing the C2f module in the trunk, neck and detection head parts of the YOLOv8s model with a FasterNet module.

[0017] Furthermore, the addition of modules in the part connected with the model detection head is specifically as follows:

[0018] The neck part of the YOLOv8s model includes two paths, one is a path connected to the trunk part, and the other is a path connected to the detection head part. A PConv module is added to the path connected to the detection head part, and the position where the PConv module is added is before the last FasterNet module of the path.

[0019] Furthermore, the addition of the attention mechanism is specifically as follows: adding a NAM attention mechanism module after the SFFP module in the Backbone part of the YOLOv8s model.

[0020] Furthermore, the improvement of the loss function is specifically as follows: the loss function is changed from CIoU to Focal-EIoU.

[0021] The present invention further provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method of the present invention when executing the computer program.

[0022] The present invention also provides a computer-readable storage medium for storing computer instructions, wherein the computer instructions implement the steps of the method of the present invention when executed by a processor.

[0023] The beneficial effects of the method of the present invention are:

[0024] In view of the problems existing in the existing distracted driving detection model, such as large number of parameters, high computational complexity, and unsuitability for deployment on vehicle-mounted edge devices, the method of the present invention proposes a lightweight distracted driving detection method based on YOLOv8. First, the C2f module in YOLOv8 is replaced by the FasterNet module, which effectively reduces the number of parameters and computational complexity of the model. In order to reduce the amount of calculation while ensuring the detection accuracy, the present invention introduces PConv convolution in the detection head to further optimize the convolution operation. Secondly, the NAM attention mechanism is added to improve the model's ability to capture key areas such as the driver's hands and face, and enhance the detection effect in complex driving scenarios. In addition, by using the Focal-EIoU loss function instead of CIoU, the accuracy and convergence speed of the prediction box regression calculation are improved. Experimental results show that the YOLOv8s-FPNE model of the present invention achieves a mAP of 81.6% in the distracted driving detection task, which is 1.2% higher than the original YOLOv8s model, with a 21.6% reduction in parameters and a 2.8G reduction in FLOPs, achieving high efficiency and lightweight. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 This is a schematic diagram of the YOLOv8s model structure;

[0026] Figure 2 This is a schematic diagram of the YOLOv8s-FPNE model structure;

[0027] Figure 3 Comparison bar chart of mAP between YOLOv8s model and YOLOv8s-FPNE model;

[0028] Figure 4 It is the precision-recall (PR) curve of the YOLOv8s model and the YOLOv8s-FPNE model. DETAILED DESCRIPTION

[0029] The technical solution of the present invention will be described clearly and completely below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0030] Embodiment 1,

[0031] This embodiment provides a lightweight distracted driving detection method, the method comprising the following steps:

[0032] S1. Data collection and division:

[0033] Collect distracted driving behavior images and divide them into training set, validation set and test set;

[0034] S2. Construction of distracted driving detection model, specifically:

[0035] A hierarchical improvement mechanism is used to improve the existing YOLOv8s model framework. The hierarchical improvement mechanism is specifically as follows:

[0036] First layer: Reduce the number of parameters and complexity by replacing modules in the model's trunk, neck, and detection head;

[0037] The second layer: improves detection accuracy by adding modules in the part connected to the model detection head;

[0038] The third layer: improve detection accuracy by adding attention mechanism;

[0039] The fourth layer: improve the detection accuracy by improving the loss function;

[0040] S3. Distracted driving detection model training: The distracted driving detection model is trained through the training set and the validation set, and the training results are tested through the test set to obtain a distracted driving detection model that can be applied;

[0041] S4. Use an applicable distracted driving detection model to detect driving behavior.

[0042] Embodiment 2,

[0043] This embodiment further limits the embodiment 1 and further illustrates step S1.

[0044] The distracted driving behavior images include three typical distracted driving behaviors: using a mobile phone, drinking water, and smoking. Each category contains a large number of images of drivers under different lighting, angles, and background conditions to ensure that the model can maintain good detection performance in various real driving environments. The data set contains a total of 5147 images. To ensure the effectiveness of model training, the data set is divided into training set, test set, and validation set in a ratio of 7:2:1. The images are collected by cameras and cover a variety of actual driving scenarios, such as urban roads, highways, etc., to ensure the diversity of data. All images are manually annotated, and the annotation information includes the category of distracted behavior, the position of the target frame, etc., to ensure the accuracy of the training data. During the experiment, all input images undergo the following preprocessing steps before being sent to the model: 1. Size adjustment: The resolution of all images is adjusted to 640×640 to meet the input requirements of the YOLOv8s-FPNE model (the distracted driving detection model designed by the present invention is named the YOLOv8s-FPNE model). 2. Normalization: The pixel values ​​of the image are normalized to speed up the convergence of the model and improve the training effect. 3. Data enhancement: Data enhancement is performed through random flipping, rotation, brightness adjustment, etc. to improve the generalization ability of the model.

[0045] Embodiment 3,

[0046] This embodiment further limits the embodiment 1 and further illustrates step S2.

[0047] based on Figure 1 The YOLOv8-S version of YOLOv8 shown in the figure is used as the baseline model, and it is optimized in many aspects to propose the YOLOv8s-FPNE model, whose model structure is Figure 2 To detect distracted driving behavior, the model introduces the following innovations:

[0048] The first layer: Reduce the number of parameters and complexity by replacing modules in the trunk, neck, and detection head of the model; specifically, replace the C2f module in the trunk, neck, and detection head of the YOLOv8s model with the FasterNet module. For example, C2f_Faster in 2 in the figure represents the FasterNet module.

[0049] The second layer: the detection accuracy is improved by adding modules in the part connected to the model detection head; specifically, the neck part of the YOLOv8s model contains two paths, one is the path connected to the trunk part, and the other is the path connected to the detection head part. A PConv module is added to the path connected to the detection head part, and the position where the PConv module is added is before the last FasterNet module of the path.

[0050] The third layer: Improve detection accuracy by adding the attention mechanism; specifically, add the NAM attention mechanism module after the SFFP module in the Backbone part of the YOLOv8s model, such as Figure 2 The NAMA in the figure stands for NAM attention mechanism module.

[0051] The fourth layer: Improve the detection accuracy by improving the loss function; specifically, change the loss function from CIoU to Focal-EIoU.

[0052] Introduce the FasterNet:

[0053] FasterNet is a lightweight network structure designed to improve the operating efficiency of neural networks by reducing redundant calculations. The introduction of this module is particularly suitable for resource-constrained scenarios, such as edge computing devices or embedded systems.

[0054] FasterNet uses PConv to optimize the calculation path. Compared with traditional convolution operations, it can significantly reduce the computational overhead while ensuring the quality of feature extraction. Traditional neural networks, especially deep convolutional neural networks (CNNs), usually require a lot of computing resources when processing images. Commonly used convolution operations need to process all data in each input channel and perform corresponding convolution calculations on them, which will generate huge computing requirements and memory access pressure. In real-time application scenarios, such as distracted driving detection, each frame of the image needs to be analyzed quickly to ensure that the system can respond immediately. The design focus of FasterNet is how to reduce unnecessary calculations without sacrificing accuracy so that input data can be processed quickly and efficiently.

[0055] FasterNet uses PConv to reduce the amount of computation. The main difference between PConv and traditional convolution is that it only performs convolution operations on some input channels. Traditional convolution operations require the same convolution to be performed on all input channels, which means that even if the features of some channels have little effect on subsequent detection, computing resources will still be wasted. PConv effectively reduces redundant computation by selectively applying convolution operations.

[0056] PConv works by analyzing the similarities between channels in the input feature map to determine which channels can share information. It only performs standard convolution operations on certain key channels, while the remaining channels retain feature information through sparse connections or feature sharing. This not only reduces the number of convolution calculations, but also significantly reduces the number of memory accesses, thereby effectively improving the computational efficiency of the model.

[0057] The C2f module (a variant of the Cross Stage Partial Network) in YOLOv8 is a feature extraction module in its original structure. The C2f module reduces redundant calculations by sharing feature information at different stages. Although C2f performs well in YOLOv8, it still has the problem of high computational complexity, especially when high-resolution input is used, the FLOPs (Floating Point Operations Per Second) of the model will increase significantly.

[0058] This example replaces the C2f module in YOLOv8 with FasterNet. FasterNet significantly reduces the FLOPs of the network through its lightweight architecture and efficient calculation method of PConv. While maintaining similar or better detection accuracy, FasterNet reduces the consumption of memory bandwidth, allowing the model to run efficiently in embedded devices or edge computing scenarios.

[0059] Introduction to PConv:

[0060] PConv (partial convolution) is a method for optimizing convolution operations, which aims to reduce redundant calculations in convolutional neural networks. It is particularly suitable for high-resolution image processing tasks such as target detection and distracted driving detection. Traditional convolution operations require the same calculation to be performed on each channel of the input, while PConv only performs convolution operations on some input channels. This method effectively reduces the amount of calculation and memory bandwidth consumption while maintaining a high feature extraction capability.

[0061] When processing images, convolutional neural networks usually generate multi-channel feature maps. The features between these channels are often highly similar, so performing the same convolution operation on each channel may result in a lot of redundant calculations. PConv reduces unnecessary calculations by performing standard convolution operations on only some channels of the input feature map, while other channels are connected through sparse or skip connections.

[0062] In the YOLOv8s-FPNE model, PConv is used in the part connected to the detection head. The detection head is responsible for classifying and predicting the location of the target based on the extracted feature map. Traditional detection heads usually apply multiple convolutional layers to perform convolution calculations on all input channels. This method has a very high computational burden when processing high-resolution images. PConv significantly reduces FLOPs by reducing the number of convolution operations, allowing the model to complete reasoning faster when processing high-resolution images.

[0063] Introduce the Normalized Attention Mechanism:

[0064] NAM (Normalized Attention Mechanism) is a lightweight and efficient attention mechanism that aims to enhance the model's ability to focus on key features in a neural network while reducing the computational burden. The attention mechanism is widely used in computer vision tasks, especially in object detection tasks. The attention mechanism can effectively help the model focus on important areas in the image, thereby improving detection accuracy.

[0065] In neural networks, the role of convolution operations is to extract spatial and channel features of input images. However, convolution operations usually perform the same processing on all features of the input, which may cause the model to be unable to distinguish between key features and minor features. The core idea of ​​the attention mechanism is to enhance the model's attention to important areas by giving weights to different features.

[0066] The NAM attention mechanism combines channel attention and spatial attention to enable the model to adaptively adjust the degree of attention to different regions and channels. Channel attention is mainly used to adjust the importance of each channel in the feature map, while spatial attention is used to select the most critical area in the spatial dimension of the feature map.

[0067] Compared with traditional attention mechanisms, such as CBAM (Convolutional Block Attention Module) and SE (Squeeze-and-Excitation) modules, NAM achieves a better balance between computational complexity and performance. The main innovation of NAM is that it simplifies the process of attention calculation, reduces redundant calculations by introducing normalization operations and lightweight weight adjustment mechanisms, while maintaining the ability to focus on important features.

[0068] In the YOLOv8s-FPNE model, the NAM attention mechanism is introduced into multiple network modules. By attaching the NAM module after the convolutional layer, the model can dynamically adjust different channels and spatial regions during the feature extraction process. This enables YOLOv8s-FPNE to more accurately capture the driver's distracted behavior when dealing with complex scenes, especially in multi-tasking or complex lighting conditions, where NAM significantly improves the performance of the model.

[0069] Introduce the Focal-EIoU loss function:

[0070] In the object detection task, the loss function is one of the core elements for evaluating the model performance. The traditional YOLO model uses CIoU (Complete Intersection over Union) as the loss function. CIoU not only considers the IoU between the predicted box and the true box, but also introduces the influence of distance and aspect ratio. However, CIoU still has some limitations when dealing with complex scenes, especially in the processing of high-quality samples and difficult-to-detect targets. The model converges slowly and has limited positioning accuracy.

[0071] To solve these problems, this embodiment introduces the Focal-EIoU loss function. This improved version combines the Focal mechanism and EIoU (Extended IoU) loss, so that the model can better perform feature learning and positioning prediction when processing complex samples.

[0072] CIoU improves the accuracy of the target detection box by adding the distance and aspect ratio penalty of the target box center point on the basis of IoU. However, CIoU still cannot completely solve the problems of difficult sample processing and uneven weight of high-quality samples. CIoU shows problems of slow convergence and inaccurate positioning when dealing with some complex scenes in distracted driving detection tasks, especially when detecting fine movements of the driver (such as holding a mobile phone or looking up at the mirror), the error is large.

[0073] The Focal-EIoU loss function combines the Focal mechanism to make the model pay more attention to difficult-to-detect samples during training. The Focal mechanism reduces the weight of easy-to-detect samples, allowing the model to focus more on difficult-to-detect targets during training. In this way, the model can significantly improve detection accuracy when dealing with complex distracted driving behaviors (such as multi-tasking distraction and subtle movements).

[0074] EIoU further expands the geometric relationship of the target box based on CIoU, not only considering IoU, distance and aspect ratio, but also introducing a new term to optimize the alignment between the predicted box and the real box. This enables the model to converge faster and maintain high prediction accuracy in difficult-to-detect scenarios.

[0075] The calculation formula of Focal-EIoU loss function is as follows:

[0076]

[0077] Among them, IoU is the intersection over union ratio of the predicted box and the real box, α and γ are the weight parameters controlling the distance and aspect ratio penalty terms, and x pred is the center x coordinate of the prediction box, x true is the center x coordinate of the ground truth box, The square of the maximum possible distance between the predicted box and the true box. The Focal mechanism dynamically adjusts the weights to enable the model to focus more on samples that are difficult to detect.

[0078] In the YOLOv8s-FPNE model, Focal-EIoU replaces the original CIoU loss function. With this improvement, the model shows better convergence and stability when dealing with complex scenes. Especially in the distracted driving detection task, Focal-EIoU can effectively improve the positioning accuracy of the driver's fine movements, such as identifying subtle movements such as the driver using a mobile phone, looking up or turning his head in complex lighting conditions.

[0079] Embodiment 4,

[0080] This example experimentally verifies the beneficial effects of the methods defined in Examples 1-3.

[0081] The experiment uses 640×640 pixels as the input image size. For the training parameters, the batch size is selected as 16, the training epoch is set to 100, and the initial learning rate is set to 0.001. The specific experimental conditions are shown in Table 1.

[0082] Table 1:

[0083]

[0084] In order to comprehensively evaluate the performance of the YOLOv8s-FPNE model proposed in this paper in the distracted driving detection task, the experiment used a variety of commonly used evaluation indicators. These indicators not only cover the detection accuracy, but also include the efficiency, resource consumption and real-time performance of the model. The following are the specific evaluation indicators and their significance:

[0085] Mean Average Precision (mAP).

[0086] Average precision (mAP) is one of the most commonly used evaluation indicators in target detection tasks, which is used to evaluate the comprehensive detection performance of the model for different categories of targets. mAP is the average AP value (Average Precision) of all categories. The calculation formula of AP is as follows:

[0087]

[0088] Among them, p(r) represents the precision curve under different recall rates. The higher the mAP value, the higher the detection accuracy of the model. This experiment mainly evaluates the average accuracy of the YOLOv8s-FPNE model on three types of distraction behaviors: "using mobile phones", "drinking water" and "smoking". The calculation of mAP is based on the model's correct recognition of the target location and category.

[0089] Precision.

[0090] Precision measures the proportion of correct predictions among all samples predicted as positive by the model. The formula is as follows:

[0091]

[0092] Among them, TP is a true positive and FP is a false positive. High accuracy means that the model has a low probability of false positives during the detection process, that is, the model only issues an alarm when distraction behavior actually occurs, thereby reducing interference to the driver.

[0093] Recall

[0094] The recall rate indicates the proportion of correct predictions made by the model among all actual positive samples. The formula is as follows:

[0095]

[0096] Among them, FN is a false negative example. A high recall rate means that the model can detect the driver's distracted behavior as much as possible with a low false negative rate. Improving the recall rate is particularly important to ensure that the system can identify the driver's distracted behavior in a timely manner.

[0097] F1-score.

[0098] F1-score is a weighted average of precision and recall, which is used to comprehensively evaluate the performance of the model.

[0099] The calculation formula of F1-score is as follows:

[0100]

[0101] The higher the F1-score, the better the model strikes a balance between precision and recall, and can accurately and comprehensively detect distracting behaviors.

[0102] Intersection over Union (IoU).

[0103] IoU measures the degree of overlap between the model prediction box and the real box. The calculation formula is as follows:

[0104]

[0105] The higher the IoU, the closer the model's target detection box is to the real target. In distracted driving detection, IoU is a key indicator for evaluating the model's target positioning performance.

[0106] Parameter quantity (Model Parameters).

[0107] The parameter count measures the total number of all parameters in the model. The fewer the parameters, the lighter the model is and the more suitable it is for deployment on resource-constrained devices.

[0108] Floating Point Operations Per Second (FLOPs).

[0109] FLOPs represents the number of floating-point operations that the model needs to perform during reasoning. The lower the FLOPs, the lower the computational complexity of the model and the faster the reasoning speed. In the distracted driving detection task, low FLOPs ensures that the model can detect the driver's behavior in real time and meet the real-time requirements of the vehicle system.

[0110] Table 2 shows the experimental comparison results of YOLOv8s introducing the current mainstream lightweight network. C2f-Faster has the least impact on accuracy while reducing the number of parameters, which meets the needs of distracted driving detection scenarios. Although MobileNetV3 and ShuffleNetV2 have certain advantages in parameter quantity and computational complexity, their detection accuracy is slightly lower than C2f-Faster. Therefore, this paper selects C2f-Faster as the network structure of the final model.

[0111] Table 2:

[0112] Method mAP@0.5(%) Params(M) FLOPs(G) YOLOv8s 80.4 11.13 28.4 MobileNetV3 72.5 2.56 6.1 ShuffleNetV2 72.8 6.38 16.4 C2f-Faster 79.0 8.30 21.4

[0113] In order to evaluate the impact of different improved modules on the accuracy of distracted driving detection, a series of ablation experiments were designed to gradually disassemble and analyze the improved YOLOv8s-FPNE model. Through the ablation experiment, we can deeply understand the contribution of each improved module to the model performance. The specific results are shown in Table 3.

[0114] Table 3:

[0115]

[0116] Table 3 shows that the accuracy of the original YOLOv8s model reached 80.4%, an increase of 1.6% compared to YOLOv10s. After replacing C2f with FasterNet, the number of parameters and complexity were significantly reduced to 8.30M and 21.4G, but the mAP dropped slightly to 79.0%. After adding the PConv module, the number of parameters and complexity increased slightly, but the mAP increased to 79.8%, indicating that PConv can improve the detection accuracy without significantly increasing the complexity. After using the Focal-EIoU loss function, the mAP was further improved to 80.4%, which is the same as the effect after the introduction of the NAM mechanism. The NAM attention mechanism significantly improved the mAP to 81.6%, indicating its effectiveness in highlighting important features. In summary, the fusion of FasterNet, PConv, NAM and Focal-EIoU loss function significantly improved the performance of the YOLOv8s-FPNE model, which is suitable for deployment on resource-constrained devices for distracted driving detection.

[0117] Experimental results show that the NAM attention mechanism outperforms other attention mechanisms in both detection accuracy and mAP value. In the distracted driving detection task, the NAM attention mechanism achieved an mAP value of 81.6%. Therefore, this paper selects the NAM attention mechanism as the attention module of the final model.

[0118] The introduction of the attention mechanism can effectively improve the detection accuracy and efficiency of the model. In order to select the best attention mechanism, this paper experimentally compares the current mainstream lightweight attention mechanisms, including TripleAttention, MLCA, iRMB, Acmix, ECA, NAM, SGE, and EMA. The experimental results are shown in Table 4.

[0119] Table 4:

[0120]

[0121]

[0122] The experimental results show that the models under different mechanisms have different performances in terms of parameter quantity, complexity and mean average precision (mAP). Although TripleAttention increases the number of parameters and complexity of the model, its mAP decreases instead, and the effect is not good; MLCA and iRMB are difficult to adapt to real-time detection tasks due to the long training time; although Acmix has increased complexity, its mAP is slightly lower than the baseline model and its performance is average; while the ECA mechanism maintains low complexity and number of parameters, its mAP is slightly lower than the baseline model; SGE and EMA have improved in accuracy, but in the end, the NAM attention mechanism performs best, with a mAP of 0.816, and significantly improves the detection accuracy with almost no increase in the number of parameters and complexity, verifying its effectiveness in distracted driving detection tasks.

[0123] like Figure 3 The figure shows the mAP comparison bar chart of the YOLOv8s model and the YOLOv8s-FPNE model. It can be seen from the figure that the mAP values ​​of the YOLOv8s-FPNE model are improved for distracted driving behaviors such as smoking, using mobile phones, and drinking water.

[0124] like Figure 4 The figure shows the precision (Precision)-recall rate (Recall) curve diagram of the YOLOv8s model and the YOLOv8s-FPNE model, where Figure (a) represents the YOLOv8s model and Figure (b) represents the YOLOv8s-FPNE model. After comparison, it can be seen that the YOLOv8s-FPNE model has higher precision and recall in all categories, especially in the categories of smoking (smoke) and using mobile phones (call), which have increased by 2.3% and 0.6% respectively, and the mAP@0.5 of the total data has also increased to 81.6%, showing the advantages of the YOLOv8s-FPNE model in comprehensive performance. This shows that the FPNE mechanism can effectively improve the detection ability of the model in complex scenarios.

Claims

1. A lightweight distracted driving detection method, characterized in that: The method comprises the following steps: S1. Data collection and division: Collect distracted driving behavior images and divide them into training set, validation set and test set; S2. Construction of distracted driving detection model, specifically: A hierarchical improvement mechanism is used to improve the existing YOLOv8s model framework. The hierarchical improvement mechanism is specifically as follows: First layer: Reduce the number of parameters and complexity by replacing modules in the model's trunk, neck, and detection head; The second layer: improves detection accuracy by adding modules in the part connected to the model detection head; The third layer: improve detection accuracy by adding attention mechanism; The fourth layer: improve the detection accuracy by improving the loss function; S3. Distracted driving detection model training: The distracted driving detection model is trained through the training set and the validation set, and the training results are tested through the test set to obtain a distracted driving detection model that can be applied; S4. Use an applicable distracted driving detection model to detect driving behavior.

2. The distracted driving detection method according to claim 1, characterized in that: The replacement of modules in the trunk, neck and detection head parts of the model is specifically: replacing the C2f module in the trunk, neck and detection head parts of the YOLOv8s model with the FasterNet module.

3. The distracted driving detection method according to claim 2, characterized in that: The specific steps of adding modules to the part connected with the model detection head are as follows: The neck part of the YOLOv8s model includes two paths, one is a path connected to the trunk part, and the other is a path connected to the detection head part. A PConv module is added to the path connected to the detection head part, and the position where the PConv module is added is before the last FasterNet module of the path.

4. The distracted driving detection method according to claim 1, characterized in that: The addition of the attention mechanism is specifically as follows: adding a NAM attention mechanism module after the SFFP module in the Backbone part of the YOLOv8s model.

5. The distracted driving detection method according to claim 1, characterized in that: The improvement of the loss function is specifically: changing the loss function from CIoU to Focal-EIoU.

6. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 5 are implemented.

7. A computer-readable storage medium for storing computer instructions, characterized in that: When the computer instructions are executed by a processor, the steps of the method according to any one of claims 1 to 5 are implemented.