A battery bike helmet recognition method based on improved semi-supervised learning

Through improved semi-supervised learning methods and image processing technology, combined with the teacher-student model and the pool mechanism, the problems of low accuracy and weak generalization ability of the traditional semi-supervised helmet detection system in different scenes and weather conditions are solved, and the problem is achieved Higher detection accuracy and faster inference time.

CN114627381BActive Publication Date: 2024-09-24NANTONG ZHIXING FUTURE INTERNET OF VEHICLES INNOVATION CENT CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210426001.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-04-21
Publication Date
2024-09-24
Estimated Expiration
2042-04-21

AI Technical Summary

Technical Problem

Traditional semi-supervised helmet detection systems have low detection accuracy and weak generalization capabilities under different scenarios and weather conditions, and require more inference time in actual operations.

Method used

Using an improved semi-supervised learning method, the teacher-student model is combined with the Faster-RCNN deep neural network to design a category confidence container pool and a category instance container pool, and use images such as mosaic data enhancement, CutMix, CutOut, random rotation and random contrast adjustment. processing technology, combining adaptive memory loss and adaptive foreground fusion to optimize the model training process.

Benefits of technology

It improves the accuracy and generalization ability of battery vehicle helmet detection, reduces the inference time, and enhances the practicality and generalization of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure 00000000_0000
    Figure 00000000_0000
Patent Text Reader

Abstract

The present invention discloses a battery vehicle helmet recognition method based on improved semi-supervised learning, comprising the following steps: S1, using a camera to take pictures of battery vehicle drivers wearing helmets in various scenes, creating a battery vehicle helmet data set, and enhancing the data; S2, using Faster-RCNN as a helmet recognition model, and the basic process of semi-supervised learning adopts a teacher-student model to train the helmet recognition model; S3, improving the semi-supervised learning method, and training the improved model; S4, using the trained student model to recognize battery vehicle helmets. Compared with the existing battery vehicle helmet recognition method, the present invention proposes an improved semi-supervised learning method. Compared with the traditional semi-supervised learning model, the method of the present invention has higher accuracy and does not increase the reasoning time. The model of the present invention can adapt to the detection of battery vehicle helmets in different scenes and weather conditions, and the model has better practicability and generalization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the fields of computer vision, image processing, deep learning and target recognition, and in particular relates to an electric vehicle helmet recognition method based on improved semi-supervised learning. Background Art

[0002] With the development of society and the advancement of science and technology, various types of transportation have emerged in cities. However, according to preliminary statistics from the Traffic Management Bureau of the Ministry of Public Security, the traffic accident mortality rate of battery-powered bicycle drivers and passengers is often very high, of which about 80% are caused by craniocerebral injuries. Relevant studies have shown that wearing a helmet correctly can reduce the risk of death in traffic accidents by 60% to 70%.

[0003] The traditional semi-supervised helmet detection system has the disadvantages of low detection accuracy and weak generalization ability due to the influence of different scenes and different weather. Summary of the invention

[0004] The purpose of the present invention is to provide a battery bicycle helmet recognition method based on improved semi-supervised learning to solve the problems of poor practicality, low generalization and more reasoning time required in actual operation of traditional semi-supervised models.

[0005] In order to solve the above technical problems, the specific technical solutions of the present invention are as follows:

[0006] A battery bicycle helmet recognition method based on improved semi-supervised learning includes the following steps:

[0007] S1. Use a camera to take pictures of battery vehicle drivers wearing helmets in various scenes, create a battery vehicle helmet dataset, and enhance the data through image processing methods;

[0008] S2, using Faster-RCNN deep neural network as the helmet recognition model, the basic process of semi-supervised learning adopts the teacher-student model to train the helmet recognition model;

[0009] S3. Improve the semi-supervised learning method and train the improved model;

[0010] S4. Use the trained student model to identify electric bicycle helmets.

[0011] Furthermore, the data enhancement used in S1 includes mosaic data enhancement, CutMix, CutOut, random rotation and random contrast adjustment, and finally an image enhanced data set is obtained.

[0012] Furthermore, the mosaic data enhancement is to randomly extract four pictures from the data set to form a new training picture;

