Electric vehicle helmet detection method and system based on improved YOLOv8 algorithm
By improving the YOLOv8 algorithm, a diversity data set was constructed and the Simplified BiFPN structure and SIoU loss function were introduced, which solved the problem of poor robustness of electric vehicle helmet detection in complex environments, significantly improving detection accuracy and efficiency.
Patent Information
- Application Number
- CN202411274698.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-12
- Publication Date
- 2024-12-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
The existing electric vehicle helmet detection based on the YOLO series algorithm is poorly robust in complex environments and dense target scenarios, resulting in frequent false detection and missed detection, which is difficult to meet the practical application needs.
Using the improved YOLOv8 algorithm, by constructing diversity data sets, designing Simplified BiFPN structures and SIoU loss functions, feature extraction and prediction capabilities are enhanced and detection accuracy is improved.
It significantly improves the accuracy and real-timeness of electric vehicle helmet inspection, reduces false detection and missed detection, and improves the detection accuracy and efficiency of the model.
Smart Images

Figure CN119131556A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of target detection, and in particular to an electric vehicle helmet detection method and system based on an improved YOLOv8 algorithm. Background Art
[0002] With the rapid development of the economy and the expansion and construction of road traffic, flexible and convenient electric vehicles have become one of the main means of transportation for the masses. However, while enjoying the convenience of travel, people often suffer serious safety accidents due to not wearing safety helmets. According to statistics, about 80% of the deaths of motorcycle and electric vehicle drivers and passengers are caused by craniocerebral injuries. The correct wearing of safety helmets can greatly reduce the risk of death and injury in traffic accidents, and plays an important role in protecting the lives and safety of the masses. Therefore, since April 2020, the traffic management department has begun to carry out the "one helmet and one belt" safety protection action across the country, and legally investigate and correct unsafe behaviors such as motorcycle and electric bicycle riders not wearing safety helmets, and help the people develop safe habits. However, in the face of a large group of electric vehicle users, the current supervision method is still mainly based on daily patrols by traffic police, which consumes a lot of police force and is inefficient.
[0003] Automatically identifying the wearing of helmets by electric vehicle drivers and passengers through target detection algorithms can save labor costs and improve the efficiency of traffic department law enforcement management. Target detection based on deep learning can be divided into "two-stage detection" based on candidate regions and "one-stage detection" based on regression ideas. Among them, the YOLO algorithm, which belongs to the "one-stage detection" algorithm, gradually absorbed the architecture of the "two-stage detection" algorithm during its development and continuously optimized its own algorithm module. Since YOLOv5, it has achieved a suitable balance between detection accuracy and detection speed, which is better than most other target detection algorithms. Although there have been some studies in the prior art that use the YOLO series of algorithms to detect electric vehicle helmets, the relevant studies are designed for data sets of specific application scenarios, and the robustness is poor when used in migration, and the accuracy is not high when detecting small targets. In actual application scenarios, complex and changeable environmental backgrounds, overlapping dense targets, and various head-worn objects similar to helmets are prone to cause a large number of missed detections and false detections, which increases the difficulty of detection and puts higher requirements on the feature expression ability of the algorithm. Summary of the invention
[0004] In order to solve the technical problem that the electric vehicle helmet detection based on the YOLO series algorithm in the prior art has poor robustness and is difficult to cope with complex environments, the electric vehicle helmet detection system based on the improved YOLOv8 algorithm proposed in the present invention includes a detection data acquisition module, a training data construction module, a data preprocessing module and a detection module, wherein the training data construction module, the data preprocessing module and the detection module are connected in sequence, and the detection data acquisition module is connected to the detection module;
[0005] The training data construction module is used to construct a data set of an electric vehicle helmet detection model;
[0006] The data preprocessing module is used to preprocess the data set;
[0007] The detection data acquisition module is used to acquire real-time detection images, and perform resolution processing and data enhancement on the detection images;
[0008] The functions of the detection module include: 1) training the electric vehicle helmet detection model based on the data set from the data preprocessing module; 2) inputting the real-time detection image into the electric vehicle helmet detection model to obtain the detection result.
[0009] Preferably, the sources of the data set include: 1) obtained from web pages through web crawlers; 2) obtained through on-site photography at street intersections, and the data set includes diverse samples involving different scenes, different weather conditions, different shooting angles, different electric vehicle target sizes and different electric vehicle densities. The scenes include traffic intersections, streets and alleys, and community gates. The weather conditions include sunny, rainy, foggy and snowy days. The shooting angles include front, side, back and overhead views.
[0010] Preferably, the specific process of the preprocessing is to first classify the images in the data set according to the detection categories, then manually select, process the resolution, enhance the data and screen the images, and finally label the detection targets in the data set. The detection categories are set to electric vehicles and helmets. Other situations similar to the recognition targets are not labeled as separate categories, but are directly used as background negative samples for training.
[0011] Preferably, the electric vehicle helmet detection model is improved based on YOLOv8n, including an input end Input, a feature extraction network Backbone, a feature fusion network Neck and a prediction end Head.
[0012] Preferably, the feature extraction network Backbone fine-tunes the number of channels according to the model scale based on different scaling factors, segments the feature map and fuses it across stages by stacking multiple Conv modules and C2f modules, and then connects an SPPF module to aggregate global information through pooling operations of different scales, and finally generates three feature maps P3, P4 and P5, which are used to detect small, medium and large objects in the picture, respectively.
[0013] Preferably, the feature fusion network Neck adopts a Simplified BiFPN structure, and the mathematical expression of the Simplified BiFPN structure is as follows:
[0014]
[0015] Among them, P3, P4 and P5 are three feature graphs generated by the feature extraction network Backbone. As three input nodes, Pi in is the input of the current feature layer, Pi td is the middle fusion layer, Pi out is the output after feature extraction enhancement, Conv is the convolution operation, Resize is the upsampling or downsampling operation, and w i is the weight of each path, and ε is a parameter set to prevent numerical instability, with a value of 0.0001.
[0016] Preferably, the prediction end Head receives three feature maps obtained after feature fusion from the feature fusion network Neck, performs final classification and boundary regression positioning to determine the category and position of the detection target, continuously optimizes parameters by minimizing the loss function, and adopts SIoU as the loss function. The SIoU consists of four parts: angle loss, distance loss, shape loss and IoU loss.
[0017] Preferably, the angle loss is defined as follows:
[0018]
[0019] Among them, B and B gt Represent the center points of the predicted box and the real box respectively, C h and C w are the height difference and width difference of the two center points, σ is the Euclidean distance between the two center points, is the angle α, when B and B gt When aligned on the x-axis or y-axis, Λ=0; when α=45°, Λ=1;
[0020] Based on the angle loss, the distance loss is defined as follows:
[0021]
[0022]
[0023] Among them, D h and D w They are the height and width of the minimum bounding rectangle that contains both the predicted box and the true box.
[0024] Preferably, the shape loss is defined as follows:
[0025]
[0026] Among them, w gt and h gtis the width and height of the real box, w and h are the width and height of the predicted box, and θ is used to control the proportion of shape loss in the total loss function.
[0027] The electric vehicle helmet detection method based on the above electric vehicle helmet detection system specifically includes the following steps:
[0028] S1, build a dataset for electric vehicle helmet detection model;
[0029] S2, preprocessing the data set;
[0030] S3, train the electric vehicle helmet detection model based on the data set;
[0031] S4. Input the real-time detection image into the electric vehicle helmet detection model to obtain the detection result.
[0032] Compared with the prior art, the present invention has the following beneficial effects:
[0033] The electric vehicle helmet detection system uses an electric vehicle helmet detection model based on the improved YOLOv8 algorithm for helmet detection. The electric vehicle helmet detection model introduces the weighted bidirectional fusion idea into the Neck part of the YOLOv8n model, designs the Simplified BiFPN structure, and uses the SIoU loss function to introduce the vector angle between the predicted box and the true box, redefines the penalty indicator, adjusts the direction of the predicted box faster, accelerates the convergence process of the network, and improves the prediction accuracy of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 It is a structural schematic diagram of the electric vehicle helmet detection system of the present invention. DETAILED DESCRIPTION
[0035] The technical solution of the present invention is described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0036] like Figure 1 As shown, the electric vehicle helmet detection system based on the improved YOLOv8 algorithm proposed in the present invention includes a detection data acquisition module, a training data construction module, a data preprocessing module and a detection module. The training data construction module, the data preprocessing module and the detection module are connected in sequence, and the detection data acquisition module is connected to the detection module.
[0037] The training data construction module is used to construct the data set of the electric vehicle helmet detection model. The sources of the data set include: 1) obtained from web pages through web crawlers. The specific process is to use scripts to retrieve keywords (such as electric vehicle riders, electric vehicle helmets, traffic safety helmets, etc.), crawl the image data set, remove the web crawler images with too low resolution, and finally use tools to remove duplicate images in the image data set; 2) obtained through field photography at street intersections. The data set contains a total of 2,885 images, of which 1,778 were screened out by web crawlers and 1,107 were screened out by field photography. The data set includes different scenes such as traffic intersections, streets and alleys, community gates, different weather conditions such as sunny days, rainy days, heavy fog, snow, different shooting angles such as front, side, back and top view, different electric vehicle target sizes and different electric vehicle density, and other diverse samples. .
[0038] The data preprocessing module is used to preprocess the data set. The specific process of preprocessing is to first classify the images in the data set according to the detection category, then manually select the images, process the resolution, enhance the data, and filter the images, and finally label the detection targets in the data set. In order to simultaneously detect the electric vehicle riders and helmet wearing conditions in the images, the detection categories are set to electric vehicles and helmets. To avoid interfering with the training effect, other situations similar to the recognition targets, such as cyclists and baseball caps, are not labeled as separate categories and are directly used as background negative samples for training.
[0039] The detection data acquisition module is used to obtain real-time detection images and perform resolution processing and data enhancement on the detection images.
[0040] The functions of the detection module include: 1) training the electric vehicle helmet detection model based on the data set from the data preprocessing module; 2) inputting the real-time detection image into the electric vehicle helmet detection model to obtain the detection result.
[0041] The electric vehicle helmet detection model is improved based on YOLOv8n. YOLOv8n includes the input end Input, the feature extraction network Backbone, the feature fusion network Neck and the prediction end Head.
[0042] The feature extraction network Backbone is designed with reference to the CSPDarkNet structure. The number of channels is fine-tuned according to the model scale based on different scaling factors. Multiple Conv (Convolution+BatchNormalization+SiLU) modules and C2f modules are stacked to segment feature maps and fuse them across stages. Then, a SPPF (Spatial PyramidPooling-Fast) module is connected to aggregate global information through pooling operations of different scales. Finally, three feature maps P3, P4 and P5 are generated, which are used to detect small, medium and large objects in the image respectively.
[0043] The feature fusion network Neck adopts the Simplified BiFPN structure. The mathematical expression of the Simplified BiFPN structure is as follows:
[0044]
[0045] Among them, P3, P4 and P5 are three feature graphs generated by the feature extraction network Backbone, which serve as three input nodes. in is the input of the current feature layer, Pi td is the middle fusion layer, Pi out is the output after feature extraction enhancement, Conv is the convolution operation, Resize is the upsampling or downsampling operation, and w i is the weight of each path, and ε is a parameter set to prevent numerical instability, with a value of 0.0001.
[0046] From formulas (1)-(4), it can be seen that the Simplified BiFPN structure deletes the nodes with only one input edge in the feature graphs P3 and P5, simplifies the bidirectional network structure without affecting the feature extraction effect, and reduces the computational burden. In addition, an additional edge is added between the original input node and the output node of the feature graph P4 layer, which can introduce more feature information into the fusion process at a lower computational cost, so that the network can more comprehensively utilize multi-scale features and improve the richness of feature extraction. At the same time, a weight is added to each path to strengthen important feature information. The path weight can adjust the contribution of each path according to the feature importance learned during the training process to ensure that important feature information is fully strengthened. Through the above processing, the Simplified BiFPN structure can help the algorithm more comprehensively integrate and utilize multi-scale features, improve feature expression capabilities, and thus better handle complex and changing environmental backgrounds and dense targets, effectively reduce false detections and missed detections, and improve the detection accuracy of the model.
[0047] The prediction end Head receives three feature maps obtained after feature fusion from the feature fusion network Neck, and performs final classification and boundary regression positioning to determine the category and position of the detection target. In this process, the parameters are continuously optimized by minimizing the loss function, so that the target category, coordinates and scale predicted by the model are closer to the true value, thereby improving the detection accuracy and real-time performance of the model. The loss function consists of two parts: class loss and regression loss. The original YOLOv8 algorithm uses CIoU to calculate the loss of the predicted box and the real box. The CIoU loss function relies on the traditional indicators of bounding box regression, and only considers the overlapping area, distance and aspect ratio between the predicted box and the real box, but does not involve the matching direction between the real box and the predicted box. This deficiency will reduce the efficiency of the predicted box approaching the real box and affect the model accuracy. In order to solve this problem, the present invention uses SIoU instead of CIoU. SIoU consists of four parts: angle loss, distance loss, shape loss and IoU loss. The IoU loss adopts the conventional definition, and the definitions of the other three losses are as follows:
[0048] The angle loss is defined as follows:
[0049]
[0050] Among them, B and B gt Represent the center points of the predicted box and the real box respectively, C h and C w are the height difference and width difference of the two center points, σ is the Euclidean distance between the two center points, is the angle α. When B and B gt When aligned on the x-axis or y-axis, Λ=0; when α=45°, Λ=1.
[0051] Based on the above angle loss, the distance loss is redefined as follows:
[0052]
[0053]
[0054] Among them, Dh and Dw are the height and width of the minimum bounding rectangle that contains both the predicted box and the true box.
[0055] The shape loss is defined as follows:
[0056]
[0057] Among them, w gt and h gt is the width and height of the real box, w and h are the width and height of the predicted box, and θ is used to control the proportion of shape loss in the total loss function.
[0058] The final SIoU loss function is as follows:
[0059]
[0060] It can be seen from the above formula that while considering traditional indicators in parallel, the SIoU loss function additionally introduces the vector angle parameter and redefines the penalty indicator. The SIoU loss function evaluates the directional error of the prediction box by calculating the angle between the line connecting the center point of the prediction box and the center point of the real box and the horizontal line. By introducing the vector angle parameter, the SIoU loss function can adjust the direction of the prediction box more quickly while maintaining a high overlap rate, so that it moves toward the real box. Therefore, the SIoU loss function can accelerate the convergence process of the network, help the algorithm obtain more accurate prediction results in a shorter time, and reduce missed detections and false detections when dealing with dense targets and head wear items similar to helmets, thereby improving detection accuracy.
[0061] The experimental platform uses Windows 10 operating system, 32GB memory, Intel(R) Core(TM) i7-9700K CPU, and NVIDIA GeForce RTX 3090 GPU with 16GB video memory. The experiment uses Pytorch as the deep learning framework, the IDE environment is PyCharm2019, CUDA11.6 version, and the programming language is Python3.9.7. The experiment adopts the method of transfer learning, and trains on a self-built data set by loading pre-trained weights. The number of iterations in the training phase is set to 150, and the batch-size is 16. The model uses the automatic mode to determine the parameters of the best "optimizer" during training. The present invention measures the detection of various types of targets by average precision AP (Average-Precision), and evaluates the comprehensive detection performance of the model by the overall average precision mAP (meanAverage Precision). Based on the same experimental conditions, an ablation experiment was carried out, in which category 0 is an electric vehicle rider, category 1 is a helmet worn, and all is the comprehensive detection effect of the two categories. Experimental data show that changing the Neck part of the model to the Simplified BiFPN structure can increase the AP of category 0 and category 1 by 1.26% and 2.94% respectively, and the overall mAP by 2.1%. Using the SIoU loss function can increase the single-category mAP by 1.04% and 2.32% respectively, and the overall mAP by 1.68%. The YOLOv8n-Improved model that combines the two improved methods has improved the AP index for electric vehicle rider recognition by 1.37%, the AP index for helmet recognition by 3.16%, and the overall mAP by 2.27%. The detection accuracy is better than the algorithm that only applies a single improved method.
[0062] The electric vehicle helmet detection method based on the above electric vehicle helmet detection system specifically includes the following steps:
[0063] S1, build a dataset for electric vehicle helmet detection model;
[0064] S2, preprocessing the data set;
[0065] S3, train the electric vehicle helmet detection model based on the data set;
[0066] S4. Input the real-time detection image into the electric vehicle helmet detection model to obtain the detection result.
[0067] The above disclosure is only the preferred embodiment of the present invention, and certainly cannot be used to limit the scope of the present invention. It should be pointed out that for those skilled in the art, any equivalent changes made to the scheme of the present invention without departing from the design structure and principle of the present invention are considered to be within the protection scope of the present invention.
Claims
1. An electric vehicle helmet detection system based on an improved YOLOv8 algorithm, characterized in that ,The electric vehicle helmet detection system includes a detection data acquisition module, a training data construction module, a data preprocessing module and a detection module, the training data construction module, the data preprocessing module and the detection module are connected in sequence, and the detection data acquisition module is connected to the detection module; The training data construction module is used to construct a data set of an electric vehicle helmet detection model; The data preprocessing module is used to preprocess the data set; The detection data acquisition module is used to acquire real-time detection images, and perform resolution processing and data enhancement on the detection images; Functions of the detection module include: 1) training an electric vehicle helmet detection model based on the data set from the data preprocessing module; 2) Input the real-time detection image into the electric vehicle helmet detection model to obtain the detection result.
2. The electric vehicle helmet detection system according to claim 1, characterized in that: The sources of the dataset include: 1) obtained from web pages through web crawlers; 2) obtained through on-site photography at street intersections. The dataset includes diverse samples involving different scenes, different weather conditions, different shooting angles, different electric vehicle target sizes and different electric vehicle densities. The scenes include traffic intersections, street alleys and community gates. The weather conditions include sunny, rainy, foggy and snowy days. The shooting angles include front, side, back and overhead views.
3. The electric vehicle helmet detection system according to claim 1, characterized in that: The specific process of the preprocessing is to first classify the images in the data set according to the detection categories, then manually select, process the resolution, enhance the data, and screen the images, and finally label the detection targets in the data set. The detection categories are set to electric vehicles and helmets. Other situations similar to the recognition targets are not labeled as separate categories and are directly used as background negative samples for training.
4. The electric vehicle helmet detection system according to claim 1, characterized in that: The electric vehicle helmet detection model is improved based on YOLOv8n, including an input end Input, a feature extraction network Backbone, a feature fusion network Neck and a prediction end Head.
5. The electric vehicle helmet detection system according to claim 4, characterized in that: The feature extraction network Backbone fine-tunes the number of channels based on different scaling factors according to the model scale, segments feature maps and fuses them across stages by stacking multiple Conv modules and C2f modules, and then connects an SPPF module to aggregate global information through pooling operations of different scales, and finally generates three feature maps P3, P4 and P5, which are used to detect small, medium and large objects in the picture respectively.
6. The electric vehicle helmet detection system according to claim 5, characterized in that: The feature fusion network Neck adopts the Simplified BiFPN structure, and the mathematical expression of the Simplified BiFPN structure is as follows: Among them, P3, P4 and P5 are three feature graphs generated by the feature extraction network Backbone. As three input nodes, Pi in is the input of the current feature layer, Pi td is the middle fusion layer, Pi out is the output after feature extraction enhancement, Conv is the convolution operation, Resize is the upsampling or downsampling operation, and w i is the weight of each path, and ε is a parameter set to prevent numerical instability, with a value of 0.0001.
7. The electric vehicle helmet detection system according to claim 6, characterized in that: The prediction end Head receives three feature maps obtained after feature fusion from the feature fusion network Neck, performs final classification and boundary regression positioning to determine the category and position of the detection target, continuously optimizes parameters by minimizing the loss function, and adopts SIoU as the loss function. The SIoU consists of four parts: angle loss, distance loss, shape loss and IoU loss.
8. The electric vehicle helmet detection system according to claim 7, characterized in that: The angle loss is defined as follows: Among them, B and B gt Represent the center points of the predicted box and the real box respectively, C h and C w are the height difference and width difference of the two center points, σ is the Euclidean distance between the two center points, is the angle α, when B and B gt When aligned on the x-axis or y-axis, Λ=0; when α=45°, Λ=1; Based on the angle loss, the distance loss is defined as follows: Among them, D h and D w They are the height and width of the minimum bounding rectangle that contains both the predicted box and the true box.
9. The electric vehicle helmet detection system according to claim 7, characterized in that: The shape loss is defined as follows: Among them, w gt and h gt is the width and height of the real box, w and h are the width and height of the predicted box, and θ is used to control the proportion of shape loss in the total loss function.
10. An electric vehicle helmet detection method based on the electric vehicle helmet detection system according to any one of claims 1 to 9, characterized in that ,The electric vehicle helmet detection method specifically includes the following steps: S1, build a dataset for electric vehicle helmet detection model; S2, preprocessing the data set; S3, train the electric vehicle helmet detection model based on the data set; S4. Input the real-time detection image into the electric vehicle helmet detection model to obtain the detection result.
Citation Information
Patent Citations
YOLOv8 target detection method based on attention mechanism and multi-scale feature fusion
CN116883801A
Traffic safety helmet wearing detection system and method based on improved YOLOv5
CN116977948A
Pulmonary nodule image detection method based on YOLOv8
CN117764917A
Large-range remote sensing image nuclear power station target detection method based on improved YOLOv8
CN118429822A
