Electric vehicle helmet wearing detection method based on improved YOLOv5s

By improving the YOLOv5s network model, including the GBC3 module, SimAM attention mechanism and WIOU loss function, the error detection and missed detection problems of electric vehicle helmet wear detection in complex scenarios are solved, the detection accuracy and speed are improved, and the complex scenarios are improved Electric vehicle helmet detection capability.

CN118918541APending Publication Date: 2024-11-08WUXI UNIV +1
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410750084.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-12
Publication Date
2024-11-08

AI Technical Summary

Technical Problem

The existing electric vehicle helmet wear detection methods have problems of mis-checking and missed inspection in complex scenarios, especially in complex road environments such as dense vehicles, shading and multiple people in one vehicle, which is difficult to meet the needs of real-time inspection.

Method used

Improve the YOLOv5s network model, improve the C3 module in the backbone network and neck FPN feature fusion layer to the GBC3 module, add SimAM attention mechanism, and replace the CIOU loss function with WIOU loss function to enhance feature extraction and expression capabilities and reduce Information loss improves the accuracy of bounding box regression.

Benefits of technology

In complex scenarios, the accuracy and speed of electric vehicle helmet wear detection are significantly improved, the missed and missed detection situations are reduced, the detection ability of small targets is improved, and the positioning performance of electric vehicle helmets is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118918541A_ABST
    Figure CN118918541A_ABST
Patent Text Reader

Abstract

The invention discloses an electric vehicle helmet wearing detection method based on improved YOLOv5s, and the method comprises the following steps: S1, collecting an electric vehicle helmet wearing data set, and dividing the data set into a training set, a verification set and a test set according to a proportion; s2, C3 modules in the YOLOv5s backbone network and the neck network are improved into GBC3 modules, and an improved YOLOv5s network model is constructed; and S3, training the improved YOLOv5s network model by using the training set, continuously adjusting network structure parameters until a network model meeting conditions is obtained, and storing the model. According to the invention, the detection capability of long-distance small targets in a complex intersection scene is improved, and the positioning performance of targets such as electric vehicle helmets and the like is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of target detection, and in particular to an electric vehicle helmet wearing detection method based on improved YOLOv5s. Background Art

[0002] At present, electric vehicles have become a popular means of transportation for short-distance travel for the general public because of their energy-saving, environmentally friendly, compact size, and fast speed. However, some unsafe driving habits of citizens have caused many traffic accidents, most of which are caused by electric vehicle drivers and passengers not wearing helmets. According to relevant studies, the probability of head injury when not wearing a helmet is 2.5 times that when wearing a helmet, and the incidence of fatal injuries is 1.5 times that when wearing a helmet. Therefore, it is particularly necessary to test the wearing of helmets and reduce the occurrence of related safety accidents.

[0003] With the development of deep learning in recent years, many scholars have applied deep learning-based target detection algorithms to the detection of helmet wearing in the industrial field, which has greatly improved the detection speed and accuracy, and has played a certain role in promoting the safety of workers' lives. Similarly, in order to better protect the safety of electric vehicle drivers and passengers and improve the efficiency of traffic police law enforcement, it is of great practical significance to study the use of deep learning-based target detection algorithms to monitor the helmet wearing of drivers and passengers.

[0004] The target detection algorithm based on deep learning is divided into a two-stage algorithm based on region selection and a one-stage algorithm based on regression according to the difference in the generation of bounding regression boxes. The two-stage algorithms mainly include the R-CNN series, R-FCN and other algorithms, and the one-stage algorithms mainly include the YOLO series, SSD, RetinaNet and other algorithms. The two-stage algorithm usually has a higher detection accuracy, but it introduces additional computational complexity when generating candidate boxes, and the detection real-time performance is low. The one-stage algorithm detects targets directly on the input image, and its detection speed is faster. Due to the high real-time requirements required for helmet wearing detection, most scholars have chosen to improve the one-stage algorithm in recent years to make it more suitable for helmet wearing detection. Zhu Shuo et al. improved the YOLOv5 model, introduced the convolutional attention module CBAM and the target tracking algorithm, improved the detection speed and accuracy of electric vehicle helmet wearing, and can achieve tracking and recognition at the same time. However, this method does not take into account the detection of small targets in actual scenes. To address this problem, Xie Puxuan et al. added an efficient channel attention mechanism ECA and a Bi-FPN module, and used Alpha-CIOU Loss to balance the importance of features at different levels and enhance positioning performance, thereby improving the detection effect of small targets. Lv Zhixuan et al. proposed an improved detection method based on the YOLOX network, adding a branch attention module to the model prediction end, and proposed a new cosine annealing algorithm (CDWR), which reduced the model convergence time and improved the detection ability of small targets. Although the above-mentioned improved algorithm has made certain contributions, the detection performance is still poor. There are still many missed detections and false detections in the detection of electric vehicle helmets, which is difficult to meet the real-time detection requirements in complex road scenes such as a wide variety of vehicles, dense vehicles, occlusions, and multiple people on one vehicle. Summary of the invention