[0013] The CutMix method randomly selects a picture, randomly scales it, and then pastes it onto another picture.

[0014] The Cutout method randomly selects an area on the image and assigns the value of 0 to the area;

[0015] The random rotation is to randomly rotate the image by -60 degrees to +60 degrees;

[0016] The implementation method of random contrast adjustment is to first set a threshold m, then randomly select a number t in (0,1). If t≥0.5, the contrast adjustment ratio is t. If t<0.5, a number z is randomly selected in (-t,t) and the contrast is adjusted to z+1.

[0017] Furthermore, S2 includes the following steps: the semi-supervised learning process adopts a teacher-student model, that is, the teacher model is first trained using labeled samples, the weights of the trained teacher model are initialized, and the teacher model is used to generate pseudo labels for unlabeled data, and finally the generated pseudo labels and image data are used to train the student model. In the present invention, both the teacher and student models adopt the Faster-RCNN deep neural network.

[0018] Furthermore, two pools are designed in S3: a category confidence pool and a category instance pool, which specifically include the following steps:

[0019] S3.1. The category confidence pool is updated during the teacher-student mutual learning phase. During the training process, the category confidence pool records the prediction confidence of each category in each iteration, and uses the confidence of the category in the confidence pool as the sampling probability of the adaptive memory loss.

[0020] S3.2. The category instance pool is used to store images and their corresponding labels. For the labeled part of semi-supervised learning, the category instance pool directly generates the corresponding instance combination based on its label, i.e., image + corresponding label. For the unsupervised part, the category instance pool uses higher-quality pseudo labels to update the low-quality pseudo labels previously used for training.

[0021] S3.3, Adaptive Memory Loss First, the sampling probability of each type of suggestion box is calculated based on the category confidence pool, and then the suggestion box is randomly sampled based on the sampling probability. For the sampled suggestion box, the Focal loss function is used to calculate the classification loss;

[0022] S3.4, Adaptive foreground fusion first selects the corresponding category based on the category confidence pool, and then selects the image containing the selected category from the category instance pool. For the selected image, only the foreground category is retained according to the label, and the background and the unselected foreground in the image are removed.

[0023] Furthermore, the Focal loss in S3.3 also introduces a category-aware factor, which can reflect the performance of each category in the training process.

[0024] Furthermore, in step S3.4, the background and the unselected foreground in the picture are removed, which specifically includes the following steps:

[0025] First, the image is Gaussian smoothed, and then the area outside the bounding box in the image is set to zero according to the corresponding label. At the same time, a small square area is sampled on the Gaussian smoothed image, which does not overlap with the bounding box in the label, and the area is enlarged to the original image size, and then the area in the bounding box is pasted into the enlarged image;

[0026] The image after background removal and the original training image are spliced ​​by aligning the short sides, and the spliced ​​image is input into the model for training.

[0027] Furthermore, the S4 trains the model on four Tesla T4 GPU graphics cards, and the optimizer selects SGD. After the training is completed, the trained model is deployed to the mobile device to achieve real-time detection of electric vehicle helmets.

[0028] Furthermore, the hyperparameters of the model training process are as follows: the total number of iterations is 180,000, the optimizer selects SGD, the number of samples trained in a single batch is 16, the learning rate uses a gradually decreasing strategy, the initial learning rate is 0.005, and it decays every 5,000, with a decay rate of 0.1.

[0029] The battery vehicle helmet recognition method based on improved semi-supervised learning of the present invention has the following advantages:

[0030] 1. The present invention proposes an improved semi-supervised learning method. Based on step S3, compared with the traditional semi-supervised model, the method of the present invention has higher accuracy and does not increase the reasoning time.

[0031] 2. Based on steps S1, S2, and S3, the model of the present invention can adapt to the detection of electric vehicle helmets in different scenarios and weather conditions, and the model has better practicability and generalization. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] Figure 1 A system flow chart of battery vehicle helmet detection of the present invention;

[0033] Figure 2 It is a schematic diagram of the adaptive foreground fusion of the present invention. DETAILED DESCRIPTION

