Driving violation behavior identification system and method based on YOLOv8

By optimizing the YOLOv8n lightweight model and designing a two-stage detection layer, the problems of high false detection rate and large computational load in traditional driving violation recognition schemes under changing lighting and occlusion scenarios are solved, achieving accurate recognition and real-time processing of complex violations.

CN121392802APending Publication Date: 2026-01-23施崇玥
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511512653.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-22
Publication Date
2026-01-23

AI Technical Summary

Technical Problem

In existing technologies, traditional driving violation recognition schemes have high false detection rates under changing lighting conditions and occlusion scenarios, require large amounts of model computation, and fail to effectively identify complex violations, such as the combined judgment of closed eyes and holding a phone, resulting in insufficient recognition accuracy and speed.

Method used

We adopted the YOLOv8n lightweight model and optimized it with INT8 quantization. We designed a two-stage detection layer for face and eye/handheld device recognition. We combined the judgment logic of fatigue driving and distracted driving and optimized the training process to improve the model's generalization ability and recognition accuracy in complex scenarios.

Benefits of technology

It significantly reduces the false detection rate, improves the model's recognition accuracy and speed in complex scenarios, and can effectively identify various driving violations to meet real-time application needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121392802A_ABST
    Figure CN121392802A_ABST
Patent Text Reader

Abstract

The invention discloses a driving violation behavior recognition system and method based on YOLOv8, and relates to the technical field of target detection and recognition, and the system comprises a lightweight model building module which is used for selecting a YOLOv8n lightweight model as a basic framework, carrying out deployment through PyTorch, and carrying out the structure optimization of the YOLOv8n lightweight model; the two-stage detection module is used for designing two-stage detection layers, and the first layer is used for face positioning and outputting face coordinates and confidence; and the second layer carries out eye / handheld device identification based on the first layer coordinate area cutting. By adopting a YOLOv8n lightweight model architecture and combining two-stage detection layer design, the false detection rate can be effectively reduced, in the initial training stage, through small-batch gradient descent optimization and dynamic learning rate adjustment, it is ensured that the model is rapidly converged in a basic scene, data enhancement and mixing precision training are introduced in the fine adjustment stage, and the training efficiency is improved. And the generalization ability of the model in a complex scene is further improved.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of target detection and identification, and particularly relates to a driving violation behavior identification system and method based on YOLOv8. BACKGROUND

[0002] With the acceleration of urbanization and the increase in the number of motor vehicles, traffic safety problems are becoming increasingly serious. Improper behavior of drivers (such as speeding, fatigue driving, running red lights, and reckless lane changing) is an important factor leading to traffic accidents. Moreover, as the awareness of traffic safety improves, the public's tolerance for traffic violations is decreasing, and more and more drivers are beginning to pay attention to their own and others' driving behavior, which promotes the demand for driving behavior monitoring and analysis technology.

[0003] In the prior art, the traditional driving violation behavior identification scheme (such as YOLOv3) has a mis-detection rate of > 30% under light changes and occlusion scenes, and the model calculation amount is too large, with a mobile terminal processing speed of > 1 second / frame. In addition, the identification scene is missing, and complex violation behaviors such as combined judgment of closed eyes + handheld phone are not covered. Therefore, how to design a two-stage detection layer including face positioning and eye / handheld device recognition based on the lightweight model architecture and multi-stage optimization strategy of YOLOv8n to achieve accurate identification of driving violation behaviors is a problem to be solved by the present application. For this reason, the present application proposes a driving violation behavior identification system and method based on YOLOv8. SUMMARY

[0004] The present application aims to provide a driving violation behavior identification system and method based on YOLOv8 to solve the problems raised in the background art.

[0005] To solve the above technical problems, the technical solution adopted by the present application is as follows: In a first aspect, the driving violation behavior identification system based on YOLOv8 comprises: A lightweight model construction module is used to select a YOLOv8n lightweight model as a basic architecture, deploy it through PyTorch, and perform structural optimization on the YOLOv8n lightweight model, including model pruning and INT8 quantization. A two-stage detection module is used to design a two-stage detection layer, wherein the first layer is face positioning, and outputs face coordinates and confidence; the second layer performs eye / handheld device recognition based on the first layer coordinate region cropping, improves the accuracy and efficiency of feature extraction through staged processing, and reduces the mis-detection rate. A violation behavior judgment module is used to identify fatigue driving behavior and distraction driving behavior according to pre-set fatigue driving judgment logic and distraction driving judgment logic, and to classify and mark them, thereby reducing the safety risks caused by misjudgment and improving road traffic safety. The training process optimization module is used for fast function verification using a basic data set in an initial training stage, and data enhancement (rotation ± 15°, Gaussian noise) and mixed precision training are added in a fine adjustment stage, so that the model generalization capability is improved, and the recognition accuracy of the model in a complex scene is significantly improved.

[0006] Further improvement of the technical scheme of the application is that the lightweight model construction module specifically comprises: The YOLOv8n lightweight model is selected as the basic architecture, and is deployed through the PyTorch framework, so as to ensure the compatibility of multiple hardware platforms and efficient operation; The deployed YOLOv8n lightweight model is optimized in structure, and 20% of redundant convolution kernels are removed by using model pruning technology, so as to reduce the calculation amount and the number of parameters; The optimized YOLOv8n lightweight model is subjected to INT8 quantization processing, so as to further compress the model volume, maintain the accuracy, and improve the mobile terminal processing speed to 500 ms / frame.

