Lightweight scale adaptive scaling vehicle head and vehicle tail identification method
By adopting improved efficient network model and proxy normalization technology in front and rear recognition, the non-normalization problem caused by the normalization layer in deep convolutional neural network is solved, and the detection performance and training speed of the model are improved.
Patent Information
- Application Number
- CN202411544564.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-02-18
AI Technical Summary
In the prior art, deep convolutional neural networks have non-normalization problems caused by normalization layers in front and rear recognition, which affects the detection performance of the model.
A lightweight scale adaptive scaling front and rear recognition method is adopted to solve the non-normalization problem through an improved and efficient network model, including the MBConv1 layer and coordinate attention module in the nine-layer structure, combined with proxy normalization technology. And improve model performance.
Effectively overcome the non-normalization problem caused by the normalization layer, improve the detection performance and training speed of the model, and maintain the lightweight characteristics of the model.
Smart Images

Figure CN119478854A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of automobile recognition, and in particular to a lightweight scale-adaptive zooming method for recognizing a front or rear end of a vehicle. Background Art
[0002] In the prior art, the detection of vehicles must first detect the vehicle itself, and then determine whether the detected vehicle is the front or the rear, which is used to determine whether the vehicle is entering or leaving the mining area. Detecting the front or the rear of the vehicle can be achieved through a deep convolutional neural network. With the continuous development of deep convolutional neural networks, it can be found that improving the performance of neural networks is not only about the number of stacked layers, but also more important points: 1) The network must be trainable and convergent; 2) The number of parameters must be relatively small, that is, lightweight, which is convenient for training and can also speed up the recognition speed; 3) Innovate the model structure of the neural network to obtain a better model. In the prior art, the normalization operation has the problem that the activation may become non-normalized on the channel. As the depth increases, this problem becomes worse. Although this problem can be avoided by simply reducing the group size in group normalization, this reduction in group size will change the expressiveness and reduce the detection performance of the model. Summary of the invention
[0003] The purpose of the present invention is to provide a lightweight scale-adaptive scaling method for vehicle head and tail recognition in order to ensure model detection performance while reducing the non-normalization caused by the normalization layer.
[0004] The purpose of the present invention can be achieved by the following technical solutions:
[0005] A lightweight scale-adaptive zooming vehicle front and rear recognition method, the method comprising:
[0006] Acquire an image to be recognized, input the image to be recognized into a vehicle front and rear recognition model, and obtain a recognition result, wherein the vehicle front and rear recognition model is an improved efficient network model, and the improved efficient network model includes a nine-layer structure, and the MBConv1 layer in the nine-layer structure includes a first convolutional layer, a first proxy normalization layer, an attention CA layer, a second convolutional layer, a second proxy normalization layer, a third convolutional layer and a fourth convolutional layer connected in sequence, and the output of the fourth convolutional layer is multiplied by the input of the MBConv1 layer as the overall output of the MBConv1 layer.
[0007] Furthermore, the attention CA layer is a coordinate attention module. The input of the attention CA layer passes through the X average pooling and Y average pooling in the layer respectively, passes through the first fully connected layer together, then passes through the first activation function layer, and then passes through the second fully connected layer and the second activation function layer respectively. The output at this time is multiplied by the input of the attention CA layer to obtain the output of the attention CA layer.
[0008] Furthermore, the first activation function layer is a swish activation function layer, and the second activation function layer is a sigmoid activation function.
[0009] Furthermore, the proxy normalization layer includes a group normalization module or a layer normalization module and an activation function. The calculation process inside the proxy normalization layer is:
[0010] The output of the group normalization module or the layer normalization module is assimilated into a Gaussian proxy variable y, the Gaussian proxy variable y is multiplied by the learning parameter γ and the learning parameter β is added, and then the normalization parameter z is obtained through the activation function to obtain a non-normalized proxy variable Y that obeys the normal distribution, the non-normalized proxy variable Y is multiplied by the learning parameter γ and the learning parameter β is added, and then the normalization parameter Z is obtained through the activation function, the normalized distribution is calculated based on the normalization parameter z and the normalization parameter Z, and the normalized result is output as the output of the proxy normalization layer, and the proxy normalization layer also includes additional regularization calculations.
[0011] Furthermore, the normalized distribution is:
[0012]
[0013] Furthermore, the distribution of the non-normalized proxy variable Y is in, and represents the mean of the learning parameters.
[0014] Furthermore, during the training process of the improved efficient network model, the starting model size is first confirmed as the current size, and then the performance and computing resources during model training are monitored. When it is found that the performance of the model reaches a threshold or the computing resources reach a threshold at the current size, the current size is adjusted, and the width and number of layers of the efficient network model are updated according to the adjusted current size.
[0015] Furthermore, the nine-layer structure is:
[0016] The first layer structure includes the first model convolution layer, normalization layer and activation function layer;
[0017] The second layer structure is the MBConv1 layer and six consecutive MBConv6 layers;
[0018] The ninth layer structure includes the second model convolution layer, pooling layer and fully connected layer.
[0019] Furthermore, the MBConv6 layer includes an MBConv1 layer, a Depwise convolution, an SE layer, a convolution layer, and a random dropout layer connected in sequence, and the output of the MBConv6 layer is the product of the input of the MBConv6 layer and the output of the random dropout layer.
[0020] Furthermore, the convolutional layer in the efficient network model is a depth-separable convolution.
[0021] Compared with the prior art, the present invention has the following beneficial effects:
[0022] (1) The non-normalization is offset by assimilating the output of the group norm or layer norm into a Gaussian "proxy" variable and applying the same affine transformation and the same activation function to the proxy variable. The statistics of the non-normalized proxy variable are then used to correct the expected distribution shift in the true activation. Proxy normalization allows the present invention to maximize the group size (i.e., using layer normalization). Even if there is no channel non-normalization problem, the proxy normalization still maintains the expressive power, overcomes the non-normalization problem caused by the normalization layer, and improves the detection performance of the model.
[0023] (2) The coordinate attention module of the present invention can better capture the spatial relationship in the image by introducing coordinate information, improve the performance and training speed of the model, and at the same time have better scalability, replacing the original SE module and reducing the problem that low-dimensional features that reduce the number of channels through point convolution may lose key information. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 For existing efficient network models;
[0025] Figure 2 This is the structure diagram of the coordinate attention module;
[0026] Figure 3 Schematic diagram of the coordinate attention module CA replacing the compressed excitation SE module;
[0027] Figure 4 Normalize the activation flow chart for the agent;
[0028] Figure 5 It is a schematic diagram of the scaling principle;
[0029] Figure 6 This is a comparison picture of the front and rear of the car;
[0030] Figure 7 The number distribution of training sets and test sets in the Truck-20000 dataset;
[0031] Figure 8 It is the probability density function graph of β distribution;
[0032] Fig. 9 This is a comparison chart between this application and the ResNet34 model training. Fig. 9 (a) and (b) are the training results of the ResNet34 model. Fig. 9(c) and (d) are the training results of the model of this application;
[0033] Fig.10 This is the change of Acc and Loss of the model in the test set as the epoch increases. DETAILED DESCRIPTION
[0034] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0035] The present invention proposes a lightweight scale-adaptive zooming vehicle front and rear recognition method, the method comprising:
[0036] Acquire an image to be recognized, input the image to be recognized into a vehicle front and rear recognition model, and obtain a recognition result, wherein the vehicle front and rear recognition model is an improved efficient network model, and the improved efficient network model includes a nine-layer structure, and the MBConv1 layer in the nine-layer structure includes a first convolutional layer, a first proxy normalization layer, an attention CA layer, a second convolutional layer, a second proxy normalization layer, a third convolutional layer and a fourth convolutional layer connected in sequence, and the output of the fourth convolutional layer is multiplied by the input of the MBConv1 layer as the overall output of the MBConv1 layer.
[0037] The present invention uses EfficientNet as the backbone network. The MBConv module of the original network model is modified and a Squeeze-and-Excitation SE module is incorporated, so that the network can focus on the importance of different channel features. In the SE module, the residual connection is the low-dimensional feature after the convolution compression channel. This process may cause information loss, thus affecting the final result. In order to solve this problem, the present invention uses the Coordinate Attention CA mechanism to improve the inverted residual module, and successfully solves this problem by reversing the idea of the inverted residual.
[0038] The present invention adopts a coordinate attention mechanism CA, and considers the attention weights of different vertical and horizontal coordinate directions of the two-dimensional feature map differently. This method of introducing the coordinate attention mechanism in the convolutional neural network aims to improve the accuracy of the model in feature extraction. The coordinate attention mechanism is a technique for processing spatial feature information. Here, it performs average pooling on the two dimensions of the X-axis and the Y-axis respectively. Average pooling is an operation that reduces the size of the feature map, which is achieved by calculating the average value of the pixel values in each region. This allows the model to pay more attention to the important parts of the spatial features, thereby improving the accuracy of feature extraction. In this process, the residual edge jump connection is used to enable the model to better learn the feature information in the high-dimensional space while ensuring that the low-dimensional information is well preserved. This design helps to improve the performance of the model in processing complex tasks, and solves the loss of low-dimensional feature information after the convolution compression channel during the residual connection process by flipping the inverted residual idea. In the residual network, the residual connection can help information be transmitted more effectively in the model, thereby improving the performance of the model. However, in the process of convolution compression channel, the loss of low-dimensional feature information may occur. The idea of flipping the inverted residual can effectively solve this problem, so that the model can better learn low-dimensional feature information.
[0039] Flipped Residual Connections (FRC) is a method to solve the problem of low-dimensional information loss in residual networks. In residual networks, there are residual connections between input data and output data. This connection helps the direct propagation of information, but it may also cause the loss of low-dimensional information. The method of flipping residuals is to introduce a flip layer in the network to flip the residual connection so that information can be better propagated in the network. Specifically, the method of flipping residuals is as follows: First, calculate the difference between the input data and the network output data to obtain residual information. Flip the residual information, that is, convert it to the opposite order of the input data. Add the flipped residual information to the input data to obtain the flipped residual data. Pass the flipped residual data to the next layer of the network for calculation and processing. By introducing flipped residuals, the network can better learn low-dimensional information, thereby improving the performance of the model. The method of flipping residuals can be applied to various deep learning models.
[0040] The deep separable convolutional network of the present invention, as a convolutional neural network architecture used in computer vision tasks, achieves the goal of improving network efficiency and accuracy by splitting the traditional convolution operation into two steps: deep convolution and point-by-point convolution. This architecture performs convolution operations on each channel of the input feature map separately through deep convolution, uses smaller convolution kernels such as 3x3 to effectively reduce the number of parameters, and focuses on the extraction of local features. Subsequently, point-by-point convolution enhances the nonlinear ability of the model by merging information from different channels. In the MBConv module, the deep separable convolution is used to replace the traditional convolution module, thereby reducing the number of parameters of the model and achieving lightweight.
[0041] The present invention uses proxy normalization activation. Proxy Normalization is a method for normalizing model weights during deep learning model training. The purpose of normalization is to make model training more stable and improve model performance. In deep learning, weight normalization helps prevent gradient vanishing and gradient explosion problems, thereby reducing the difficulty of training. The proxy normalization method is an improvement on the batch normalization (Batch Normalization BN) method, which is to standardize a batch of data. However, there is a problem with batch normalization, that is, it assumes that each feature is independent, which is not always true. The core idea of the proxy normalization method is that for each feature, the present invention finds a proxy variable, which is related to the feature but not to other features. Then, the present invention normalizes the proxy variable. In this way, during the normalization process, the features can still be interdependent, thereby improving the expressive power of the model. In specific implementation, the mean and variance of each feature are usually calculated first, and then the covariance of each feature with other features is calculated. Next, the proxy variable of the feature is obtained by performing the inner product between the feature and the eigenvector of its covariance matrix. Finally, the proxy variable of each feature is normalized. In summary, the proxy normalization method improves the batch normalization method by introducing the dependency between features, which helps to improve the performance and stability of the deep learning model.
[0042] In order to make the model usable on different hardware, the width, resolution and depth (number of layers) of the model are comprehensively considered and uniformly adjusted using a scaling factor.
[0043] The improved efficient network model of the present invention adopts a lightweight scale-adaptive network architecture (LightweightScale-Adaptive Network Architecture LSAN), and the backbone model uses efficientnet. On the basis of this model, the compression excitation module SE of the inverted linear bottleneck deep separable convolution (MBconv) module is replaced by the proposed coordinate attention module and proxy normalization technology, and in order to complete the adaptive scaling of the network framework, it is suitable for running on different hardware platforms. At the same time, by replacing the standard convolution module in MBconv with deep separable convolution, the parameters are reduced, making the model more lightweight. The following is a detailed introduction to these four modules. The existing efficientnet structure is as follows: Figure 1 shown.
[0044] The Coordinate Attention Module is an attention module used in convolutional neural networks. It enhances feature representation capabilities by introducing coordinate information. In many deep learning tasks, especially computer vision tasks, the Coordinate Attention Module has been shown to replace the Squeeze-and-Excitation SE module and achieve better performance. The specific advantages and analysis are as follows. Better spatial modeling capabilities. The Coordinate Attention Module introduces coordinate information, allowing the model to better capture the spatial relationships in the image. This is very important for solving some image problems with complex spatial structures. In contrast, the SE module may not be able to fully capture these spatial relationships.
[0045] Parameter sharing, the self-attention mechanism in the coordinate attention module allows the model to share weights between all layers, thereby reducing the number of parameters of the model. This helps to increase the training speed of the model and reduce the risk of overfitting. Parallel computing capability, the self-attention calculation in the coordinate attention module can be easily processed in parallel, which enables the model to run efficiently on the GPU. Coordinate attention has better performance. Studies have shown that the coordinate attention module has better performance than the SE module in computer vision algorithms. Coordinate attention modules such as Figure 2 As shown. In addition, the coordinate attention module can be easily extended to different network architectures and tasks. This allows researchers and developers to flexibly adjust the model to adapt to different application scenarios and needs. In summary, the coordinate attention module can better capture the spatial relationship in the image by introducing coordinate information, improve the performance and training speed of the model, and have better scalability. Therefore, in many cases, the coordinate attention module can replace the SE module and achieve better results.
[0046] A modified inverted residual structure using the CA (Channel Attention) attention mechanism is introduced to replace the SE structure. Figure 3 As shown in the figure. This structure effectively retains more useful information by inverting the inverted residual design. Compared with the traditional Squeeze-and-Excitation (SE) module, the CA attention mechanism can capture richer spatial features by performing two lightweight deep convolutions. The improved process first extracts features from the high-dimensional layer through 3x3 or 5x5 deep convolutions, then introduces the CA attention mechanism for feature enhancement, and then reduces and increases the number of channels through 1x1 convolutions. Finally, 3x3 or 5x5 deep convolutions are applied again, and the input and output are added to form a "convolution-compression-expansion-convolution" data flow pattern. In the experiment, LSAN improves the backbone feature layer (Blockbone) to extract features of the adjusted size and number of channels. Compared with the original backbone, this design keeps the feature layer size and number of channels unchanged, while connecting the input and output of the high-dimensional channel, to achieve the transmission of richer information from the input tensor to the output tensor.
[0047] Normalizing the output of convolution and matrix multiplication operations has become a basic operation of CNN at this stage, among which batch normalization is the most common formal method for this purpose. However, the problem of batch size limitation introduced by batch normalization has triggered a series of innovations of alternative methods independent of batch. Some of these methods also work well in the ResNet model, but the present invention finds that none of them achieves the same performance as the batch normalization of EfficientNet. In order to solve the problem of batch normalization alternative methods, the present invention proposes a new batch-independent normalization method called proxy normalization. This method is based on the successful group (and layer) normalization method. Group normalization and layer normalization are affected by a problem that activations may become non-normalized on the channel. This problem becomes worse with increasing depth because non-normalization is prominent at each level. Although this problem can be avoided by simply reducing the group size in group normalization, this reduction in group size will change the expressiveness and reduce performance. Proxy normalization provides a better solution that preserves expressivity while offsetting the two main sources of non-normalization, namely affine transformation and activation function, following group normalization or layer normalization. Specifically, the non-normalization is offset by assimilating the output of the group norm or layer norm into a Gaussian "proxy" variable and applying the same affine transformation and the same activation function to this proxy variable. The statistics of the non-normalized proxy variable are then used to correct the expected distribution shift in the true activation. Proxy normalization allows the present invention to maximize the group size (i.e., using layer normalization), and even if there is no channel non-normalization problem, proxy normalization still maintains expressiveness. Importantly, this method does not mimic any implicit regularization features of batch normalization. Therefore, additional regularization is required in this work, and the present invention uses a combination of mixing and shear mixing. When comparing the performance of Layer Normalization + Proxy Normalization (LN+PN) with two Batch Normalization (BN) baseline models under standard preprocessing and AutoAugment (AA), it is found that LN+PN matches or exceeds the standard preprocessing performance of BN across the entire range of model sizes. In addition, LN+PN is almost as good as BN on AA, even though AA requires the expensive process of training augmented parameters. Figure 4 shown.
[0048] By increasing the depth of the network, richer and more complex feature representations can be obtained, and these features can also be effectively applied in other tasks. In network design, the influence of three factors, depth, width and input resolution, on model performance. First, when the deep network architecture is too complex, the problem of gradient diffusion may be encountered, making training more difficult; secondly, expanding the width of the network can help capture more detailed features, but excessively increasing the width may make it difficult for the model to abstract deeper features; in addition, improving the resolution of the input image is expected to enhance the model's ability to capture detailed features, but too high a resolution may result in limited improvement in the accuracy of the model, and also lead to a significant increase in computational costs. In order to study the impact of these three factors on the final accuracy, the present invention incorporates them into the optimization problem and solves them under specified resource constraints. By this method, a series of models can be obtained, which may have different scaling ratios on different benchmark networks. Experiments show that searching for scaling ratios in larger models may obtain better results, but due to the high search cost, it is generally chosen to search on smaller models.
[0049] In order to study the impact of these three variables d, w, and r on the final accuracy, as shown in Formula 3.2, the present invention incorporates them into the formula for analysis. Under given resource constraints, the present invention can construct an abstract optimization problem. The constraints d and r here are used to adjust the depth and resolution, affecting related factors, while the number of channels of the feature matrix is scaled by another factor w. In addition, target_memory represents the memory capacity limit, and target_flops refers to the computing speed limit.
[0050]
[0051] Formula 3.1 represents the continuous multiplication operation, F i represents the current best network layer setting. ε represents the Operator operator in the basic network, then Indicates that in the i-th iteration, layer F i Repeated execution of L i Second, X represents the feature matrix of this layer. i ,W i ,C i ) represent the height, width, and channel of X respectively.
[0052]
[0053] In theory, the amount of FLOPs is proportional to the depth, that is, when the depth doubles, the FLOPs will also double. The relationship with the width is that when the width doubles, the FLOPs will increase four times. This is because the FLOPs of the convolutional layer can be calculated by the following formula 3.3:
[0054] FLOPs = features w ×feature h ×feature c ×kernel w ×kernel h ×kernel number ; (3.3)
[0055] Assuming that the height and width of the input and output feature matrices remain unchanged, when the width doubles, the number of channels of the input feature matrix and the number of channels or convolution kernels of the output feature matrix will also double, resulting in a four-fold increase in FLOPs. The relationship between FLOPs and resolution is that when the resolution doubles, FLOPs also increase fourfold, because the width and height of the feature matrix will double. Therefore, the total FLOPs ratio can be approximately expressed as α*β 2 *γ 2 , and when there is a limit, for any given Φ, the increase in FLOPs will be quite significant.
[0056] Scale adaptive scaling is a technology that dynamically adjusts the model width and number of layers during model training. Its purpose is to further improve the energy efficiency of the model while ensuring model performance. The schematic diagram is shown in 3.7. Specifically, the principle of scale adaptive scaling can be divided into the following steps:
[0057] 1) Initialization: At the beginning of training, a suitable starting model size is selected based on the performance of the device and the task requirements. Starting model size determination: This size is usually determined based on the computing power and storage space of the device to ensure that the model can run efficiently on the device. 2) Dynamic adjustment: During the training process, the performance of the model and the use of computing resources are monitored in real time. When it is found that the performance of the model reaches a bottleneck at the current size, or the computing resources are used too much, the model will automatically adjust its size to achieve a balance between performance and computing resources. 3) Scale search: The best model size is found through a technique called "scale search". Scale search tries different model sizes and evaluates the performance of the model on the validation set. The size that achieves the best balance between performance and computing resources is selected as the new model size. 4) Update model: After finding the new model size, the width and number of layers of the model are updated according to the new size. This process is performed dynamically to adapt to different devices and task requirements. In short, the principle of scale adaptive scaling is to dynamically adjust the model size during model training to improve the energy efficiency of the model while ensuring model performance. This technology enables the algorithm model to achieve high performance and efficiency under various equipment and task requirements.
[0058] Scaling principle Figure 5 shown.
[0059] As a convolutional neural network architecture used in computer vision tasks, the deep separable convolutional network achieves the goal of improving network efficiency and accuracy by splitting the traditional convolution operation into two steps: deep convolution and point-by-point convolution. This architecture performs convolution operations on each channel of the input feature map separately through deep convolution, using smaller convolution kernels such as 3x3 to effectively reduce the number of parameters and focus on the extraction of local features. Subsequently, point-by-point convolution enhances the nonlinear ability of the model by combining information from different channels. The deep separable convolution is used to replace the original convolution module in the MBConv module. This reduces the model parameters to achieve lightweight.
[0060] The following is a specific experiment. When the mine environmental monitoring system captures a photo of a vehicle, it is sometimes unable to accurately indicate whether the photo captured is the front of the vehicle, the rear of the vehicle, or the roof of the vehicle. Generally, based on the conventional left-in-right-out principle or custom rules, it distinguishes whether the license plate number of the front of the vehicle or the license plate number of the rear of the vehicle needs to be identified, which often results in many false alarms. The purpose of this invention is to solve the problem of identifying the front and rear of vehicles in mines, and to propose a lightweight scale adaptive scaling (LSAN) method for identifying the front and rear of vehicles. The front and rear pictures of the vehicle are as follows: Figure 6As shown, the algorithm's accurate recognition of the head and tail of the vehicle will have important practical significance for the recognition and capture of license plate information. The present invention determines the optimal network structure and network performance of the LSAN algorithm through experiments. And compares it with other complex networks VGG16, ResNet34, EfficientNet, and DBPSNet.
[0061] The constructed lightweight adaptive scaling network model LSAN will be used to identify and classify the front and rear of the mine truck using 12,211 pictures of data, including 4,073 pictures of the front and 4,065 pictures of the rear, and 7,789 pictures of special vehicles that the original system cannot identify. This data set is named Truck-20000. The experiment is divided into two steps: the first step is data partitioning processing, the data set is divided by python code, and the original data set is divided into training set and test set, which are saved in the target folder. The target folder is mainly divided into train folder and test folder. When the overall data is divided, the ratio of training set to test set is set to 3:2, which are used for training and testing respectively. The second step is to use the model to train the divided data first to obtain the training model, and then use the trained model to test the data of the test set to obtain the test results, and continuously adjust the model parameters to find the best model for identifying the front and rear of the mine truck on this data set. Figure 7 The distribution of the number of training sets and test sets in the dataset is shown.
[0062] Development environment and network parameters:
[0063] The platform is developed based on Python language, using PyCharm 2020.3.3x64 and Anaconda32020.07 (Python 3.9 64-bit) as the development tools of the platform.
[0064] The parameter settings during network training are shown in Table 1. In the field of supervised learning and deep learning, the learning rate (Ir0) plays a key hyperparameter role, which affects whether the objective function can stabilize at the local minimum and how fast it stabilizes. A higher learning rate at the beginning can promote rapid learning of the network and help the model approach the optimal solution faster. However, as the training progresses, it may cause large oscillations in the later stages of training, and sometimes even cause the loss function to oscillate around the minimum, making it difficult for the model to accurately reach the optimal state. Therefore, the method adopted in this chapter is to start from the initial value, then keep it constant, and then perform exponential decay. The initial value is set to 0.01, the decay factor is 0.8, and the learning rate rise epoch is set to 100. The momentum is set to 0.9. Momentum is a commonly used acceleration technology in the gradient descent method, mainly used to solve the problem of ill-conditioned Hessian matrix; weight decay (weight_decay) can prevent overfitting. In the training model train_model, a parameter best_model_wts is defined to store the weights and bias coefficients that need to be learned during the training process. Then, batch normalization and dropout are enabled to compress the data dimensions and remove dimensions with a dimension of 1. Variable can be regarded as a wrapper of a tensor. It not only contains the contents of the tensor, but also contains information such as gradients. Therefore, the Variable data structure is often used in neural networks. Receive the returned value and take the value with the highest probability. Set the gradient to zero, calculate the loss, then return the loss, update the parameters, and finally save the training model. The data width is 1920 and the height is 1080, which is not suitable for training. Therefore, the data needs to be preprocessed, and the data is processed into a width and height of 256 and placed in the bishe-enddata2 folder. The batch size is set to 8, the training round is set to 10, the dataset image processing size is set to 256, the category is set to 3, and the model name used is set to LSAN-b0.
[0065] Table 1 Network training parameters
[0066]
[0067] Module function design:
[0068] (1) Mixup data enhancement
[0069] Mixup is an innovative data augmentation technique that performs data augmentation based on a simple data-independent principle
[50] and generates new training examples and their labels through linear interpolation. The final processing of the labels is shown in the following formula:
[0070]
[0071] The label processing of this method can be expressed by the following formula, where (x i ,y i ), (x j ,y j ) represents the pair of training samples selected from the original data set and their corresponding labels. λ is the parameter that follows the β distribution, in the form of λ:β(α,α) where the density distribution function of β is as follows Figure 3 As shown in .10, the range of α is [0, +∞]. Here, α is a hyperparameter. The increase of its value will lead to an increase in training error, but it will also improve the generalization of the model. When α tends to infinity, the model will return to the original training method. The probability density function of the β distribution Figure 8 shown.
[0072] When building the training model, this chapter defines a parameter called best_model_wts to store the weights and bias coefficients that need to be learned during the training process. Next, this chapter turns on batch normalization and discard operations to compress the data dimension and reduce computational complexity. This chapter also compresses the label data dimension from one dimension to zero dimension for model processing. During the model training process, this chapter uses the Variable data structure, which contains not only the data of the tensor but also the gradient information. This chapter receives the value returned by the model and takes the value with the highest probability as the prediction result. After calculating the loss, this chapter sets the gradient to zero to update the parameters. Finally, this chapter saves the trained model. This chapter first trains the ResNet34 model and the LSAN-b0 model of the present invention. In the initial stage, this chapter only trained for 10 epochs to better compare the convergence speed of the two models under a small number of experiments. The running effect and convergence speed of LSAN-b0 are significantly better than ResNet34 during the experiment. Under the same experimental equipment and environment, the LSAN-b0 model of the present invention has certain advantages.
[0073] When loading data, this chapter uses the data loading module to import data, retain the best model, and dynamically set the learning rate. This callback mechanism monitors performance indicators. If no improvement in model performance is observed within the set number of training cycles with patience, the learning rate will be reduced. After reducing the learning rate, the system will go through a cooldown period before resuming normal operation.
[0074] The method of the present invention is tested on the Truck-20000 dataset at different iteration times. The detailed experimental results are shown in Table 2. As can be seen from the table, the LSAN-b0 algorithm is convergent on the training set of the front and rear of the mine truck. The results of the algorithm on the further test set are shown in Table 3.4.
[0075] Table 2 Experimental results of LSAN-b0 algorithm
[0076]
[0077] Comparison of experimental results of the LSAN algorithm of the present invention and other four algorithms on the Truck-20000 dataset:
[0078] DBPSNet is an early algorithm developed by the author for vehicle front and rear recognition. The experimental results of five algorithms, VGG16, ResNet34, DBPSNet, EfficientNet, and LSAN, are statistically analyzed and listed as shown in Table 3.
[0079] Table 3 Comparison of experimental results of four algorithms on Truck-20000 dataset
[0080]
[0081]
[0082] The pre-training of the five algorithms was all done on the ImageNet dataset. Finally, the training was done on the Truck-20000 dataset to fine-tune the parameters and conduct tests. The LSAN algorithm achieved the highest accuracy of 98.67% in the test set recognition rate.
[0083] The model of this application changes in the test set Acc and Loss as the epoch increases as follows Fig.10 As shown, the comparison chart between this application and ResNet34 model training is as follows Fig. 9 As shown, Fig. 9 (a) and (b) are the training results of the ResNet34 model. Fig. 9 (c) and (d) are the training results of the model of this application
[0084] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.
Claims
1. A lightweight scale-adaptive zooming vehicle front and rear recognition method, characterized in that: Methods include: Acquire an image to be recognized, input the image to be recognized into a vehicle front and rear recognition model, and obtain a recognition result, wherein the vehicle front and rear recognition model is an improved efficient network model, and the improved efficient network model includes a nine-layer structure, and the MBConv1 layer in the nine-layer structure includes a first convolutional layer, a first proxy normalization layer, an attention CA layer, a second convolutional layer, a second proxy normalization layer, a third convolutional layer and a fourth convolutional layer connected in sequence, and the output of the fourth convolutional layer is multiplied by the input of the MBConv1 layer as the overall output of the MBConv1 layer.
2. A lightweight scale-adaptive zooming vehicle front and rear recognition method according to claim 1, characterized in that: The attention CA layer is a coordinate attention module. The input of the attention CA layer passes through the X average pooling and Y average pooling in the layer respectively, and then passes through the first fully connected layer together, and then passes through the first activation function layer, and then passes through the second fully connected layer and the second activation function layer respectively. The output at this time is multiplied by the input of the attention CA layer to obtain the output of the attention CA layer.
3. A lightweight scale-adaptive zooming vehicle front and rear recognition method according to claim 2, characterized in that: The first activation function layer is a swish activation function layer, and the second activation function layer is a sigmoid activation function.
4. The lightweight scale-adaptive zooming vehicle front and rear recognition method according to claim 1, characterized in that: The proxy normalization layer includes a group normalization module or a layer normalization module and an activation function. The calculation process inside the proxy normalization layer is: The output of the group normalization module or the layer normalization module is assimilated into a Gaussian proxy variable y, the Gaussian proxy variable y is multiplied by the learning parameter γ and the learning parameter β is added, and then the normalization parameter z is obtained through the activation function to obtain a non-normalized proxy variable Y that obeys the normal distribution, the non-normalized proxy variable Y is multiplied by the learning parameter γ and the learning parameter β is added, and then the normalization parameter Z is obtained through the activation function, the normalized distribution is calculated based on the normalization parameter z and the normalization parameter Z, and the normalized result is output as the output of the proxy normalization layer, and the proxy normalization layer also includes additional regularization calculations.
5. The lightweight scale-adaptive zooming vehicle front and rear recognition method according to claim 1, characterized in that: The normalized distribution is:
6. The lightweight scale-adaptive zooming vehicle front and rear recognition method according to claim 1, characterized in that: The distribution of the non-normalized proxy variable Y is in, and represents the mean of the learning parameters.
7. The lightweight scale-adaptive zooming vehicle front and rear recognition method according to claim 1 is characterized in that: During the training process of the improved efficient network model, the starting model size is first confirmed as the current size, and then the performance and computing resources during model training are monitored. When it is found that the performance of the model reaches a threshold or the computing resources reach a threshold at the current size, the current size is adjusted, and the width and number of layers of the efficient network model are updated according to the adjusted current size.
8. The lightweight scale-adaptive zooming vehicle front and rear identification method according to claim 1, characterized in that: The nine-layer structure is as follows: The first layer structure includes the first model convolution layer, normalization layer and activation function layer; The second layer structure is the MBConv1 layer and six consecutive MBConv6 layers; The ninth layer structure includes the second model convolution layer, pooling layer and fully connected layer.
9. A lightweight scale-adaptive zooming vehicle front and rear identification method according to claim 8, characterized in that: The MBConv6 layer includes an MBConv1 layer, a Depwise convolution, an SE layer, a convolution layer, and a random dropout layer connected in sequence, and the output of the MBConv6 layer is the product of the input of the MBConv6 layer and the output of the random dropout layer.
10. The lightweight scale-adaptive zooming vehicle front and rear recognition method according to claim 1, characterized in that: The convolutional layer in the efficient network model is a depth-wise separable convolution.