Rapid board identification method based on YOLO model

By optimizing channel sparse regularization and channel pruning for the YOLOv5 model, the existing wood board recognition technology is solved, and more efficient and accurate wood board recognition effect is achieved.

CN119832381APending Publication Date: 2025-04-15GUANGZHOU QINGBEI INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411686101.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-24
Publication Date
2025-04-15

AI Technical Summary

Technical Problem

The existing wood board identification technology has problems such as inefficiency, large errors and poor adaptability, making it difficult to quickly and accurately identify different types of wood boards.

Method used

Based on the YOLOv5 model, through channel sparse regularization and channel pruning technology, the model is optimized to automatically identify unimportant channels, reduce the redundant parameters and calculation amount of the model, and improve the accuracy of the model through fine-tuning.

Benefits of technology

A more compact and efficient wooden board recognition model is realized, which improves recognition accuracy, reduces the weight volume of the model, enhances the running speed, and can achieve accurate recognition in a fast-passing wooden board scene.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119832381A_ABST
    Figure CN119832381A_ABST
Patent Text Reader

Abstract

The invention discloses a rapid board identification method based on a YOLO model. The method comprises the following steps: making a high-quality board data set; labeling the wood board data set of each state; inputting the data set into the improved YOLOv5 network model; training an original DNN model; channel trimming, filter trimming, connecting layer trimming and layer trimming are conducted on the model; evaluating the model and finely adjusting the data; processing the obtained data output by the model to obtain a prediction result, measuring the identified data, and comparing the difference between the identified data and the original data of the YOLOv5 network; and connecting the model to a high-precision camera, and packaging to form a high-speed and accurate wood board detection system, so that high-precision and high-speed rapid industrial wood board detection is realized, and corresponding center point data is output. Through the optimized YOLO model, the wood board can be quickly identified, and intelligent operation of the robot on the wood board is facilitated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of artificial intelligence and deep learning model optimization, and in particular relates to a method based on channel sparse regularization and channel pruning for optimizing a YOLOv5 target detection model to quickly and accurately identify wooden boards. Background Art

[0002] In the current wood processing industry, quickly and accurately identifying different types of wood boards is a key step to improve production efficiency and ensure product quality. Object detection technology has made a huge leap from traditional manual methods to today's deep learning methods. Traditional wood board recognition methods have problems such as low efficiency, large errors and poor adaptability. In order to overcome these problems, this method is optimized based on the YOLOv5 model: first, through channel sparse regularization training, the scaling factor is associated with the channel of each convolutional layer, and sparse regularization is applied to automatically identify unimportant channels; then these unimportant channels are pruned using a small scaling factor to reduce the redundant parameters and computation of the model; finally, the pruned model is fine-tuned to achieve an accuracy comparable to or even higher than the original model, thereby obtaining a more compact and efficient wood board recognition model. Summary of the invention

[0003] Technical solution: The present invention provides a method for quickly identifying wooden boards based on the YOLOv5 model, as follows.

[0004] Step 1.1, you need to collect enough data sets. ,in represents the i-th image, Represents the label of the corresponding image. The image is flattened from 640*640 resolution into a vector of 1228800 length and input into the model.

[0005] Step 1.2, the image needs to be set to a standard size W*H, and the pixel values ​​need to be normalized to the interval [0,1], that is This can effectively prevent the numerical overflow of the model and make the gradient more stable. The features of the normalized data are consistent, which improves the convergence speed of the model. If normalization is not performed, the scale differences of different features may cause the optimization algorithm to have too large or too small steps in some directions, thereby affecting the convergence speed.

[0006] Step 2.1, use the pre-trained YOLOv5 model as the base model and load the pre-trained weights. Suppose the initial model is , where θ represents the model parameters. Then, the scaling factor is associated, and the scaling factor is associated with each channel in the convolution layer from the BN layer of the native model. Let The convolutional layer output of layer is The scaling factors of each channel affect each other.

[0007] Step 2.2, during training, apply sparse regularization to these scaling factors. .

[0008] Step 2.3, this formula is our key innovation. The introduction of the sparse induced penalty imposed by the scaling factor can continuously optimize some erroneous data and effectively evaluate the accuracy of the data. (x, y) represents the training input and target, and W represents the trainable weight, which can effectively reduce the loss of pre-training.

[0009] Step 2.4, we also added additional regularization parameters to the loss function of target detection, which can effectively prevent overfitting, improve the generalization ability of the model, control the model complexity, and optimize the training process. The regularization parameters penalize the complexity of the model, limit the size of the weights, help the model learn more general features, avoid overfitting the noise in the training data, and thus perform better on new, unseen data.

[0010] Step 2.5, according to the scaling factor value of each channel during training, set a pruning threshold. This threshold will be relatively small to retain more valid channels.

[0011] In step 2.6, the channels whose scaling factor values ​​are less than the threshold and their corresponding weight matrices are deleted to generate a pruned model.