[0007] Further improvement of the technical scheme of the application is that the two-stage detection module comprises a face positioning detection layer and an eye / handheld device recognition detection layer; The face positioning detection layer is used as the first layer of two-stage detection, is used for positioning a face and outputting face coordinates and confidence, and provides a region range for local feature recognition of the second layer. The eye / handheld device recognition detection layer is used as the second layer of two-stage detection, is used for recognizing eyes and a handheld device based on the coordinate region of the first layer face positioning, and realizes recognition of a composite illegal behavior (such as joint determination of closing eyes and holding a phone).

[0008] Further improvement of the technical scheme of the application is that the face positioning detection layer specifically comprises: The face positioning detection layer receives original camera image data, performs normalization processing, maps pixel values to a standard range, eliminates light and device differences, simultaneously performs noise reduction processing by using Gaussian filtering or mean filtering, and adjusts the image to a resolution size required by the YOLOv8n lightweight model. The preprocessed image data is input into the backbone network of the YOLOv8n lightweight model, multi-layer convolution and residual connection are used to extract multi-scale features, spatial pyramid pooling is used to enhance feature fusion capability, feature fusion is performed by a path aggregation network, and a feature map containing face position information is generated; The detection head predicts face region coordinates and confidence based on an anchor box mechanism, outputs a prediction box with a confidence greater than 0.7, and generates a local face region by cutting the original image according to the coordinates, as the second stage input.

[0009] Further improvement of the technical scheme of the application is that the eye / handheld device recognition and detection layer specifically comprises: The face region cropped image is received, the contrast is enhanced through adaptive histogram equalization, the eye and device edge features are highlighted, the image quality is optimized through dynamic gamma correction according to the illumination condition, and the image is scaled to 224*224 pixels while keeping the key feature geometric integrity; The dual-branch convolution structure based on the improved YOLOv8n lightweight model is used to extract the eye and handheld device features in parallel, wherein the shallow layer convolution focuses on the eyelid movement details, the deep layer convolution captures the device contour semantics, the attention mechanism is introduced to weight the feature channels, the response to the closed eye state and the device type is strengthened, and then the multi-scale features are fused through the feature pyramid network while the low layer details are reserved; The dual detection head outputs the eye state and the handheld device type in parallel, the confidence threshold is 0.8, the composite violation behavior is determined according to the rule of closing eyes and detecting a mobile phone, the joint confidence of taking the minimum value of the two is output, and finally the structured data containing the violation type, the confidence and the timestamp are generated.

[0010] Further improvement of the technical scheme of the application is that the violation behavior judgment module comprises a violation behavior logic formulation unit and a cooperative detection unit; The violation behavior logic formulation unit is used to formulate the judgment logic of the violation behavior according to the actual demand and the business logic, wherein the violation behavior includes fatigue driving and distraction driving, if the closed eyes are detected and the closed eye duration exceeds 2 seconds, the fatigue driving is marked, if the handheld phone is detected and the vehicle speed is greater than 30km / h, the distraction driving is marked, and the accuracy and reliability of the violation behavior recognition are improved; The cooperative detection unit is used to cooperate the formulated judgment logic with the output results of the two-stage detection module, to judge the violation behavior according to the detected face, eye and handheld device features according to the judgment logic, so as to realize the seamless connection of detection and judgment.

[0011] Further improvement of the technical scheme of the application is that the violation behavior logic formulation unit specifically comprises: The business demand in the actual application scene is analyzed, the violation behavior types to be recognized are fatigue driving and distraction driving, the judgment logic framework is constructed based on the business demand, wherein the fatigue driving is judged by the closed eye duration exceeding 2 seconds, and the distraction driving is judged by combining the handheld phone detection with the vehicle speed exceeding 30km / h; After the basic logic framework is constructed, the vehicle driving speed information is acquired in real time through the Gaode map, and is associated with the handheld phone detection result, so as to improve the accuracy and reliability of the violation behavior recognition and reduce the possibility of misjudgment; Verify and optimize the prepared violation behavior judgment logic, test through a large amount of actual driving scene data, evaluate the performance of the judgment logic in different scenes, and adjust and optimize the judgment logic according to the test results, to further improve the accuracy and adaptability of the judgment logic.

[0012] The further improvement of the technical scheme of the application lies in that the cooperative detection unit specifically comprises: The two-stage detection module outputs the face region coordinates, eye state, handheld device type and position of the structured data, the time stamp and coordinate system are unified through a space-time alignment algorithm, and the feature data is normalized, the eye closing time is converted into a frame rate ratio, and the device position is mapped to the face key point coordinate system; Based on the preprocessed feature data, load the preset violation behavior judgment logic, wherein the fatigue driving is counted by a sliding window to count the number of consecutive closed eyes, and the pre-warning is triggered when the threshold is exceeded for more than 2 seconds; the distraction driving is combined with the vehicle speed information and the device usage state, and the violation is determined when the vehicle speed is higher than 30km / h and the handheld phone is detected, the logical combination rule is used to avoid misjudgment, and the confidence score is attached; The multi-rule judgment results are fused, if any violation behavior is established, a standardized event message containing the time stamp, violation type and evidence feature is immediately generated, the zero-copy technology is used to push to the downstream subsystem, the internal judgment state machine is used to record the duration of the violation behavior, and finally the output result is transmitted after being encrypted, so that the data security is guaranteed.