[0005] Purpose of the invention: The purpose of the present invention is to provide an electric vehicle helmet wearing detection method based on improved YOLOv5s, which can improve the detection accuracy and speed under the premise of adding only a few parameters, and improve the problems of false detection and missed detection in complex scenes with occlusion, dense vehicles and multiple people in one vehicle.

[0006] Technical solution: A method for detecting electric vehicle helmet wearing based on improved YOLOv5s, comprising the following steps:

[0007] S1, collects the electric vehicle helmet wearing data set and divides it into training set, validation set and test set according to the proportion;

[0008] S2, improve the C3 module in the YOLOv5s backbone network and the neck network into a GBC3 module, and build an improved YOLOv5s network model;

[0009] S3, use the training set to train the improved YOLOv5s network model, continuously adjust the network structure parameters until a network model that meets the conditions is obtained, and save the model.

[0010] Furthermore, the implementation steps for collecting the electric vehicle helmet wearing data set are as follows:

[0011] S11, select a street traffic intersection on a specific road section, take photos, and use Python to crawl and filter the images of electric bikes with and without helmets; then merge the bicycle riding pictures from the bike helmet dataset, and finally put all the pictures together;

[0012] S12, converting all the obtained images into images with a suffix of jpg;

[0013] S13, when labeling the data set, the situation where the electric vehicle driver and passenger wear a helmet is labeled as helmet, with category 0; secondly, the electric vehicle and the driver and passenger are labeled as motor, with category 1; finally, the situation where no helmet is worn is labeled as head, with category 2; bicycles, bicycle drivers and pedestrians are not labeled; after the labeling is completed, the image is output as an xml file in VOC format and placed in a folder named Annotations, and then the xml file is converted into a txt file using Python code;

[0014] S14, divide the data set into training set, validation set and test set in the ratio of 7:2:1.

[0015] Furthermore, the structure of the improved YOLOv5s network model is as follows: the C3 module in the backbone network and the neck FPN feature fusion layer is improved to a GBC3 module; a parameter-free attention mechanism SimAM is added to the shallow feature extraction of the backbone network and before the prediction head; and the CIOU loss function is replaced by a WIOU loss function with a dynamic non-monotonic focusing mechanism.

[0016] Furthermore, the GBC3 module includes a GBlock module and a recursive gated convolution, and the GBlock module is constructed using a Transformer block, including a multi-layer perceptron and layer normalization; according to the structure in the C3 module, the three standard convolutions in C3 are replaced with recursive gated convolutions, and then the residual module is replaced with N improved GBlock modules;

[0017] The input features are passed through recursive gated convolution. First, they enter a convolution layer to adjust the number of input channels C to twice the original number and obtain a set of p0 and The projection characteristics are shown in the following formula:

[0018]

[0019] Among them, H and W are the height and width of the projected feature, C0 is the number of channels of feature q0, and C n-1 is the feature q n-1 The number of channels, n represents the number of spatial interactions, k represents the kth factorial number, A projection layer that performs channel blending. represents the set of real numbers;

[0020] Then the recursive operation of gated convolution is performed, and the feature q k Enter the depth-separable convolution with a kernel size of 7×7, and then compare the features of each block q0 with the previous block p k The features are multiplied element by element, and then multiplied by the scale factor 1 / α to scale the output to achieve information interaction between the current feature and the adjacent features, and the output feature p is obtained. k+1 :

[0021] p k+1 =f k (q k )⊙d k (p k ) / α,k=0,1,...,n-1

[0022] Among them, f k () represents a set of deep convolutional layer operations, ⊙ represents element-wise multiplication, d k () represents the convolution operation matching different order dimensions, and the scaling factor 1 / α is used for stable training of the network;

