A wood surface defect detection method based on improved YOLOv5l network
Through the improved YOLOv5l network model, combined with the improvement of adaptive anchor frame and FPN structure, the problem of unsatisfactory accuracy and efficiency of wood surface defect detection in the prior art is solved, and high-precision and low-cost wood defect detection is achieved, which is suitable for actual industrial needs.
Patent Information
- Application Number
- CN202210015819.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-01-07
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2042-01-07
AI Technical Summary
The prior art has poor identification accuracy and efficiency in wood surface defect detection, and the manual inspection cost is high and the efficiency is low.
Using the improved YOLOv5l network model, the high-precision detection of various types of wood defects is achieved through the improvement of adaptive anchor frame and FPN structure, combined with pseudo-label fine-tuning and NWD calculation methods.
It significantly improves the identification accuracy and efficiency of wood surface defect detection, reduces detection delay, adapts to actual industrial needs, and reduces labor costs.
Smart Images

Figure CN114359235B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of wood surface defect detection, and in particular to a wood surface defect detection method based on an improved YOLOv5l network. Background Art
[0002] Plywood is one of the most common and widely used wood panels among artificial panels. Plywood is made of different thin wood boards pasted and pressed together, which can save a lot of wood. With forest resources becoming increasingly scarce today, using plywood is a very good way to save energy. However, during the production process, cracks, worm holes, dead knots, loose knots and other defects may exist on the surface of a single thin wood board. According to national standards, wood defects can be divided into 10 categories. Figure 2 shows several common wood defects. These defective woods are not conducive to the next step of production and will affect the progress of veneer manufacturing. Most of the methods for detecting such defects in the production line use the following method: Figure 1 The manual inspection method shown. Due to factors such as different manual inspection standards, poor classification accuracy, and low efficiency, the quality of wood will be affected and the production speed of the product cannot be guaranteed. Moreover, with the continuous increase in labor prices, the production cost of manual inspection will also increase significantly.
[0003] In view of the above problems, finding a high-precision, low-cost and highly stable method to detect and identify wood defects is a major problem that the wood production industry needs to solve. In order to avoid being affected by subjective factors of workers, the use of machine vision and intelligent recognition technology to replace artificial vision to detect wood defects can effectively make up for the shortcomings of manual detection, reduce labor costs, greatly improve the utilization rate of wood, and at the same time improve the economic benefits and social value of enterprises. The target detection algorithm in deep learning that has developed rapidly in recent years can just solve this problem. However, due to the various forms, various types, large defect scale changes, and a large number of small targets of wood surface defects, the recognition accuracy and efficiency of existing detection algorithms are not very ideal. For example, Chinese patent CN 110310259 A discloses a wood knot defect detection method and related devices based on an improved YOLOv3 algorithm, but the surface defect categories of the wood strips it targets are single, with only two types of dead knots and live knots, while there are more defect categories in actual demand. Summary of the invention
[0004] The purpose of the present invention is to provide a wood defect detection method based on an improved YOLOv5l network, which can not only detect various types of wood surface defects, effectively improve the recognition accuracy and efficiency, and reduce the detection delay, but also deploy the model locally and in the cloud service, and can perform incremental learning of wood defects, cope with defect diversity, and meet the actual needs of the industry.
[0005] To achieve the above object, the present invention adopts the following technical solutions:
[0006] A wood surface defect detection method based on an improved YOLOv5l network, the method comprising the following steps:
[0007] S1. Obtain a public wood defect dataset as dataset one, and process the images and labels in dataset one.
[0008] S2. Use the improved YOLOv5l network model to pre-train the dataset 1. First, uniformly scale the images in the dataset 1 and send them to the improved YOLOv5l network model. The YOLOv5l network model first selects a suitable anchor frame according to the size of the wood defect image using the adaptive anchor frame method, and extracts features through the Backbone layer to extract the feature map of the wood defect image. Then, the Neck layer is used to mix and combine the image features of the upper-layer feature map. Finally, the output layer predicts the image features, and the NMS method is used to screen multiple prediction frames. During the screening process, the NWD calculation method is used to generate bounding boxes and prediction categories to obtain the trained network model model1.
[0009] S3, collecting real-life wood data as data set 2, using a sliding window method, randomly selecting a number of images from data set 1 processed by step S1 for cropping, cropping defective parts in the images separately, and storing the cropped defective parts in data set 2 to expand data set 2.
[0010] S4. Divide the data set 2 into a training set, a validation set and a test set, wherein the defects in the wood images have been marked in the training set and the validation set, and the images have wood defect labels. The defects in the wood images in the test set have not been marked, and the images do not have wood defect labels. The trained network model model1 is used to predict the test set, and the wood images with defects in the test set are labeled, and the labels greater than the set prediction threshold are used as pseudo labels.
[0011] S5. After integrating the training set and the test set in the data set 2, the training set is input into the network model model1 to train the network model model1, and the trained network model model2 is obtained. The best network model best mode is selected from the network models model1 and model2 through the validation set.
[0012] S6. Locally deploy the network model best mode, collect thin wood board images in real time and input them into the network model best mode. The network model best mode outputs the category and quantity of wood surface defects.
[0013] Furthermore, the connection layer a of the FPN structure in the improved YOLOv5l network model consists of three branches, namely a 1×1 convolutional layer branch and two 3×3 convolutional layer branches with void rates ar=1 and 2 respectively.
[0014] Furthermore, the adaptive anchor frame method specifically includes the following steps:
[0015] First, manually calculate the initial value of the anchor box, count the aspect ratios of all label boxes in dataset one, obtain the maximum aspect ratio of the target, recalculate the anchor box and replace the default anchor box with the new anchor box data; then, check the annotation information in dataset one, calculate the best recall rate of the annotation information of this dataset for the default anchor box, and when the best recall rate is greater than or equal to 0.85, there is no need to update the anchor box; if the best recall rate is less than 0.85, it is necessary to recalculate the anchor box that conforms to this dataset.
[0016] Furthermore, the NWD calculation method is:
[0017]
[0018] Where C is a constant related to the data set,
[0019]
[0020] Among them, cx a ,cy a ,w a ,h a Represents the location information of the prediction box A, cx b ,cy b ,w b ,h b represents the location information of the prediction box B, ‖·‖ F is the Frobenius norm, N a represents the Gaussian distribution model of the prediction box A, N b Represents the Gaussian distribution model of the prediction box B, NWD(N a , N b ) represents the similarity measure between prediction box A and prediction box B. The NMS method is used to screen the prediction boxes. For example, if two prediction boxes are predicted for a certain type of defect target: prediction box A and prediction box B, the NWD calculation method is used to calculate the similarity relationship between the two prediction boxes. The similarity relationship of the prediction boxes is calculated based on the position information of the boxes.
[0021] Compared with the prior art, the advantages of the present invention are:
[0022] (1) The existing technology only has samples of dead knots, slip knots and no defects in the data set for wood detection defects. The present invention increases the defects to 9 categories, namely dead knots, slip knots, resin, cracks, crack knots, decay, sound knots, color difference, and worm holes. In view of the diversity of wood defects mentioned above, the present invention uses two data sets, and extracts defect features from data set one using the idea of sliding windows and uses this to expand data set two. This essentially can obtain sufficient and high-quality data samples, and then use the pseudo-labeling method to fine-tune the model and select the best model from the generated models. This makes the performance of the model obtained by the final training more robust.
[0023] (2) The accuracy of model detection is not only related to the data set, but mainly to the detection network structure used. According to the experimental results on the MC COCO data set, the AP value of the YOLOv5l model in the test set is 2.2 higher than that of YOLOv3. The speed of YOLOv5 is also faster and the size of the model is reduced by 16% compared with YOLOv3. Therefore, the present invention uses the YOLOv5l model to greatly improve the accuracy and real-time performance of target detection. The method for identifying multiple types of wood defects can meet the requirements of industrial accuracy and real-time performance. The task of identifying small targets such as wood defects is to extract the features of wood defects as much as possible. While based on the advantages of the network structure of Yolov5s, the present invention makes adjustments based on Yolov5 to address the difficulty of detecting small targets such as wood defects, and realizes an improved YOLOv5l network, which greatly increases the possibility of extracting wood defect feature maps and improves the accuracy and speed of detecting multiple wood defects. Specifically, the present invention modifies the Neck part of the YOLOv5l network structure, and further processes the top feature map of FPN through a hole convolution. The hole convolution can improve the perception field of view compared with the standard convolution. Since the scale of the knot defect among the nine types of defect images is smaller than that of the decay defect, the feature map of each type of defect can be improved by modifying the FPN layer. It has a good effect on the inconsistency of wood defect size.
[0024] (3) Due to the phenomenon of overlapping predicted borders in wood defect detection, the original network framework uses the weighted NMS method to screen the final predicted box. The method used in this method is mainly based on the IOU measurement method. The sensitivity of this method to wood defects will cause the IOU values of many predicted boxes to be lower than the set threshold (Nt), thereby resulting in false positive predictions. The present invention modifies the IOU measurement method of the weighted NMS and changes it to the NWD measurement method. The CIoU loss function is also based on the IOU measurement. It is very sensitive to small target position deviations such as wood defects. The loss function of the bbox is modified for this, and the CIoU loss function is changed to the NWD loss function.
[0025] (4) In view of the fact that there are many types of wood defects and the defect sizes vary, the present invention manually calculates the anchor frame before pre-training and replaces the initial value of the anchor frame in the original frame. After calculation by the k-means++ algorithm, the number and size of the obtained candidate frames are more suitable for various wood defects and are more accurate than before the improvement.
[0026] (5) In view of the fact that sample variability exists in the process of wood defect detection, which may cause the initial model to have a reduced accuracy during the detection process, the present invention proposes to use cloud services to save image data and realize model optimization and incremental learning. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 It is a schematic diagram of manual sorting of thin wood boards;
[0028] Figure 2 is a schematic diagram of wood surface defects, where Figure 2a The wood defects are color difference, Figure 2b The wood defect in the Figure 2c The wood defect in the wood is a dead knot;
[0029] Figure 3 It is a processing flow chart for improving the YOLOv5l network model;
[0030] Figure 4 It is the structural diagram of PFN and PAN in the improved YOLOv5l network model;
[0031] Figure 5 It is a schematic diagram of the hole convolution of the connection layer in the FPN structure in the improved YOLOv5l network model;
[0032] Figure 6 It is the architecture diagram of the improved YOLOv5l network model;
[0033] Figure 7is a flow chart of the wood surface defect detection method of the present invention;
[0034] Figure 8 It is a structural schematic diagram of the wood surface defect detection device in the present invention.
[0035] in:
[0036] 1. Thin wooden board, 2. Industrial camera, 3. Light source, 4. Conveyor belt, 5. Controller, 6. Carrier board, 7. Cloud server. DETAILED DESCRIPTION
[0037] The present invention will be further described below in conjunction with the accompanying drawings:
[0038] Use Figure 8 The detection device shown is used to detect surface defects of thin wood. Figure 8 As shown, the detection device includes a conveyor belt 4 for conveying wood, an industrial camera 2 for collecting wood images arranged above the conveyor belt 4, a pair of light sources 3 located on both sides of the industrial camera 2, a controller 5 for controlling the industrial camera, the conveyor belt and the carrier, and a cloud service end 7. In the specific implementation process, the lenses of the industrial cameras Basler Ace2 and Basler Lens are used for acquisition, and the light source is used to ensure the clarity of the acquired image. The industrial camera is used to collect data on defects in thin wood boards. The PC end uses Pycharm software for the model pre-training stage. The algorithm is based on the Pytorch framework, and the initial learning rate is set to 0.01, the cyclic learning rate is set to 0.2, and the learning rate momentum is 0.937. The optimizer uses SGD with momentum. A total of 300 training rounds are set, and the batch-size is 10. The PC end system is Ubuntu, using the docker image service, and using the NVIDIA GTX2080 Super graphics card to accelerate the training process. The trained model is deployed on the web through the flask framework, and the Jeston carrier is deployed in the local device.
[0039] like Figure 7 As shown in the figure, the wood surface defect detection method based on the improved YOLOv5l network of the present invention comprises the following steps: the detection device is powered on, a wooden board is placed on a conveyor belt, the conveyor belt transports the wooden board to the bottom of the industrial camera, the industrial camera collects the image of the wooden board, and transmits the collected image to be detected to the PC; the image to be detected is pre-processed and then input into the improved YOLOv5l network, and the detection image is detected by using the following steps: Figure 3 After the processing method shown is used to obtain the best network model, the defect category and location information of the image to be detected are obtained using the best network model. According to the inference result of the best network model, it is classified as defective or qualified, and the inference result is uploaded to the cloud service background data, which can be displayed on the front-end page.
[0040] like Figure 3 The processing flow chart of the improved YOLOv5l network model shown in the figure specifically includes the following steps:
[0041] (1) Obtain a public wood defect dataset as dataset 1, process the images and labels in dataset 1, and convert them into txt format.
[0042] The public wood defect dataset is a prior art, in which the dataset annotation information has format errors. The present invention corrects the erroneous information and performs data cleaning. The annotation information format is converted to adapt to the YOLOv5l network model, and the image is preprocessed, including cropping and segmenting the black edges of the original image; the purpose of this is to provide more accurate data for the following model training, which can improve the speed and accuracy of model training.
[0043] (2) Using the sliding window method, the random defect images in dataset one are cropped separately and classified into dataset two.
[0044] The data set in the present invention is divided into two parts, one of which is Dataset 1 based on public wood defect data, which contains more than 20,000 labeled wood surface defects, covering the 9 most common wood defects. Dataset 2 comes from data collected in real-time scenes, and Dataset 2 is manually annotated. This invention adopts a deep learning approach. First, the network model is pre-trained using Dataset 1, and then returned for tuning based on the training results. Then Dataset 2 is used to divide it into a 7:2:1 ratio for training, verification, and testing. The main processing flow is as follows:
[0045] A batch of unlabeled images (test set) in Dataset 2 are predicted, and labels greater than the prediction threshold are selected as pseudo labels. Pseudo labels can not only reduce the workload of manual annotation of Dataset 2, but also continue to train model1 in this way to improve the accuracy of the model. After the training is completed, the network model model1 continues to integrate the pseudo-label data (data labeled for the test set) and the training set in Dataset 2, and uses the integrated data to continue training model1. After the training is completed, model2 is obtained.
[0046] Through model training and verification, the total loss is calculated as the weighted sum of the labeled and unlabeled losses, and the calculation formula is as follows:
[0047] Loss=Labeled Loss+alpha*Unlabeled Loss
[0048] Among them, Labeled Loss (labeled loss value) = Loss1 = classification loss + localization loss + confidence loss, classification loss represents classification loss, localization loss represents positioning loss, and confidence loss represents confidence loss.
[0049] Alpha is a coefficient to the total loss of pseudo labels, which is a function of time t (epochs) and is given by the following formula:
[0050]
[0051] Among them, α f =3,T1=100,T2=600.
[0052] Unlabeled Loss (unlabeled loss value) = Loss1' = classification'loss + localization'loss + confidence'loss.
[0053] The best network model is selected through the validation set divided from the dataset 2. The specific selection steps are as follows: The network model model1 obtained by pre-training with the dataset 1 is used to determine the model hyperparameters in the model1 using the validation set divided from the dataset 2. The determination method is to calculate the loss function. The loss function formula is Loss1 = classification loss + localization loss + confidence loss, which means classification loss + positioning loss + confidence loss. Similarly, the loss function of the network model model2 is calculated using the validation set of the dataset 2. The calculation of the loss function is as follows: Loss2 = Labeled Loss + alpha * Unlabeled Loss. The best model is selected by comparing Loss1 and Loss2. Finally, the best model is selected by the loss value. The prediction threshold can be determined by clustering on the validation set, and the appropriate threshold can be selected by fine-tuning.
[0054] The present invention adopts the idea of sliding window to cut part of the image data in the public wood defect dataset 1 and retain the defective images. These defective images are combined with dataset 2 for the next training. In addition, the uneven distribution of defect types in dataset 1 is enhanced by conventional data enhancement methods (random vertical / horizontal folding, color space enhancement). Finally, Mosaic data enhancement is used to randomly scale, crop, and arrange the four images to form a 640*640 pixel image.
[0055] (3) Use the improved YOLOv5l network architecture to pre-train dataset 1, scale the image to 640*640 pixels, and select the appropriate anchor frame scheme through the adaptive anchor frame method.
[0056] like Figure 4-Figure 6 As shown in the figure, in YOLOv5, the Focus structure takes the structure of YOLOv5l as an example. The original 608×608×3 image is input into the Focus structure, and the slice and convolution operations are used to finally become a 304×304×32 feature map. Focus is used to compress the network layer to speed up. The CSP structure solves the problem of gradient information duplication in network optimization in other large convolutional neural network frameworks Backbone, and integrates the gradient changes from beginning to end into the feature map, thereby reducing the number of parameters and FLOPS values of the model. The Neck structure adopts the FPN+PAN structure, which can fuse features at multiple scales. The FPN structure performs top-down upsampling, so that the bottom feature map contains stronger semantic information of wood defects. The PAN structure performs bottom-up downsampling, so that the top feature contains the location information of strong wood defects. The two features are finally fused, so that feature maps of different sizes contain both semantic information and feature information of strong wood defects, ensuring accurate prediction of wood defect images of different sizes.
[0057] The improved YOLOv5l network proposed in the present invention improves the FPN structure. The top feature map c3 is further processed by the dilated convolution to generate p3. At this time, p3 and c2 are feature fused. The top connection layer a of the FPN structure consists of three branches, a 1×1 convolution layer branch, and two 3×3 convolution layer branches with dilated rates ar=1 and 2 respectively. The 3×3 dilated convolution layer with ar=2 can obtain more global context feature details and enhance the reasoning ability. Finally, after splicing the feature maps, a 1×1 convolution layer is used to fuse feature information. The improvement of this method uses different ar to improve the adaptability of the model to targets of different scales, and has a better effect on the inconsistency of the size of wood surface defects.
[0058] Before pre-training, the initial value of the anchor box is manually calculated, and the aspect ratios of all label boxes in the data set are counted. By finding that the maximum aspect ratio of the target is 5:1, the anchor box is recalculated and the 10 sets of new anchor box data are used to replace the default anchor box. Before starting training, the annotation information in the data set will be checked, and the best recall rate of the annotation information of this data set for the default anchor box will be calculated. When the best recall rate is greater than or equal to 0.85, the anchor box does not need to be updated; if the best recall rate is less than 0.85, the anchor box that conforms to this data set needs to be recalculated. Set the bpr parameter (that is, the basis for recalculating the anchor box) to 0.85, and the anchor box can be calculated multiple times. The appropriate anchor box scheme can be selected from the results obtained by manual calculation and kmean clustering method.
[0059] When images are trained, they are scaled. A common method is to scale the original images to a standard size and then feed them into the detection network. The detection network is an improved YOLOv5l network, which uses the YOLOv5l network to adaptively add the least black edges to the image. The calculation steps are as follows:
[0060] Step 1: Calculate the scaling ratio, calculate the scaling factor for the length and width of the image respectively, and select the smaller scaling factor.
[0061] Step 2: Multiply the length and width of the original image by a smaller scaling factor.
[0062] Step 3: Subtract the smaller of the calculated length and width from the larger one to get the height that needs to be filled. Then use the remainder method to get the value that needs to be filled at both ends of the image height.
[0063] (4) Through the above-mentioned image adaptation, the images in dataset 1 are adapted to the standard size and then sent to the detection network.
[0064] (5) The wood defect image enters the detection network, and the wood defect features are extracted through the Backbone mentioned above to generate a feature map. Then, the feature map of the upper layer is mixed and combined with the image features through the Neck layer.
[0065] (6) The image features are predicted through the output layer to generate bounding boxes and predicted categories.
[0066] In the post-processing of wood defect detection, the present invention adopts the NWD metric method for the screening of many target boxes. NMS is an indispensable part of target detection and is used to suppress redundant prediction bounding boxes. The IOU metric is applied, and the IOU metric standard formula is as follows:
[0067]
[0068] NMS processing flow, first, it sorts all the predicted boxes according to the score. Select the predicted box M with the highest score and suppress all other predicted boxes that have significant overlap with M (using a predefined threshold Nt). This process is recursively applied to the remaining boxes. The formula is as follows:
[0069]
[0070] However, the sensitivity of IOU to small objects will make the IOU values of many prediction boxes lower than Nt, resulting in false positive predictions. Therefore, the IOU metric in NMS is changed to the NWD metric, which can eliminate boxes with large similarity by calculating the similarity between prediction box A and prediction box B. The formula is as follows:
[0071]
[0072] Here, C is a constant related to the dataset.
[0073]
[0074] Where cx a ,cy a ,w a ,h a Represents the location information of the prediction box A, cx b ,cy b ,w b ,h b represents the location information of the prediction box B, ‖·‖ F is the Frobenius norm. N a express Gaussian distribution model of prediction box A, N b Represents the Gaussian distribution of the predicted box B Model ,NWD(N a , N b ) represents the similarity measure between prediction box A and prediction box B. The NMS method is used to screen the prediction boxes. For example, if two prediction boxes are predicted for a certain type of defect target: prediction box A and prediction box B, the NWD calculation method is used to calculate the similarity relationship between the two prediction boxes. The similarity relationship of the prediction boxes is calculated based on the position information of the boxes.
[0075] The output Bounding box loss function of the improved YOLOv5l network proposed in this invention changes the CIoU_Loss loss function that originally uses the IOU metric method to NWD_Loss (i.e. L NWD ) is used as the loss function. The Gaussian distribution of the predicted box P and the Gaussian distribution of the real box G are first calculated. After calculating the distance measurement between P and G, the similarity value is obtained through normalization. The calculation formula is as follows:
[0076]
[0077] Among them, N P is the Gaussian distribution model of the prediction box P(Prediction), N g is the Gaussian distribution model of the ground truth box G, L NWD Represents the loss function of the Bounding box, NWD(N p ,N g ) represents the similarity value between a predicted box and a true box. The loss value is used to back propagate and update the parameters, reducing the loss between the true value and the predicted value, making the predicted results of the obtained model more accurate.
[0078] The NWD measurement method overcomes the problems of scale and position sensitivity, and can improve the accuracy of NMS for small target detection of wood surface defects.
[0079] (7) Save the generated best.pt model file (model1).
[0080] (8) Collect the second real-life dataset and manually label it.
[0081] (9) Divide dataset 2 into training set, validation set, and test set in a ratio of 7:2:1.
[0082] (10) Use the trained network model model1 to predict a batch of unlabeled wood defect images (test set) in dataset 2, and select labels greater than the prediction threshold as pseudo labels.
[0083] (11) Fine-tune the data with wood defect labels (training set) and the data without wood defect labels (test set) in dataset 2 into network model model1, train network model model2, and select the best network model best mode through the validation set.
[0084] (12) The best network model best mode in step (11) is deployed locally, and the model is deployed in the carrier board of the Jetson series. A single thin wooden board is photographed by a conveyor belt device, and reasoning is performed through the model in the carrier board to obtain the type and number of surface defects of the wood and upload them to the back-end service. The reasoning result is analyzed to classify it as a defective product or a qualified product.
[0085] (13) The selected best network model, best mode, is deployed as a web model through Flask, a Python WEB framework.
[0086] The embodiments described above are merely descriptions of preferred implementation modes of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should all fall within the protection scope determined by the claims of the present invention.
Claims
1. A wood surface defect detection method based on an improved YOLOv5l network, characterized in that: The method comprises the following steps: S1. Obtain a public wood defect dataset as dataset 1, and process the images and labels in dataset 1; S2. Use the improved YOLOv5l network model to pre-train the dataset 1. First, uniformly scale the images in the dataset 1 and send them to the improved YOLOv5l network model. The YOLOv5l network model first selects a suitable anchor frame according to the size of the wood defect image using the adaptive anchor frame method, and extracts features through the Backbone layer to extract the feature map of the wood defect image. Then, the Neck layer mixes and combines the image features of the upper feature map. Finally, the output layer predicts the image features, and uses the NMS method to screen multiple prediction frames. During the screening process, the NWD calculation method is used to generate bounding boxes and prediction categories to obtain the trained network model model1. The connection layer a of the FPN structure in the improved YOLOv5l network model consists of three branches, namely, a 1×1 convolutional layer branch and two 3×3 convolutional layer branches with hole rates ar=1 and 2 respectively; The NWD calculation method is: Where C is a constant related to the data set, Among them, cxa, cya, wa, ha represent the location information of the prediction box A, cxb, cyb, wb, hb represent the location information of the prediction box B, ‖·‖ F is the Frobenius norm, N a represents the Gaussian distribution model of the prediction box A, N b Represents the Gaussian distribution model of the prediction box B, NWD(N a ,N b ) represents the similarity measure between prediction box A and prediction box B; S3, collecting real-life wood data as data set 2, using a sliding window method, randomly selecting a number of images from data set 1 processed by step S1 for cropping, cropping defective parts in the images separately, storing the cropped defective parts in data set 2, and expanding data set 2; S4, dividing the data set 2 into a training set, a validation set and a test set, wherein the defects in the wood images have been marked in the training set and the validation set, and the images have wood defect labels, and the defects in the wood images have not been marked in the test set, and the images do not have wood defect labels, and the trained network model model1 is used to predict the test set, and the wood images with defects in the test set are marked with labels, and the labels greater than the set prediction threshold are used as pseudo labels; S5, after integrating the training set and the test set in the data set 2, input them into the network model model1 to train the network model model1, obtain the trained network model model2, and select the best network model best mode from the network models model1 and model2 through the validation set; S6. Locally deploy the network model best mode, collect thin wood board images in real time and input them into the network model best mode. The network model best mode outputs the category and quantity of wood surface defects.
2. A wood surface defect detection method based on an improved YOLOv51 network according to claim 1, characterized in that: The adaptive anchor frame method specifically comprises the following steps: First, manually calculate the initial value of the anchor box, count the aspect ratios of all label boxes in dataset one, obtain the maximum aspect ratio of the target, recalculate the anchor box and replace the default anchor box with the new anchor box data; then, check the annotation information in dataset one, and calculate the best recall rate of the annotation information of this dataset for the default anchor box; finally, judge the best recall rate. If the best recall rate is greater than or equal to 0.85, there is no need to update the anchor box; if the best recall rate is less than 0.85, it is necessary to recalculate the anchor box that conforms to this dataset.
Citation Information
Patent Citations
Wood knot defect detection method based on improved YOLOv3 algorithm
CN110310259A
Method for identifying concrete cracks based on yolov3 deep learning model
AU2020101011A4
Remote sensing image target detection method fusing semantic segmentation
CN110633661A