[0013] The further improvement of the technical scheme of the application lies in that the training process optimization module specifically comprises: The samples of standard light, front face and unshielded device are selected from the basic data set, small batch gradient descent optimization is adopted, dynamic learning rate adjustment is used, model convergence is completed within 1-2 training cycles, and training loss and verification set accuracy are monitored, if the preset threshold is not reached, the network architecture is adjusted for rapid iteration verification; Data enhancement and mixed precision training are introduced, TensorCore is used to accelerate matrix operation, memory occupation is reduced, larger batch training is supported, dynamic loss scaling and distributed training are combined to optimize calculation efficiency, and the generalization ability and recognition accuracy of the model in complex scenes are improved; The comprehensive index is calculated on the independent test set, the performance attenuation and the anti-robustness in the edge scene are analyzed, the decision basis is analyzed by using a visualization tool, the attention distribution is optimized, if the evaluation result does not reach the expectation, the enhancement strategy is adjusted in the fine-tuning stage, through the closed-loop iteration, the model meets the deployment requirements of accuracy and delay.

[0014] Secondly, the driving violation recognition method based on YOLOv8, implemented based on the aforementioned driving violation recognition system based on YOLOv8, includes the following steps: S1. The YOLOv8n lightweight model was selected and deployed through the PyTorch framework to ensure compatibility with multiple hardware. Samples with standard lighting, frontal faces and unobstructed devices were selected from the basic dataset. The initial training quickly validated the function. Data augmentation and mixed precision training were introduced in the fine-tuning stage. The model was evaluated in multiple dimensions to meet the deployment requirements. S2. Based on actual needs and business logic, formulate logic for judging violations including fatigued driving and distracted driving; S3. Design a two-stage detection layer. The first layer is for face localization, outputting face coordinates and confidence scores. The second layer is for eye / handheld device recognition based on the coordinate region cropped from the first layer. S4. Combining the two-stage detection layer and the preset violation judgment logic, the violation behavior is classified and marked.

[0015] Due to the adoption of the above technical solution, the technical progress achieved by this invention compared to the prior art is as follows: 1. This invention provides a driving violation recognition system and method based on YOLOv8. By adopting the lightweight YOLOv8n model architecture and combining it with a two-stage detection layer design, the false detection rate can be effectively reduced. In the initial training stage, the model is optimized by mini-batch gradient descent and dynamic learning rate adjustment to ensure that the model converges quickly in basic scenarios. In the fine-tuning stage, data augmentation and mixed precision training are introduced to further improve the model's generalization ability in complex scenarios.

[0016] 2. This invention provides a driving violation recognition system and method based on YOLOv8. The structure of the lightweight YOLOv8n model is optimized through model pruning and INT8 quantization technology. Redundant convolutional kernels are removed and the model volume is compressed, reducing the amount of computation and storage requirements. Among them, mixed precision training utilizes TensorCore to accelerate matrix operations, reduce memory usage, and support larger batch training, which significantly improves the processing speed of the model on mobile devices. This solves the problem of slow processing speed of traditional solutions on mobile devices, ensures that the system can run in real time, and meets the low latency requirements of practical applications.

[0017] 3. This invention provides a driving violation recognition system and method based on YOLOv8. It designs a two-stage detection layer. The first stage performs face localization, and the second stage performs eye and handheld device recognition based on face region cropping. This not only improves the accuracy and efficiency of feature extraction, but also enables joint judgment of complex violations. It makes up for the shortcomings of traditional solutions in identifying scenarios, improves the comprehensiveness and accuracy of violation recognition, and can more effectively identify a variety of driving violations. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this invention. For those skilled in the art, other drawings can be obtained based on these drawings.