[0023] Finally, a convolution of size 1×1 is performed.

[0024] Furthermore, by defining a minimum energy function, the weight of each neuron in the helmet feature map is obtained; the minimum energy function of the neuron in the SimAM attention mechanism The formula is as follows:

[0025]

[0026] in, Represent the mean and variance respectively, λ is the added regularization term, t is the target neuron of the input feature in a single channel, i represents the index in the spatial dimension, and M=H×W is the total number of neurons in the current channel;

[0027] The scaling operator is used for feature refinement, and the final optimized output result As shown below:

[0028]

[0029] Where E represents the neurons in the helmet feature map A set of values, X is the input feature, and ⊙ represents element-by-element multiplication.

[0030] Furthermore, the WIOU loss function adopts the expression of WIOUv1 as follows:

[0031]

[0032]

[0033] in, represents the first loss function of WIOU; It represents the loss function based on IoU intersection and union ratio; is a penalty term that will expand the normal quality anchor box A and B are the coordinates of the center point of the anchor box. mt , B mt is the center point coordinate of the target frame; the superscript * represents the W m and H m Operation separated from the calculation formula; W m , H m is the width and height of the minimum enclosing rectangle;

[0034] The outlier degree of the anchor box of the dynamic non-monotonic focusing mechanism is defined as:

[0035]

[0036] in, is the gradient gain, is an exponentially weighted moving average with momentum m;

[0037] Then, a non-monotonic focusing coefficient τ is constructed with β and applied to the WIOUv1 loss function:

[0038]

[0039] Among them, α and δ are hyperparameters, and β is the outlier degree; Represents the third loss function of WIOU.

[0040] Compared with the prior art, the present invention has the following significant effects:

[0041] 1. The present invention improves the original YOLOv5s network model by improving the C3 module of the backbone network and the neck FPN feature fusion layer into a GBC3 module, thereby improving the network model's ability to extract and express features and enhancing the feature fusion capability, so that the target loses less detail information after multiple layers of convolution;

[0042] 2. The present invention adds the SimAM attention mechanism to the shallow feature extraction of the backbone network, which reduces the information loss in the head area, more accurately captures the detailed information of important targets, and improves the model's ability to detect small targets at long distances in complex intersection scenarios;

[0043] 3. The present invention improves the CIOU loss function into the WIOU loss function, which reduces the influence of low-quality samples in the homemade helmet training data set, makes the bounding box regression more accurate, and improves the positioning performance of targets such as electric vehicle helmets. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 is a flow chart of the present invention;

[0045] Figure 2a This is the GBC3 module structure diagram in the present invention, Figure 2b This is the GBlock module structure diagram. Figure 2c g n Conv module structure diagram;

[0046] Figure 3 is the attention mechanism diagram of the present invention;

[0047] Figure 4 This is the improved YOLOv5s network structure diagram of the present invention;

[0048] Figure 5a This is the PR curve of the YOLOv5s algorithm for electric vehicle helmet wearing detection before the improvement of the present invention;

[0049] Figure 5b This is the PR curve of the improved YOLOv5s algorithm for electric vehicle helmet wearing detection;

[0050] Figure 6a For a scene with multiple people in one car, Figure 6b This is the original YOLOv5s detection image of a scene with multiple people in one car. Figure 6c Improve the model's detection map for scenarios with multiple people in one car;

[0051] Figure 7a For scenes with occlusion, Figure 7b This is the original YOLOv5s detection image of the scene with occlusion. Figure 7c Improve the model’s detection map for scenes with occlusions;

[0052] Figure 8a For scenes with occlusion and dense vehicles, Figure 8b This is the original YOLOv5s detection image of a scene with occlusion and dense vehicles. Figure 8c Improve the model’s detection map for scenes with occlusion and dense traffic;

[0053] Figure 9a For intersection scenes with complex vehicle types and small targets, Figure 9b This is the original YOLOv5s detection image of the intersection scene with complex vehicle types and small targets. Fig.9c Improved detection graph of the model for intersection scenes with complex vehicle types and small objects. DETAILED DESCRIPTION

[0054] The present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.

[0055] like Figure 1 As shown, the present invention provides an electric vehicle helmet wearing detection method based on improved YOLOv5s, comprising the following steps:

[0056] Step 1: Collection of electric vehicle helmet wearing data set;