[0012] In step 2.7, we assume is the set of channels that need to be pruned. Delete all channels and corresponding weight matrices in the set to generate a pruned model. Then evaluate the performance of the model on the validation set.

[0013] In step 2.8, we also need to fine-tune the model. First, we need to set a lower learning rate to avoid over-adjusting the model parameters. We use the labeled and pre-processed wooden board image dataset to fine-tune the pruned model to further optimize the model performance.

[0014] Step 3: Process the model output data to obtain the predicted results and evaluate the results.

[0015] Furthermore, step 2 is as follows: a regularization term related to these scaling factors is added to the loss function; during the training process, the optimization algorithm will minimize the original loss and the regularization term at the same time, causing the scaling factors of unimportant channels to gradually decrease and approach zero; ultimately, the outputs of these redundant channels are naturally suppressed, the model complexity is reduced, the computational efficiency is improved, and the generalization ability is enhanced.

[0016] Furthermore, step 2 is as follows: This regularization term helps to make the scaling factors corresponding to those unimportant channels converge to zero, thereby achieving natural suppression of these redundant channels. This process can not only reduce the computational overhead of the model and improve operating efficiency, but also enhance the generalization ability of the model, ensuring that the model is more focused on the key features that contribute to the task. In this way, the model can reduce complexity and reduce the risk of overfitting while maintaining or even improving performance.

[0017] Furthermore, step 3 is as follows: The way we evaluate the performance of the model is to first determine whether its accuracy is consistent with or higher than the original model. The formula is ,in and Represent the number of true positives and false positives of the pruned model, respectively.

[0018] Furthermore, step 3 is as follows: In order to more completely evaluate our new model, it is necessary to adjust and optimize the hyperparameters of the evaluation results. The evaluation indicators include precision, recall rate and F1 score. The specific formula is , these values ​​can effectively evaluate the performance of our fine-tuned model.

[0019] Beneficial effects: Compared with the existing technology, the present invention has the following significant advantages: by improving the YOLOv5 model, the accuracy of wooden board detection is improved, the weight volume obtained by the model will be reduced, the running speed of the model will be increased, and it will help the model to achieve accurate recognition in the scene of fast-passing wooden boards.

[0020] Figure 1 It is the overall flow chart of the present invention; Figure 1 As shown, the present invention provides a method for quickly identifying wooden boards based on the YOLO model, comprising the following steps.

[0021] Step 1.1, data collection, we need to collect different types of wood board images, including wood boards of various textures, colors, and shapes. Make sure that the dataset contains enough samples to cover the diversity in actual application scenarios and ensure that the system can adapt to different environments and different needs.

[0022] Step 1.2: After data collection, the collected images need to be preprocessed, including cropping, scaling, normalization, etc., to ensure that the input image quality is relatively high, and the size and format meet the requirements of the YOLOv5 model, and to create a data set. The data set is divided into a training set, a validation set, and a test set.

[0023] Step 2.1, use the pre-trained YOLOv5 model as the base model, load the pre-trained weights, and select the most suitable pre-trained weights according to different needs.

[0024] Step 2.2, adding modules to the original YOLOv5 model requires channel sparse regularization training on the model head, associating the scaling factors from the BN layer of the native model with each channel in the convolutional layer. During the training process, sparse regularization is applied to these scaling factors to automatically identify unimportant channels.

[0025] Step 2.3, continue to debug according to our actual scenarios, set appropriate sparse regularization coefficients, balance the accuracy and sparsity of the model. Use the labeled wooden board image dataset for training until the model converges.

[0026] In step 2.4, it is necessary to determine the corresponding pruning threshold for different requirements. According to the scaling factor value of each channel during the training process, a pruning threshold is set. In order to deal with the scenario of the wooden board, the model mostly chooses a smaller threshold to retain more valid channels.

[0027] Step 2.5, perform pruning to delete the channels whose scaling factor values ​​are less than the threshold and their corresponding weight matrices to generate a pruned model.

[0028] In step 2.6, evaluate the performance of the pruned model on the validation set to ensure that there is no significant drop in accuracy.

[0029] In step 2.7, fine-tune the configured model and set a lower learning rate to avoid over-adjusting the model parameters.

[0030] In step 2.8, fine-tune the pruned model using the labeled wood board image dataset to further optimize the model's performance and ensure that it can run stably in actual scenarios.

[0031] Step 2.9, evaluate the performance of the fine-tuned model on the test set, and make necessary hyperparameter adjustments and optimizations based on the evaluation results.

[0032] Step 3. After configuration is complete, export the model and export the fine-tuned model to the format for TensorFlow Lite deployment.

[0033] Step 3.1, integrate the optimized model into the actual wood board recognition system and combine it with the automated equipment on the production line. The model is responsible for providing data of the corresponding center point.