[0019] Figure 1 This is a schematic diagram illustrating the workflow of the driving violation recognition system and method based on YOLOv8 of the present invention. Figure 2 This is a schematic diagram of the method flow for the driving violation recognition method based on YOLOv8 of the present invention. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0021] Example 1, as Figure 1 As shown, this invention provides a driving violation recognition system based on YOLOv8, including: The lightweight model building module is used to select the YOLOv8n lightweight model as the basic architecture, deploy it through PyTorch, and optimize the structure of the YOLOv8n lightweight model, including model pruning (removing 20% ​​of redundant convolutional kernels) and INT8 quantization (compressing the model size by 50%). This further reduces the computational and storage requirements of the model while maintaining its accuracy as much as possible, making the model run faster on mobile devices, achieving a processing speed of 500ms / frame. This solves the problem of slow processing speed on mobile devices in traditional solutions. By using the YOLOv8n lightweight model as the basic architecture and deploying it through the PyTorch framework, the module ensures compatibility and efficient operation across multiple hardware platforms. The deployed YOLOv8n lightweight model is structurally optimized by removing 20% ​​of redundant convolutional kernels using model pruning technology to reduce computational load and the number of parameters. The optimized YOLOv8n lightweight model is then subjected to INT8 quantization to further compress the model size, maintain accuracy, and improve the mobile processing speed to 500ms / frame. The specific work of the lightweight model construction module is: selecting a YOLOv8n lightweight model as a basic architecture, significantly reducing the computational complexity and storage requirements of the model while maintaining high detection accuracy, and deploying the YOLOv8n lightweight model through the PyTorch framework, using the efficient computing power and flexible model construction tools of PyTorch to ensure that the YOLOv8n lightweight model runs smoothly on multiple hardware platforms; the deployed YOLOv8n lightweight model is optimized in structure, 20% of redundant convolution kernels are removed using model pruning technology, and the convolution kernels that have less influence on the output of the YOLOv8n lightweight model are removed by analyzing the importance of each convolution kernel in the YOLOv8n lightweight model, thereby reducing the computational load and parameter quantity of the YOLOv8n lightweight model; the optimized YOLOv8n lightweight model is subjected to INT8 quantization processing, converting the weights and activation values of the YOLOv8n lightweight model from floating-point numbers to 8-bit integers, further compressing the volume of the YOLOv8n lightweight model, reducing the storage requirements and computational load of the YOLOv8n lightweight model, while maintaining the accuracy of the YOLOv8n lightweight model; through INT8 quantization, the processing speed of the YOLOv8n lightweight model on the mobile end is significantly improved, which can reach a processing speed of 500ms / frame, and the computational efficiency is greatly improved by reducing the numerical precision, and combined with pruning optimization, the dual defects of insufficient accuracy and speed bottleneck of the traditional scheme are solved; The two-stage detection module is used to design a two-stage detection layer, wherein the first layer is face positioning, and outputs face coordinates and confidence; the second layer performs eye / handheld device recognition based on the first layer coordinate region cropping, through stage-by-stage processing, the accuracy and efficiency of feature extraction are improved, and the false detection rate is reduced, and the two-stage detection module includes a face positioning detection layer and an eye / handheld device recognition detection layer; The face positioning detection layer, as the first layer of the two-stage detection, is used to position the face and output the face coordinates and confidence, providing a regional range for the local feature recognition of the second layer. The face positioning detection layer receives the original image data of the camera, performs normalization processing to map the pixel values to a standard range, eliminating light and device differences. At the same time, Gaussian filtering or mean filtering is used for noise reduction processing, and the image is adjusted to the resolution size required by the YOLOv8n lightweight model. The preprocessed image data is input into the backbone network of the YOLOv8n lightweight model, multi-layer convolution and residual connection are used to extract multi-scale features, spatial pyramid pooling is used to enhance feature fusion capability, and feature fusion is performed by path aggregation network to generate a feature map containing face position information. The detection head predicts face region coordinates and confidence based on the anchor box mechanism, outputs the predicted box with a confidence of >0.7, and crops the original image to generate a local face region as the input of the second stage according to the coordinates; The specific working content of the face positioning detection layer is: receiving original image data from the camera through the face positioning detection layer, mapping the pixel value to the [0, 1] standard range through normalization processing to eliminate the influence of light and device differences, at the same time, using Gaussian filtering or mean filtering to reduce the positioning error caused by image quality, adjusting the preprocessed image data to the resolution size (640x640 pixels) required by the YOLOv8n lightweight model input to ensure the feature extraction efficiency of subsequent convolution operations; input the preprocessed image data into the backbone network of the YOLOv8n lightweight model, extract multi-scale features through multi-layer convolution and residual connection, the feature map is enhanced through spatial pyramid pooling (SPP) to enhance the fusion ability of local and global features, and then the feature fusion is performed through the path aggregation network (PAN) to generate a feature map containing face position information, wherein the detection head predicts the coordinates (x, y, w, h) and confidence score of the face region based on the anchor box mechanism, and the confidence score reflects the probability that the current region contains a face; the face positioning detection layer outputs the predicted box with a confidence score exceeding a threshold (0.7) as the face positioning result, including the face center coordinates, width and height, and confidence value, at the same time, the original image data is dynamically regionally cropped according to the output face coordinates to generate a local image containing only the face region, and then the cropped image data is input into the second stage (eye / handheld device recognition) to significantly reduce the computational amount of subsequent processing and improve the accuracy of local feature recognition; The eye / handheld device recognition detection layer, as the second layer of two-stage detection, performs cropping based on the coordinate region of the first layer face positioning, recognizes the eye and handheld device, realizes the recognition of composite violation behaviors (such as joint judgment of closed eyes + handheld phone), makes up for the defects of traditional schemes that do not cover composite violation behaviors, improves the comprehensiveness and accuracy of violation behavior recognition, receives the face region cropped image, enhances the contrast through adaptive histogram equalization, highlights the edge features of the eye and device, dynamically gamma correction optimizes the image quality according to the lighting conditions, scales to 224x224 pixels while keeping the key feature geometric integrity, parallel extracts eye and handheld device features based on the improved double-branch convolution structure of the YOLOv8n lightweight model, wherein the shallow convolution pays attention to the eyelid movement details, the deep convolution captures the device contour semantics, the attention mechanism is introduced to weight the feature channels, and the response to closed eyes and device types is strengthened, and then the multi-scale features are fused through the feature pyramid network and the low-level details are preserved, the double detection heads output the eye state and handheld device type in parallel, the confidence threshold is 0.8, the composite violation behavior is judged according to the rule of closed eyes and detected mobile phone, and the joint confidence value is output by taking the minimum value, and finally the structured data containing the violation type, confidence and timestamp is generated; The specific functions of the eye / handheld device recognition and detection layer are as follows: The eye / handheld device recognition and detection layer receives a cropped image of the face region output from the face localization and detection layer as input. It enhances local contrast through adaptive histogram equalization, highlighting the eye contour and edge features of the handheld device. For different lighting conditions (strong light, backlight), dynamic gamma correction (γ=0.5~1.5) is used to further optimize image quality and ensure the stability of feature extraction. The input image is then uniformly scaled to 224×224 pixels, and bicubic interpolation is used to maintain the geometric integrity of key features (such as eyelid closure and device screen reflection). Based on an improved lightweight YOLOv8n model backbone network, it extracts eye features (shallow convolutions focus on eyelid movement details) and handheld device features in parallel through a dual-branch convolutional structure. The system utilizes deep convolution to capture device contour semantics, introduces an attention mechanism to dynamically weight feature channels, and enhances the response to key features of closed-eye state (eyelid coverage > 80%) and device type (mobile phone / tablet). It also employs a Feature Pyramid Network (FPN) to fuse multi-scale features, addressing the detection of small targets (long-distance handheld devices). Simultaneously, residual connections preserve low-level detail information, improving the accuracy of composite behavior determination. The system outputs eye state (open / closed) and handheld device type (none / mobile phone / other) in parallel through dual detectors, with a confidence threshold of 0.8 for both. Composite violation behavior determination is achieved based on logic and rules (closed eyes and detected mobile phone), and the joint confidence score (the minimum of the two scores) is output. Finally, structured data containing violation type, confidence score, and timestamp is output. The violation judgment module is used to identify and classify fatigued driving behavior and distracted driving behavior according to the pre-set fatigued driving judgment logic and distracted driving judgment logic, thereby reducing the safety risks caused by misjudgment and improving road traffic safety. The training process optimization module is used to perform rapid functional verification using the basic dataset during the initial training phase, and to add data augmentation (rotation ±15°, Gaussian noise) and mixed precision training during the fine-tuning phase to improve the model's generalization ability and significantly improve the model's recognition accuracy in complex scenes.