[0034] In order to better understand the purpose, structure and function of the present invention, the following is a further detailed description of an electric vehicle helmet recognition method based on improved semi-supervised learning in conjunction with the accompanying drawings.

[0035] like Figure 1 As shown, the present invention discloses a battery vehicle helmet recognition method based on improved semi-supervised learning, comprising the following steps:

[0036] Step 1: Create an electric bike helmet dataset and use image processing algorithms to preprocess the images.

[0037] In this embodiment, the electric vehicle helmet dataset is obtained by camera shooting + web crawler. The camera shooting mainly captures the actual traffic intersection scene, but due to the limitation of conditions, in order to obtain pictures of electric vehicle drivers wearing helmets in complex scenes and weather, this embodiment uses web crawler technology to collect pictures from Google, 360 Gallery, and Baidu Gallery. There are 7,000 data set pictures in this embodiment. There are three categories of data set categories: helmet, driver, and electric vehicle. The data set is annotated with LabelImg, and the format is VOC data set format. Since the collected pictures contain blur and damage, in order not to affect the training of the model, the pictures need to be preprocessed. Data preprocessing includes: mosaic data enhancement, CutMix, CutOut, random rotation, and random contrast adjustment. Mosaic data enhancement is to randomly extract four pictures from the data set to form a new training picture, CutMix is ​​to randomly select a picture and paste it to another picture after random scaling, Cutout method is to randomly select an area on the image and assign this area a value of 0, random rotation is to randomly rotate the picture by -60 degrees to +60 degrees, and the implementation method of random contrast adjustment is to first set a threshold m (m=0.5 in the present invention), and then randomly select a number t in (0, 1), if t≥0.5, the contrast adjustment ratio is t, if t<0.5, then randomly select a number z in (-t, t), and the contrast is adjusted to z+1.

[0038] Step 2: Use Faster-RCNN as the helmet recognition model. The basic process of semi-supervised learning adopts the teacher-student model to train the helmet recognition model.

[0039] like Figure 1 As shown, the teacher-student model is used in this embodiment. The model has two stages: the Burn-In stage and the teacher-student mutual learning stage. In the Burn-In stage, the model pre-trains the student model with a small amount of labeled data in a supervised manner. Then, the teacher model is initialized with the pre-trained weights of the student model.

[0040] In the mutual learning stage between teachers and students, this embodiment trains the student model with labeled data and unlabeled data, and the supervision signal of these data is generated by pseudo labels. When the student model is updated through gradient back propagation, the knowledge is fed back to the teacher model through the exponential moving average (EMA) mechanism. The update process is shown in the following formula:

[0041]

[0042] ∈ t ←α×∈ t +(1-α)×∈ t

[0043] Among them, ∈ s and ∈ t denote the model parameters of the student and teacher respectively. L denotes the total loss of semi-supervised object detection, and α is the decay coefficient in EMA. It is a partial derivative in mathematics.

[0044] In this embodiment, two instance pools are designed: a category confidence pool and a category instance pool. In this embodiment, a category confidence pool is designed to record the classification performance at the dataset level in the mutual learning stage of the teacher-student model, and the performance of each category is evaluated by predicting the confidence index.

[0045] Step 3: Improve the semi-supervised model and train the semi-supervised model. The specific steps include:

[0046] At the beginning of the teacher-student mutual learning stage, this embodiment initializes the category confidence pool through the teacher model instead of random initialization. Specifically, this embodiment first creates an empty category confidence pool, and then uses the teacher model to infer the input data. For the inferred data, this embodiment sets a confidence threshold t to filter incorrect categories. Only predictions with confidence greater than the threshold can be recorded. This process can be written as the following formula:

[0047]

[0048] Where N in is the total number of input data, and M is the total number of bounding boxes in an image. j and score j They represent the predicted category of the jth bounding box and the prediction confidence of the corresponding category respectively. C is the total number of categories in the dataset.

[0049] After initialization, this embodiment updates the category confidence in the category confidence pool by exponential moving average. The process is shown in the following formula.

[0050]

[0051] Wherein, k represents the kth iteration. In addition to the category confidence pool, this embodiment also designs a category instance pool. The category instance pool stores rich instance-level annotations and corresponding images. For labeled data, the category instance pool directly saves the category, bounding box, and corresponding image. For unlabeled data, the category instance pool continuously updates the category and bounding box by improving the pseudo-label.