[0034] Step 3.2, continuously monitor the performance of the model in actual applications to ensure its stability and reliability in different scenarios.

[0035] Step 3.3: In subsequent maintenance, change the model parameters according to different scenario requirements to suit more practical scenarios.

[0036] Furthermore, step (1) is as follows: we need to use a high-precision camera to collect high-resolution images of the field, and after preprocessing, we need to filter out blurry photos to prevent them from affecting the accuracy of the model.

[0037] Furthermore, step (2) is as follows: When debugging the original model parameters, we need to consider the stability of the model and deal with various possible situations, such as the problem of easy misidentification caused by stacking wooden boards and wooden boards close to each other. These situations have a great impact on our model parameters and should be given priority consideration during the debugging process.

Claims

1. A method for rapid identification of wooden boards based on the YOLO model, characterized in that: include: (1) Take pictures of industrial wood boards at the construction site to create a corresponding data set. (2) Label and clean the data set and place it in the native format of YOLOv5. (3) Fine-tune the YOLOv5 model. For the initial network, first use channel sparse regularization to train, then prune the channels with a small scaling factor to obtain a fine-tuned and pruned network, and finally generate a more compact network. By adding scaling factors between each batch normalization (BN) layer and the convolution layer, these factors are associated with each output channel of the convolution layer to quantify the importance of each channel. In addition to the conventional loss function during training, we also add a sparse regularization term based on the L1 norm. This regularization term helps to push the scaling factors corresponding to those unimportant channels to converge to zero, thereby achieving natural suppression of these redundant channels. (4) The scaling factors from the BN layer of the native model are associated with each channel in the convolutional layer. Sparse regularization is applied to these scaling factors during training to automatically identify unimportant channels. This process not only significantly reduces the number of model parameters and computational complexity, but also avoids unnecessary computational overhead and potential overfitting risks. However, in order to compensate for the accuracy loss that may be caused by the pruning process and further optimize the model performance, the pruned model is then carefully fine-tuned. This stage of training allows the model to readjust the weight distribution between the remaining channels to better adapt to the new structural features and ultimately reach or exceed the detection accuracy of the native model. Values ​​with smaller scaling factors will be pruned. After pruning, a compact model is obtained, which is then fine-tuned to achieve higher accuracy than the normal network. (5) The model is tested on various data and the best weights are selected for practical industrial applications.

2. According to the method for rapid identification of wooden boards based on the YOLO model in claim 1, it is characterized in that: Step (2) is as follows: Use the labeling software labelimg to label the collected data set in YOLO format, create a data set, divide the data set into a training set, a validation set, and a test set, and filter out erroneous data for data cleaning.

3. The method for rapid identification of wooden boards based on the YOLO model according to claim 1, characterized in that: Step (3) is as follows: Batch normalization (BN) is usually inserted after the convolution and fully connected layers and before nonlinear processing, from convolution to BN and then to ReLU. In order to make each dimension a standard Gaussian distribution, that is, a Gaussian distribution with a mean of 0 and a variance of 1, the following formula can be applied: ;in The new value of the kth sample point after normalization. is the original value of the kth sample point, and E represents the mathematical expectation. The processed value can eliminate the influence of the dimensions between variables, so that different features can be compared at the same scale, which is beneficial to the performance of the algorithm. Then batch normalization can be performed. The formula for batch normalization is as follows: ; where h is the activation value vector input to the current layer, which can be the activation value set of all samples in a batch. E(h) is the mean of the input activation value vector, that is, the average value of all sample activation values. is the variance of the input activation value vector h, which reflects the fluctuation of the activation value. β and γ are learnable parameters, β is used for shift and γ is used for scale. They exist to allow the model to have a certain degree of flexibility after normalization, and to adjust the distribution of activation values ​​according to actual needs. The core idea of ​​this module is to normalize the data in each batch so that they have the same statistical properties (mean close to 0, variance close to 1), which can alleviate the problem of internal covariate shift, speed up the gradient descent, and also help prevent overfitting.

4. The method for rapid identification of wooden boards based on the YOLO model according to claim 1, characterized in that: Step (4) is as follows: the output of each channel is multiplied by a scaling factor, and then the network weights and these scaling factors are jointly trained to apply sparse regularization to the latter. Finally, channels with small factors are pruned and the pruned network is fine-tuned. The training objective of the method is given by the following formula: ; where (x, y) denotes the training input and target, W denotes the trainable weights, the first term corresponds to the standard training loss of CNN, g(·) is the sparsity-inducing penalty imposed on the scaling factor, and λ balances the two terms. g(s)=|s|, which is known as the L1-norm and is widely used to achieve sparsity.

5. The method for rapid identification of wooden boards based on the YOLO model according to claim 1, characterized in that: Step (5) is as follows: connect the camera and the platform test algorithm to detect the real-time situation of the wooden board, and give the best weight to the actual work production.