[0022] Example 2, as Figure 1 As shown, based on Embodiment 1, the present invention provides a technical solution: the violation behavior determination module includes a violation behavior logic formulation unit and a collaborative detection unit; The rule violation logic formulation unit is configured to formulate a rule violation judgment logic according to actual requirements and business logic, wherein the rule violation includes fatigue driving and distraction driving, and if the closed-eye state is detected and the closed-eye duration exceeds 2 seconds, the fatigue driving is marked; in association with the Gaode map data, if the handheld phone is detected and the vehicle speed is greater than 30 km / h, the distraction driving is marked, so as to improve the accuracy and reliability of the rule violation identification, analyze the business requirements in the actual application scenarios, and determine that the rule violation types to be identified are fatigue driving and distraction driving, construct a judgment logic framework based on the business requirements, wherein the fatigue driving is determined based on the closed-eye duration exceeding 2 seconds; the distraction driving is determined based on the handheld phone detection and the vehicle speed exceeding 30 km / h, after the basic logic framework is constructed, the vehicle speed information is acquired in real time by accessing the Gaode map, and is associated with the handheld phone detection result, so as to improve the accuracy and reliability of the rule violation identification and reduce the possibility of misjudgment, the formulated rule violation judgment logic is verified and optimized, a large amount of actual driving scene data is tested to evaluate the performance of the judgment logic in different scenarios, and the judgment logic is adjusted and optimized according to the test result, so as to further improve the accuracy and adaptability of the judgment logic; The rule violation logic formulation unit is configured to formulate a rule violation judgment logic according to actual requirements and business logic, wherein the rule violation includes fatigue driving and distraction driving, and if the closed-eye state is detected and the closed-eye duration exceeds 2 seconds, the fatigue driving is marked; in association with the Gaode map data, if the handheld phone is detected and the vehicle speed is greater than 30 km / h, the distraction driving is marked, so as to improve the accuracy and reliability of the rule violation identification, analyze the business requirements in the actual application scenarios, and determine that the rule violation types to be identified are fatigue driving and distraction driving, construct a judgment logic framework based on the business requirements, wherein the fatigue driving is determined based on the closed-eye duration exceeding 2 seconds; the distraction driving is determined based on the handheld phone detection and the vehicle speed exceeding 30 km / h, after the basic logic framework is constructed, the vehicle speed information is acquired in real time by accessing the Gaode map, and is associated with the handheld phone detection result, so as to improve the accuracy and reliability of the rule violation identification and reduce the possibility of misjudgment, the formulated rule violation judgment logic is verified and optimized, a large amount of actual driving scene data is tested to evaluate the performance of the judgment logic in different scenarios, and the judgment logic is adjusted and optimized according to the test result, so as to further improve the accuracy and adaptability of the judgment logic; The cooperative detection unit is used for cooperation of the prepared judgment logic and the output results of the two-stage detection module, judgment of the violation behavior according to the detected face, eye and handheld device features, seamless connection of the detection and the judgment, accurate judgment immediately after the detection of the violation behavior, improvement of the real-time performance and the practicability of the system, receiving the structured data of the face region coordinates, the eye state, the handheld device type and the position output by the two-stage detection module, unifying the time stamp and the coordinate system through the space-time alignment algorithm, and normalizing the feature data, converting the eye closing time length into the frame rate proportion, mapping the device position to the face key point coordinate system, loading the preset violation behavior judgment logic based on the preprocessed feature data, wherein the fatigue driving is triggered for warning by the sliding window statistics of the continuous eye closing frame number exceeding the threshold of 2 seconds, the distraction driving is judged as the violation when the vehicle speed is higher than 30km / h and the handheld phone is detected, the logical combination rule is adopted to avoid misjudgment, the confidence score is attached to the judgment result, the multi-rule judgment results are fused, if any violation behavior is established, the standardized event message containing the time stamp, the violation type and the evidence feature is immediately generated, the zero-copy technology is used to push the result to the downstream subsystem, the judgment state machine is internally maintained to record the duration of the violation behavior, and finally the output result is transmitted after the lightweight encryption, so that the data security is guaranteed; The specific working content of the cooperative detection unit is as follows: receiving the output results of the two-stage detection module, including the structured data of the face region coordinates, the eye state (open eyes / closed eyes), the handheld device type and the position, unifying the output results of different detection heads to the same time stamp and coordinate system through the space-time alignment algorithm, eliminating the data misplacement caused by the sampling frequency difference or the detection delay of sensors, simultaneously, normalizing the feature data, converting the eye closing time length into the frame rate proportion, mapping the device position to the face key point coordinate system, and ensuring the consistency of the input of the subsequent judgment logic; based on the preprocessed feature data, the cooperative detection unit loads the preset violation behavior judgment logic, for fatigue driving, the continuous eye closing frame number is counted through the sliding window, if the threshold of 2 seconds is exceeded, the warning is triggered; for distraction driving, the vehicle speed information and the device use state are combined, when the vehicle speed is higher than 30km / h and the handheld phone is detected, the violation is judged, the logical OR and the logical AND combination rule is adopted in the judgment process, the multi-condition strict matching is ensured, the single feature misjudgment is avoided, and the confidence score is attached to the judgment result; the multi-rule judgment results are fused, if any violation behavior judgment is established, the standardized event message containing the time stamp, the violation type and the evidence feature (eye closing frame sequence, device position screenshot) is immediately generated, the result is pushed to the downstream subsystem (warning response, message generation, etc.) through the zero-copy technology, the end-to-end delay is ensured to be lower than 200ms, simultaneously, the judgment state machine is internally maintained to record the duration of the current violation behavior, finally the output result is transmitted after the lightweight encryption, and the data security is guaranteed. The training process optimization module specifically includes: The samples of standard light, frontal face and unobstructed device are screened from the basic data set, small batch gradient descent optimization is adopted, dynamic learning rate adjustment is matched, model convergence is completed within 1-2 training cycles, training loss and verification set accuracy are monitored, if the preset threshold is not reached, the network architecture is adjusted for rapid iteration verification, data enhancement and mixed precision training are introduced, TensorCore is used to accelerate matrix operation, memory occupation is reduced, larger batch training is supported, dynamic loss scaling and distributed training are combined to optimize calculation efficiency, the generalization ability and recognition accuracy of the model in complex scenes are improved, the comprehensive index is calculated on the independent test set, the performance degradation and anti-robustness in the edge scene are analyzed, the decision basis is analyzed by combining the visualization tool, the attention distribution is optimized, if the evaluation result does not meet the expectation, the enhancement strategy is adjusted in the fine tuning stage, through the closed loop iteration, the model meets the deployment requirements of accuracy and delay; The specific work of the training process optimization module is as follows: in the initial training stage, samples covering basic scenes (standard light, front face and unobstructed device) are selected from the basic data set to ensure balanced data distribution and reliable annotation quality. Mini-batch gradient descent (Mini-batch SGD) optimization is adopted, combined with dynamic learning rate adjustment (such as Warmup+CosineDecay), to complete model convergence in 1-2 training cycles. The convergence trend of training loss and validation set accuracy is monitored. If the model cannot reach the preset threshold (classification task F1≥0.85) under the basic scene, the network depth or feature fusion strategy is adjusted. Through rapid iteration verification, the model development cycle is shortened, and excessive computing resources are avoided in invalid architecture. The basic data set refers to the data set used in the initial training stage of the model, which contains data samples with basic scene coverage, function rapid verification and data balance. Basic scene coverage selects samples under standard light conditions, front face angles, and unobstructed devices (handheld phones) to ensure balanced data distribution and reliable annotation quality. Function rapid verification completes model convergence in 1-2 training cycles through small batch gradient descent and dynamic learning rate adjustment to verify whether the basic function meets the standard. Data balance includes driver samples of different genders, ages, and expressions to avoid insufficient recognition ability of the model for specific groups due to data bias. In the fine-tuning stage, the model generalization ability is improved through data augmentation and mixed precision training. In terms of data augmentation, geometric transformation (rotation ±15°, random scaling 0.8-1.2 times) and noise injection (Gaussian noise σ=0.05, salt and pepper noise density 0.02), simulate the light changes and shielding interference in the real environment, use mixed precision training to accelerate matrix operation with TensorCore, reduce GPU memory usage by 30%-50% while maintaining model accuracy, support larger batch size training (BatchSize increased by 2-4 times), prevent gradient underflow through dynamic loss scaling (DynamicLossScaling), and further optimize computing efficiency through distributed training (DataParallelism). Through enhanced data diversity and computational optimization, the recognition accuracy of the model in complex scenarios is improved by 5%-12%; After fine-tuning training, the actual effect of the model is verified through multi-dimensional evaluation, and the comprehensive index (mAP, ROC-AUC) is calculated on the independent test set. The performance degradation of the model in edge scenarios (low light, side face, and partial device occlusion) is analyzed, and the adversarial sample test (FGSM attack) is introduced to evaluate the robustness of the model. The model is enhanced for samples vulnerable to attack, and the Grad-CAM visualization tool is used to analyze the model's decision basis and optimize the attention distribution of the feature extraction layer. If the evaluation result does not meet the expectation, the model is returned to the fine-tuning stage to adjust the enhancement strategy (increase motion blur and color jitter), and through closed-loop iteration, the model meets the deployment requirements of accuracy ≥ 90% and inference delay < 50ms in complex scenarios.