[0057] First, we took photos near subway stations and some street intersections in Nanjing, and took 2,672 photos in total. We also used Python to crawl images of electric bikes with and without helmets online, and after screening, we had 408 photos. In addition, in order to enrich the road condition background of this dataset, we also merged 122 bicycle riding photos from the bike helmet dataset. Finally, we put all the data together, and there were 3,202 photos in total.

[0058] Secondly, convert all the obtained pictures into pictures with the suffix jpg;

[0059] Then, in order to effectively distinguish between electric vehicles driven by drivers and passengers, electric vehicles not driven by drivers, bicycles driven by riders, and pedestrians, the electric vehicle drivers and passengers wearing helmets will be marked as helmets when annotating the data set, with a category of 0. Secondly, the electric vehicle and the driver are marked as motors, with a category of 1; finally, the situation of not wearing helmets is marked as head, with a category of 2; bicycles, bicycle drivers, and pedestrians are not marked. The dataset annotation tool is Labelimg. After the annotation is completed, the image is output as an xml file in VOC format and placed in a folder named Annotations. Because the label format of the YOLO algorithm is txt, the xml file is converted into a txt file using python code; finally, the training set, validation set, and test set are divided according to the ratio of 7:2:1, with 2242 training sets, 640 validation sets, and 320 test sets.

[0060] Step 2: Improvement of the original YOLOv5s network

[0061] (1) Improve the C3 module of the YOLOv5s backbone network and the neck network to the GBC3 module

[0062] like Figure 4 As shown in Figure 1, the C3 module in the YOLOv5s network structure uses a residual module composed of ordinary convolutions. However, this module fails to fully integrate multi-scale feature information, lacks the ability to achieve high-order spatial interaction, and fails to effectively solve the problems of missed detection and false detection of helmet targets. Therefore, a recursive gated convolution (g n The GBC3 module composed of the GNN Conv) improves the residual structure and standard convolution block in the C3 module to enhance the spatial information interaction of neighboring features and the understanding of contextual semantic information, obtain more detailed information of the target, and improve the model's detection ability for helmet targets.

[0063] like Figure 2a As shown, the GBC3 module is mainly composed of GBlock, g n Conv. Figure 2b As shown in Figure 1, GBlock is constructed using the Transformer block design, including a multi-layer perceptron (MLP) and layer normalization. According to the structure of the original C3 module, the three standard convolutions in C3 are replaced by g n Conv, and then replace the residual module with N improved GBlock modules.

[0064] like Figure 2c As shown, the main part of the GBC3 module is g n Conv, this convolution can achieve long-term interaction with high-order space, and is constructed using standard convolution, linear projection and element multiplication. It has the ability of input adaptive spatial mixing similar to self-attention. The input features are recursively gated convolution. First, they enter a convolution layer to adjust the number of input channels C to twice the original number, and obtain a set of p0 and The projection characteristics are shown in the following formula.

[0065]

[0066] Among them, H and W are the height and width of the projected feature, C0 is the number of channels of feature q0, and C n-1 is the feature q n-1 The number of channels, n represents the number of spatial interactions, k represents the kth factorial number, A projection layer that performs channel blending. Represents a set of real numbers. Then the recursive operation of gated convolution is performed, and the feature q k Enter the depth-separable convolution with a kernel size of 7×7, and then compare the features of each block q0 with the previous block p k The features are multiplied element by element, and then multiplied by a scaling factor of 1 / α to scale the output to achieve information interaction between the current feature and the adjacent features, and the output feature p is obtained.k+1 :

[0067] p k+1 =f k (q k )⊙d k (p k ) / α,k=0,1,...,n-1 (2)

[0068] Among them, f k () represents a set of deep convolutional layer operations, and ⊙ represents element-wise multiplication. k () represents the convolution operation that matches different order dimensions. The scaling factor 1 / α is used for stable training of the network. Finally, a convolution of size 1×1 is performed to keep the number of output and input channels the same.

[0069] (2) Adding SimAM attention mechanism to the shallow feature extraction of the backbone network and before the prediction head

[0070] During the image capture process, due to factors such as imaging conditions and viewing angles, the resolution of the electric vehicle driver's helmet will be reduced, and its pixel ratio is small, which can easily affect the detection effect. At the same time, due to the complex road background, there are many background objects that interfere with the model's recognition of helmet targets. Multiple convolutions will also lead to the loss of target detail information. Therefore, the introduction of the attention mechanism makes the model pay more attention to the head area features of the driver in the image, improves the model's perception of the helmet target, and thus improves the accuracy of the model's detection.