[0052] Based on the designed category confidence pool, this embodiment proposes an adaptive memory loss to solve the imbalance between foreground and background, and the imbalance between foreground and foreground in semi-supervised learning.

[0053] The adaptive memory loss in this embodiment is a variant of the Focal loss. Focal loss counts all the suggestion boxes in the loss, but the adaptive memory loss samples some suggestion boxes for the classification loss calculation. Specifically, the adaptive memory loss first defines the sampling probability s of each category c ,s c The calculation method is shown in the following formula.

[0054]

[0055] According to the calculated sampling probability, the adaptive memory loss randomly samples the proposal boxes, and the classification loss is calculated for the sampled proposal boxes, while the classification loss is not calculated for the unsampled loss.

[0056] There is still category imbalance in the sampled suggestion boxes. This embodiment calculates Focal loss for these sampled suggestion boxes, but the suppression degree of all categories in Focal loss is the same, which is not conducive to model training.

[0057] This embodiment introduces a category-aware factor γ into the focal loss. c , γ c The definition of is shown below.

[0058] γ c =γ b +γ d

[0059] where γ b It is the suppression coefficient in Focal loss, which is a factor independent of the category and a constant. d is a factor related to the category confidence. d The calculation formula is as follows.

[0060] γ d =(1+log(Conf c ))×α s, c∈{1,...,C}

[0061] Among them, α s is a scaling factor.

[0062] Therefore, the adaptive memory loss of this embodiment is expressed as follows.

[0063]

[0064] In addition to adaptive memory loss, this embodiment also proposes adaptive foreground fusion to improve the recognition accuracy of the model for poorly performing categories. The specific methods include:

[0065] The process of adaptive foreground fusion is as follows Figure 2 As shown. Adaptive foreground first obtains the probability of selecting each category based on the category confidence, as shown in the following formula:

[0066] h c =Softmax(1-Conf c )

[0067] According to the category selection probability, the adaptive foreground fusion randomly selects a category and selects a picture from the category instance pool. The selected picture must contain the selected category. In addition, for the selected picture, this embodiment performs a background removal operation on it. The specific steps include:

[0068] First, the image is Gaussian smoothed, and then the area outside the bounding box in the image is set to zero according to the corresponding label. At the same time, a very small square area (in this embodiment, the size of the original image) is sampled on the Gaussian smoothed image. ), the area does not overlap with the bounding box in the label, and the area is enlarged to the original image size, and then the area in the bounding box is pasted into the enlarged image.

[0069] The image after background removal and the original training image are spliced ​​by aligning the short sides and then input into the model for training.

[0070] Step 4: Use the trained model to identify the battery bike helmet. The specific steps include:

[0071] The semi-supervised model is trained on 4 Tesla T4 GPUs, and the optimizer is SGD. The trained images are deployed on mobile devices (such as Jetson TX2) to realize the recognition of battery bicycle helmets. The deep learning framework of the present invention is Pytorch1.8.0, and the detection framework is Detectron2.

[0072] It is to be understood that the present invention is described by some embodiments, and it is known to those skilled in the art that various changes or equivalent substitutions may be made to these features and embodiments without departing from the spirit and scope of the present invention. In addition, under the teachings of the present invention, these features and embodiments may be modified to adapt to specific circumstances and materials without departing from the spirit and scope of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed herein, and all embodiments falling within the scope of the claims of this application belong to the scope of protection of the present invention.

Claims

1. A battery vehicle helmet recognition method based on improved semi-supervised learning, characterized in that: The following steps are involved: S1. Use a camera to take pictures of battery vehicle drivers wearing helmets in various scenes, create a battery vehicle helmet dataset, and enhance the data through image processing methods; S2, using Faster-RCNN deep neural network as the helmet recognition model, the basic process of semi-supervised learning adopts the teacher-student model to train the helmet recognition model; S3. Improve the semi-supervised learning method and train the improved model; S4, use the trained student model to identify the battery bicycle helmet; Two pools are designed in S3: a category confidence pool and a category instance pool; wherein a pool is an intermediate variable used to store data during model training, and the category confidence pool and category instance pool represent variables for storing prediction confidence and category instances of each category, specifically including the following steps: S3.