[0023] As shown in Embodiment 3, Figure 1 、 Figure 2 Based on Embodiments 1-2, the application further provides a driving violation behavior recognition method based on YOLOv8, which is realized based on the above-mentioned driving violation behavior recognition system based on YOLOv8 and includes the following steps: S1, a YOLOv8n lightweight model is selected, which is deployed through a PyTorch framework to ensure multi-hardware compatibility, and samples with standard light, frontal face, and unoccluded device are selected from a basic data set. The function is verified quickly in the initial training, and data enhancement and mixed precision training are introduced in the fine-tuning stage. Through multi-dimensional evaluation, the model meets the deployment requirements; S2, according to actual requirements and business logic, a violation behavior judgment logic including fatigue driving and distraction driving is formulated; S3, a two-stage detection layer is designed, the first layer is face positioning, and the second layer is eye / handheld device recognition based on the first layer coordinate region clipping; S4, combined with the two-stage detection layer and the preset violation behavior judgment logic, the violation behavior is classified and labeled.

[0024] The above merely provides the specific implementation of the present application, but the protection scope of the present application is not limited to this. Any person skilled in the art can easily think of the changes or replacements within the technical range disclosed by the present application, which should be covered in the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A driving violation behavior recognition system based on YOLOv8, characterized in that, The method comprises the following steps: a lightweight model construction module is used to select a YOLOv8n lightweight model as a basic architecture, deploy the model through a PyTorch framework, and optimize the structure of the YOLOv8n lightweight model; a two-stage detection module is used to design a two-stage detection layer, wherein the first layer is used for face positioning and outputs face coordinates and confidence; and the second layer is used for eye / handheld device recognition based on the coordinate region clipping of the first layer; a violation behavior judgment module is used to identify fatigue driving behavior and distraction driving behavior according to pre-set fatigue driving judgment logic and distraction driving judgment logic, and classify and mark the behaviors; a training process optimization module is used to use a basic data set for rapid function verification in an initial training stage, increase data enhancement and mixed precision training in a fine-tuning stage, and improve the generalization ability of the model.