[0071] The existing attention mechanism can only adjust the weight of features in the channel domain or spatial domain, which limits the flexibility of the model in learning attention weights and increases the number of parameters. Therefore, we choose the SimAM attention mechanism that can pay attention to both the channel and spatial domains and obtain 3-D weights, such as Figure 3 As shown in the figure, without adding additional parameters, the attention weights of different areas of the network on the feature map are adjusted to pay more attention to the head area of ​​the driver and passenger, reduce the information loss in the head area, and more accurately capture the details of important targets.

[0072] SimAM is a module based on visual neuroscience and spatial inhibition theory. Neurons with rich information show more significant activity than surrounding neurons when processing visual tasks, and produce spatial inhibition on surrounding neurons. Neurons that show obvious spatial inhibition effects should be given higher priority in detection tasks. The simplest way to find these neurons is to measure the linear separability between a target neuron and other neurons. Based on the above theory, a minimum energy function is defined to derive the weight of each neuron in the helmet feature map. Neuron minimum energy function of SimAM attention mechanism And important parameters are shown in the following formula.

[0073]

[0074] in, Represent the mean and variance respectively, λ is the added regularization term, t is the target neuron of the input feature in a single channel, i represents the index in the spatial dimension, and M=H×W is the total number of neurons in the current channel.

[0075] The above formula shows that in energy The lower the value, the more significant the difference between neuron t and its surrounding neurons, and the more important it is for visual information processing. Therefore, the attention importance of each neuron can be To express.

[0076] According to Hillyard et al., attention regulation in the mammalian brain is usually manifested as a gain (i.e., scaling) effect on neuronal responses. Therefore, a scaling operator is used instead of addition for feature refinement, and the final optimized output result X is shown as follows:

[0077]

[0078] In the above formula, E represents the neuron in the helmet feature map A set of values, X is the input feature.

[0079] E put all After grouping across channels and spatial dimensions, the unimodal function Sigmoid is introduced to limit the E value from being too large.

[0080] (3) Improvement of bounding box regression loss function

[0081] The YOLOv5s algorithm uses the CIOU loss function, which uses the overlapping area, aspect ratio, and center point distance of the bounding box as penalty items, but does not take into account the competition between high-quality and low-quality samples in the training set. In addition, most of the current object detection research assumes that the samples in the training data are of high quality, and focuses on enhancing the fitting ability of the bounding box regression loss. However, it is inevitable that some low-quality samples will be included in the homemade helmet training data set. If the bounding box regression of low-quality samples is blindly enhanced, the positioning performance of the model will be damaged.

[0082] To address the above problems, the present invention replaces the CIOU loss function with the WIOU loss function with a dynamic non-monotonic focusing mechanism to improve the positioning performance and detection accuracy of the model. Since geometric factors such as distance and aspect ratio will aggravate the penalty for low-quality examples, in order to weaken this penalty and reduce intervention during training, WIOUv1 is proposed, as shown in the following formula:

[0083]

[0084] in, represents the first loss function of WIOU; It represents the loss function based on IoU intersection and union ratio; is a penalty term that will expand the normal quality anchor box and This will reduce the quality of the anchor box. W m , H m is the width and height of the minimum closed rectangular box; A and B are the coordinates of the center point of the anchor box, A mt , B mt The coordinates of the center point of the target box.

[0085] To avoid Produce gradients that hinder convergence, and W m and H m Separated from the calculation formula, the superscript * represents W m and H m An operation separated from a computation.

[0086] The outlier degree of the anchor box of the dynamic non-monotonic focusing mechanism is defined as:

[0087]

[0088] in, is the gradient gain; It is an exponentially weighted moving average with momentum m. Its introduction solves the problem of slow convergence in the later stage of training.

[0089] A small outlier means that the anchor box is of high quality, and a large outlier means that the anchor box is of low quality. Then use β to construct a non-monotonic focusing coefficient τ and apply it to WIOUv1:

[0090]

[0091] in, represents the third loss function of WIOU; α and δ are hyperparameters, and β is the outlier degree; after a large number of experiments, α=1.8 and δ=4 will be used in this embodiment, and the detection effect of the improved model is the best at this time.