1. The category confidence pool is updated during the teacher-student mutual learning phase. During the training process, the category confidence pool records the prediction confidence of each category in each iteration, and uses the confidence of the category in the category confidence pool as the sampling probability of the adaptive memory loss. S3.

2. The category instance pool is used to store images and their corresponding labels. For the labeled part of semi-supervised learning, the category instance pool directly generates the corresponding instance combination based on its label, i.e., image + corresponding label. For the unsupervised part, the category instance pool uses higher-quality pseudo labels to update the low-quality pseudo labels previously used for training. S3.3, Adaptive Memory Loss First, the sampling probability of each type of suggestion box is calculated based on the category confidence pool, and then the suggestion box is randomly sampled based on the sampling probability. For the sampled suggestion box, the Focal loss function is used to calculate the classification loss; S3.4, Adaptive foreground fusion first selects the corresponding category based on the category confidence pool, and then selects the image containing the selected category from the category instance pool. For the selected image, only the foreground category is retained according to the label, and the background and the unselected foreground in the image are removed.

2. The battery vehicle helmet recognition method based on improved semi-supervised learning according to claim 1 is characterized in that: The data enhancement used in S1 includes mosaic data enhancement, CutMix, CutOut, random rotation and random contrast adjustment, and finally an enhanced image dataset is obtained.

3. The battery vehicle helmet recognition method based on improved semi-supervised learning according to claim 2 is characterized in that: The mosaic data enhancement is to randomly extract four pictures from the data set to form a new training picture; The CutMix method randomly selects a picture, randomly scales it, and then pastes it onto another picture. The Cutout method randomly selects an area on the image and assigns the value of 0 to the area; The random rotation is to randomly rotate the image by -60 degrees to +60 degrees; The implementation method of random contrast adjustment is to first set a threshold m, then randomly select a number t in (0,1). If t≥0.5, the contrast adjustment ratio is t. If t<0.5, a number z is randomly selected in (-t,t) and the contrast is adjusted to z+1.

4. The battery vehicle helmet recognition method based on improved semi-supervised learning according to claim 1 is characterized in that: The S2 includes the following steps: the semi-supervised learning process adopts a teacher-student model, that is, the teacher model is first trained using labeled samples, the weights of the trained teacher model are initialized, and the teacher model is used to generate pseudo labels for unlabeled data, and finally the student model is trained using the generated pseudo labels and image data. Both the teacher and student models use the Faster-RCNN deep neural network.

5. The battery vehicle helmet recognition method based on improved semi-supervised learning according to claim 1 is characterized in that: The Focalloss in S3.3 also introduces a category-aware factor, which can reflect the performance of each category in the training process.

6. The battery vehicle helmet recognition method based on improved semi-supervised learning according to claim 1 is characterized in that: In step S3.4, the background and the unselected foreground in the image are removed, which specifically includes the following steps: First, the image is Gaussian smoothed, and then the area outside the bounding box in the image is set to zero according to the corresponding label. At the same time, a small square area is sampled on the Gaussian smoothed image, which does not overlap with the bounding box in the label, and the area is enlarged to the original image size, and then the area in the bounding box is pasted into the enlarged image; The image after background removal and the original training image are spliced ​​by aligning the short sides, and the spliced ​​image is input into the model for training.

7. The battery vehicle helmet recognition method based on improved semi-supervised learning according to claim 1 is characterized in that: The S4 trains the model on four Tesla T4 GPU graphics cards, and the optimizer selects SGD. After the training is completed, the trained model is deployed to the mobile device to achieve real-time detection of electric vehicle helmets.

8. The battery vehicle helmet recognition method based on improved semi-supervised learning according to claim 7 is characterized in that: The hyperparameters of the model training process are as follows: the total number of iterations is 180,000, the optimizer selects SGD, the number of samples trained in a single batch is 16, the learning rate uses a gradually decreasing strategy, the initial learning rate is 0.005, and it decays every 5,000 times, with a decay rate of 0.1.