2. The YOLOv8-based driving violation behavior identification system according to claim 1, characterized in that: The lightweight model construction module specifically comprises the following steps: a YOLOv8n lightweight model is selected as a basic architecture, and the model is deployed through a PyTorch framework; the deployed YOLOv8n lightweight model is optimized in structure, and 20% of redundant convolution kernels are removed through model pruning technology; the optimized YOLOv8n lightweight model is subjected to INT8 quantization processing, and the model volume is further compressed.

3. The YOLOv8-based driving violation behavior identification system according to claim 1, wherein: The two-stage detection module comprises a face positioning detection layer and an eye / handheld device recognition detection layer. The face positioning detection layer, as the first layer of the two-stage detection, is used for positioning a face and outputting face coordinates and confidence. The eye / handheld device recognition detection layer, as the second layer of the two-stage detection, is used for recognizing eyes and handheld devices based on the coordinate region clipping of the first layer face positioning, and realizing the recognition of composite violation behaviors.

4. The YOLOv8-based driving violation behavior identification system according to claim 3, characterized in that: The face positioning detection layer specifically comprises the following steps: The face positioning detection layer receives camera original image data, performs normalization processing to map pixel values to a standard range, performs noise reduction processing, and adjusts the image to a resolution size required by the YOLOv8n lightweight model. The preprocessed image data is input into the backbone network of the YOLOv8n lightweight model, multi-scale features are extracted through multiple layers of convolution and residual connection, and feature fusion is performed through a path aggregation network to generate a feature map containing face position information. The detection head predicts face region coordinates and confidence based on an anchor box mechanism, outputs a prediction box with a confidence of >0.7, and generates a local face region by clipping the original image according to the coordinates.