[0092] It is dynamic, so the anchor frame quality grading standard of WIOUv3 finally selected is also dynamically changing. It can adaptively adjust the most suitable gradient gain distribution method according to each moment of the current situation, give low-quality anchor frames small gradient gains to reduce the generation of harmful gradients, and give high-quality anchor frames smaller gradient gains to make the boundary regression frame concentrate on the anchor frame of ordinary quality, so as to improve the positioning performance of the model and improve the accuracy of electric vehicle helmet detection.

[0093] Step 3: Use the self-built electric vehicle helmet dataset to train the YOLOv5s model before and after the improvement;

[0094] The selected experimental environment configuration is shown in Table 1.

[0095] Table 1 Experimental environment platform configuration

[0096]

[0097] Using the transfer learning method, we loaded the official pre-trained weights of YOLOv5s, and then trained the YOLOv5s network model before and after the improvement on the homemade dataset for 200 rounds. The batch-size was set to 32, the SGD optimizer was used, and the Mosic enhancement strategy was used. According to the performance during the training process, the network structure parameters were continuously adjusted until the improved model with the best effect was obtained. Some hyperparameter settings of the algorithm are shown in Table 2.

[0098] Table 2 Some hyper parameters of the algorithm

[0099]

[0100]

[0101] Step 4, compare the detection performance of YOLOv5s and improved YOLOv5s;

[0102] According to the mAP of each category and the average category mAP, the PR curves of YOLOv5s and improved YOLOv5 after training are drawn respectively, as shown in Figure 5a , Figure 5b Then, we select the trained models of YOLOv5s before and after the improvement, perform inference and prediction on the images collected at the intersection, and then output whether the electric vehicle driver is wearing a helmet, and compare the detection effects before and after the model improvement.

[0103] As shown in Figures 6(a)-6(c), the detection results in the scene of one car with multiple people, YOLOv5s did not detect the passengers without helmets, while the improved YOLOv5s did not miss any detections; as shown in Figures 7(a)-7(c), the detection results in the scene with occlusion, the YOLOv5s model did not detect the helmet wearing status of the electric bike on the right side of the middle and its driver, while the improved model could detect them correctly; Figures 8(a)-8(c) are the detection results in the scene with occlusion and dense vehicles. It can be seen from the figure that the YOLOv5s model did not detect the electric bike on the left side of the man in white, and misdetected the straw hat of the driver in the right front as a helmet, while the improved model correctly detected the missed electric bike and the misdetected helmet wearing status. As shown in Figures 9(a)-9(c), the detection results in the scene of intersection with complex vehicle types and small targets, the YOLOv5s model only detected two electric bikes at a long distance, while the improved model also detected the wearing of helmets.

[0104] According to the analysis of the above results, the reason is that adding the GBC3 module can effectively enhance the interaction of feature information of neighboring targets and the understanding of contextual semantic information, thereby improving the model's detection ability when the head area is blocked; replacing the WIOU loss function makes the bounding box regression more accurate, improving the positioning performance of targets such as electric vehicles and helmets; at the same time, the introduction of the SimAM attention mechanism reduces the information loss in the head area, more accurately captures the details of important targets, and improves the model's detection ability for long-distance targets in complex intersection scenarios.

[0105] The above are merely embodiments with beneficial effects of the present invention and are not to be construed as limiting the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the principles and spirit of the present invention should be included in the protection scope of the present invention.

Claims

1. An electric vehicle helmet wearing detection method based on improved YOLOv5s, characterized in that: The following steps are involved: S1, collects the electric vehicle helmet wearing data set and divides it into training set, validation set and test set according to the proportion; S2, improve the C3 module in the YOLOv5s backbone network and the neck network into a GBC3 module, and build an improved YOLOv5s network model; S3, use the training set to train the improved YOLOv5s network model, continuously adjust the network structure parameters until a network model that meets the conditions is obtained, and save the model.