5. The YOLOv8-based driving violation behavior identification system according to claim 3, characterized in that: The eye / handheld device recognition detection layer specifically comprises the following steps: The face region clipped image is received, the contrast is enhanced through adaptive histogram equalization to highlight the edge features of eyes and devices, the image quality is dynamically gamma corrected and optimized according to the lighting conditions, and the image is scaled to 224x224 pixels. The eye / handheld device features are extracted in parallel based on the double-branch convolution structure of the improved YOLOv8n lightweight model, wherein the shallow convolution focuses on the eyelid movement details, the deep convolution captures the device contour semantics, the attention mechanism is introduced to weight the feature channels, and the responses to the closed eye state and the device type are strengthened. The two detection heads output eye state and handheld device type in parallel, the confidence threshold is 0.8, the composite violation behavior is determined according to the rule of closing eyes and detecting a mobile phone, the joint confidence of taking the minimum value of the two is output, and finally the structured data containing the violation type, confidence and timestamp are generated.

6. The YOLOv8-based driving violation behavior identification system of claim 3, wherein: The violation behavior judgment module comprises a violation behavior logic formulation unit and a cooperative detection unit; The violation behavior logic formulation unit is configured to formulate the judgment logic of the violation behavior according to the actual demand and the business logic, wherein the violation behavior comprises fatigue driving and distraction driving, if the closing eyes are detected and the closing eyes duration exceeds 2 seconds, the fatigue driving is marked; if the handheld phone is detected and the vehicle speed is greater than 30km / h, the distraction driving is marked; and the cooperative detection unit is configured to cooperate the formulated judgment logic with the output result of the two-stage detection module, and judge the violation behavior according to the detected face, eye and handheld device features according to the judgment logic. The violation behavior logic formulation unit specifically comprises:

7. The YOLOv8-based driving violation behavior identification system according to claim 6, characterized in that: The business demand in the actual application scene is analyzed, the violation behavior types to be identified are fatigue driving and distraction driving, the judgment logic framework is constructed based on the business demand, wherein the fatigue driving is judged by the closing eyes duration exceeding 2 seconds; the distraction driving is judged by combining the handheld phone detection with the vehicle speed exceeding 30km / h; After the basic logic framework is constructed, the vehicle driving speed information is acquired in real time by accessing the Gaode map, and is associated with the handheld phone detection result; The formulated violation behavior judgment logic is verified and optimized, a large amount of actual driving scene data is tested, the performance of the judgment logic in different scenes is evaluated, and the judgment logic is adjusted and optimized according to the test result. The cooperative detection unit specifically comprises:

8. The YOLOv8-based driving violation behavior identification system of claim 6, wherein: The structured data of the face region coordinates, eye state, handheld device type and position output by the two-stage detection module is received, the timestamp and coordinate system are unified by a space-time alignment algorithm, and the feature data is normalized, the eye closing duration is converted into a frame rate proportion, and the device position is mapped to the face key point coordinate system; Based on the preprocessed feature data, the preset violation behavior judgment logic is loaded, wherein the fatigue driving is triggered by the sliding window statistics of the continuous closing eyes frame number, and the warning is triggered when the threshold value exceeds 2 seconds; the distraction driving is combined with the vehicle speed information and the device use state, and the violation is judged when the vehicle speed is higher than 30km / h and the handheld phone is detected, the logic combination rule is adopted to avoid misjudgment, and the confidence score is attached; The multi-rule judgment results are fused, if any violation behavior is established, the standardized event message containing the timestamp, violation type and evidence feature is immediately generated, is pushed to the downstream subsystem through zero-copy technology, the judgment state machine is maintained internally to record the violation behavior duration, and finally the output result is transmitted after being lightly encrypted. The training process optimization module specifically comprises:

9. The YOLOv8-based driving violation behavior identification system according to claim 1, characterized in that: ​ Filter samples of standard light, frontal face, and unobstructed device from the basic dataset, use small-batch gradient descent optimization, and adjust the dynamic learning rate. Complete model convergence in 1-2 training cycles, and monitor training loss and validation set accuracy. If the preset threshold is not met, adjust the network architecture for rapid iteration and verification. Introduce data augmentation and mixed precision training, use TensorCore to accelerate matrix operations, and combine dynamic loss scaling and distributed training to optimize computational efficiency. Calculate comprehensive indicators on an independent test set, analyze performance degradation and adversarial robustness in edge scenarios, use visualization tools to analyze decision-making criteria, optimize attention distribution, and if the evaluation results do not meet expectations, revert to the fine-tuning stage to adjust the enhancement strategy. Through closed-loop iteration, the model meets the deployment requirements for accuracy and latency.

10. A method for identifying driving violations based on YOLOv8, implemented based on the YOLOv8-based driving violation identification system according to any one of claims 1-9, characterized in that, The method comprises the following steps: S1. Select a YOLOv8n lightweight model, deploy it through a PyTorch framework, and filter samples of standard light, frontal face, and unobstructed device from the basic dataset. In the fine-tuning stage, introduce data augmentation and mixed precision training, and through multi-dimensional evaluation, make the model meet the deployment requirements; S2. According to actual requirements and business logic, formulate the logic for judging the violation behaviors including fatigue driving and distraction driving; S3. Design a two-stage detection layer, the first layer is face positioning, and outputs face coordinates and confidence; The second layer is eye / handheld device recognition based on the first layer coordinate region cropping; S4. Combine the two-stage detection layer and the preset violation behavior judgment logic to classify and mark the violation behaviors.