2. According to the electric vehicle helmet wearing detection method based on improved YOLOv5s according to claim 1, it is characterized in that: The steps to collect the electric vehicle helmet wearing data set are as follows: S11, select a street traffic intersection on a specific road section, take photos, and use Python to crawl and filter the images of electric bikes with and without helmets; then merge the bicycle riding pictures from the bike helmet dataset, and finally put all the pictures together; S12, converting all the obtained images into images with a suffix of jpg; S13, when labeling the data set, the situation where the electric vehicle driver wears a helmet is labeled as helmet, with category 0; secondly, the electric vehicle and the driver are labeled as motor, with category 1; finally, the situation where the driver does not wear a helmet is labeled as head, with category 2; Bicycles, bicycle drivers and pedestrians are not labeled. After the labeling is completed, the image is exported as a VOC format xml file and placed in a folder named Annotations. Then, the xml file is converted into a txt file using Python code. S14, divide the data set into training set, validation set and test set in the ratio of 7:2:

1.

3. According to the electric vehicle helmet wearing detection method based on improved YOLOv5s according to claim 1, it is characterized in that: The structure of the improved YOLOv5s network model is as follows: the C3 module in the backbone network and the neck FPN feature fusion layer is improved to the GBC3 module; the parameter-free attention mechanism SimAM is added to the shallow feature extraction of the backbone network and before the prediction head; the CIOU loss function is replaced by the WIOU loss function with a dynamic non-monotonic focusing mechanism.

4. According to the electric vehicle helmet wearing detection method based on improved YOLOv5s as claimed in claim 3, it is characterized in that: The GBC3 module includes a GBlock module and a recursive gated convolution. The GBlock module is constructed using a Transformer block, including a multi-layer perceptron and layer normalization. According to the structure in the C3 module, the three standard convolutions in C3 are replaced with recursive gated convolutions, and then the residual module is replaced with N improved GBlock modules. The input features are passed through recursive gated convolution. First, they enter a convolution layer to adjust the number of input channels C to twice the original number and obtain a set of p0 and The projection characteristics are shown in the following formula: Among them, H and W are the height and width of the projected feature, C0 is the number of channels of feature q0, and C n-1 is the feature q n-1 The number of channels, n represents the number of spatial interactions, k represents the kth factorial number, A projection layer that performs channel blending. represents the set of real numbers; Then the recursive operation of gated convolution is performed, and the feature q k Enter the depth-separable convolution with a convolution kernel size of 7×7, and then compare the features of each block q0 with the previous block p k The features are multiplied element by element, and then multiplied by the scale factor 1 / α to scale the output to achieve information interaction between the current feature and the adjacent features, and the output feature p is obtained. k+1 : p k+1 =f k (q k )d k (p k ) / α,k=0,1,...,n-1 Among them, f k () represents a set of deep convolutional layer operations, representing element-wise multiplication, d k () represents the convolution operation matching different order dimensions, and the scaling factor 1 / α is used for stable training of the network; Finally, a convolution of size 1×1 is performed.

5. According to the electric vehicle helmet wearing detection method based on improved YOLOv5s as claimed in claim 3, it is characterized in that: By defining a minimum energy function, the weight of each neuron in the helmet feature map is obtained; the minimum energy function of the neuron in the SimAM attention mechanism The formula is as follows: in, Represent the mean and variance respectively, λ is the added regularization term, t is the target neuron of the input feature in a single channel, i represents the index in the spatial dimension, and M=H×W is the total number of neurons in the current channel; The scaling operator is used for feature refinement, and the final optimized output result As shown below: Where E represents the neurons in the helmet feature map A collection of values, X is the input feature, representing element-by-element multiplication.

6. The electric vehicle helmet wearing detection method based on improved YOLOv5s according to claim 3 is characterized in that: The WIOU loss function adopts the expression of WIOUv1 as follows: in, represents the first loss function of WIOU; It represents the loss function based on IoU intersection and union ratio; is a penalty term that will expand the normal quality anchor box A and B are the coordinates of the center point of the anchor box. mt , B mt is the center point coordinate of the target frame; the superscript * represents the W m and H m Operation separated from the calculation formula; W m , H m is the width and height of the minimum enclosing rectangle; The outlier degree of the anchor box of the dynamic non-monotonic focusing mechanism is defined as: in, is the gradient gain, is an exponentially weighted moving average with momentum m; Then, a non-monotonic focusing coefficient τ is constructed with β and applied to the WIOUv1 loss function: Among them, α and δ are hyperparameters, and β is the outlier degree; Represents the third loss function of WIOU.

Citation Information

Cited By

  • Method and device for identifying and tracking sports helmet in complex traffic scene

    CN118942045A

  • Highway vehicle detection method and system based on computer vision

    CN119625664A