CN114359235A - Wood surface defect detection method based on improved YOLOv5l network - Google Patents

Wood surface defect detection method based on improved YOLOv5l network Download PDF

Info

Publication number
CN114359235A
CN114359235A CN202210015819.XA CN202210015819A CN114359235A CN 114359235 A CN114359235 A CN 114359235A CN 202210015819 A CN202210015819 A CN 202210015819A CN 114359235 A CN114359235 A CN 114359235A
Authority
CN
China
Prior art keywords
wood
data set
network
yolov5l
defect
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202210015819.XA
Other languages
Chinese (zh)
Inventor
程大全
程广河
郝凤琦
孙瑞瑞
王星星
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Qilu University of Technology
Shandong Computer Science Center National Super Computing Center in Jinan
Original Assignee
Shandong Computer Science Center National Super Computing Center in Jinan
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shandong Computer Science Center National Super Computing Center in Jinan filed Critical Shandong Computer Science Center National Super Computing Center in Jinan
Priority to CN202210015819.XA priority Critical patent/CN114359235A/en
Publication of CN114359235A publication Critical patent/CN114359235A/en
Pending legal-status Critical Current

Links

Images

Abstract

The invention relates to a wood surface defect detection method based on an improved YOLOv5l network, which comprises the following steps: the public wood defect data set is obtained as data set one. An improved YOLOv5l network model is constructed, and a pair of improved YOLOv5l network models is trained by using a data set to obtain a trained network model 1. And collecting live-action wood data as a second data set, wherein the second data set is divided into a training set, a verification set and a test set. And (4) predicting the test set by using a model1, labeling the wood images with defects in the test set, and taking the labels larger than a set prediction threshold value as pseudo labels. And training the model1 after the training set and the test set in the data set II are trimmed to obtain a model2, and selecting the optimal network model from the model1 and the model2 by adopting the verification set. And detecting the surface defects of the wood by using the optimal network model. The method can detect the surface defects of various types of wood, and effectively improves the identification accuracy and efficiency.

Description

Wood surface defect detection method based on improved YOLOv5l network
Technical Field
The invention relates to the technical field of wood surface defect detection, in particular to a wood surface defect detection method based on an improved YOLOv5l network.
Background
The plywood is one of the most common and widely applied artificial boards. The three-ply board is formed by sticking and pressing different thin wood boards, so that a large amount of wood can be saved. Today, the use of plywood is a very good way of saving energy when forest resources are increasingly scarce, but during the production process, the surface of a single thin wood board has the defects of cracks, wormholes, dead knots, slipknots and the like, and the wood defects can be classified into 10 types according to the national standard. Figure 2 shows several common wood defects. These wood materials with defects are not conducive to the next step of production and can affect the progress of the veneer production. The way to detect such defects in the production line is mostly a manual way of detection as shown in fig. 1. Due to the factors of different manual detection standards, poor classification accuracy, low efficiency and the like, the wood quality judgment can be influenced, and the production speed of products cannot be guaranteed. And with the continuous rise of labor price, the production cost of manual detection can also be greatly increased.
Aiming at the problems, a method with high precision, low cost and strong stability is found to realize the detection and identification of the wood defects, and the method is a big problem to be solved in the wood production industry. In order to avoid the influence of subjective factors of workers, the machine vision and intelligent identification technology is adopted to replace artificial vision to detect the defects of the wood, so that the defects of the artificial detection can be effectively overcome, the labor cost is reduced, the utilization rate of the wood is greatly improved, and meanwhile, the economic benefit and the social value of enterprises are improved. The target detection algorithm in deep learning, which has been rapidly developed in recent years, can just solve this problem. However, because the wood surface defects have the conditions of various forms, various types, large defect scale change, multiple small targets and the like, the identification accuracy and efficiency of the existing detection algorithm are not ideal. For example, chinese patent CN 110310259 a discloses a knot defect detection method and related device based on an improved YOLOv3 algorithm, but the types of the knot defects on the surface of the wood strip are single, and only there are two types of dead knots and loose knots, and there are many types of defects in actual demand.
Disclosure of Invention
The invention aims to provide a wood defect detection method based on an improved YOLOv5l network, which can detect surface defects of various types of wood, effectively improve the identification accuracy and identification efficiency, reduce the detection delay, perform local deployment and cloud service deployment on a model, perform incremental learning on the wood defects, deal with defect diversity and meet the actual industrial requirements.
In order to achieve the purpose, the invention adopts the following technical scheme:
a wood surface defect detection method based on an improved YOLOv5l network comprises the following steps:
and S1, acquiring the public wood defect data set as a first data set, and processing the image and the label in the first data set.
S2, pre-training a data set I by using an improved YOLOv5l network model, uniformly scaling images in the data set I and sending the images into the improved YOLOv5l network model, selecting a proper anchor frame by using a self-adaptive anchor frame method according to the size of a wood defect image by using the YOLOv5l network model, extracting features through a Backbone layer, extracting a feature diagram of the wood defect image, mixing and combining the image features of an upper layer by using a Neck layer, predicting the image features through an output layer, screening a plurality of prediction frames by using an NMS (network management system) mode, and generating a boundary frame and a prediction category by using an NWD (non-uniform distribution) calculation method in the screening process to obtain a trained network model 1.
S3, collecting live-action wood data as a second data set, randomly selecting a plurality of images from the first data set processed in the step S1 in a sliding window mode for cutting, cutting defect parts in the images separately, storing the cut defect parts into the second data set, and expanding the second data set.
And S4, dividing the data set II into a training set, a verification set and a test set, wherein the training set and the verification set mark the defects in the wood image, the image has a wood defect label, the test set does not mark the defects in the wood image, the image does not have the wood defect label, predicting the test set by adopting a trained network model1, marking the wood image with the defects in the test set with a label, and taking the label larger than a set prediction threshold value as a pseudo label.
And S5, integrating the training set and the test set in the data set II, inputting the integrated training set and the test set into a network model1 to train the network model1 to obtain a trained network model2, and selecting the best network model best from the network model1 and the model2 through a verification set.
S6, locally deploying the network model best mode, collecting images of the thin wood boards in real time, inputting the images into the network model best mode, and outputting the types and the number of the wood surface defects by the network model best mode.
Further, the connection layer a of the FPN structure in the improved yollov 5l network model is composed of 3 branches, each of which is a 1 × 1 convolutional layer branch and 2 3 × 3 convolutional layer branches with void rates ar ═ 1 and 2.
Further, the adaptive anchor frame method specifically comprises the following steps:
firstly, manually calculating an initial value of an anchor frame, counting the width-to-height ratio of all label frames of a data set I to obtain the maximum width-to-height ratio of a target, recalculating the anchor frame and replacing the default anchor frame with the obtained new anchor frame data; then, checking the marking information in the data set I, and calculating the optimal recall rate of the marking information of the data set for the default anchor frame, wherein when the optimal recall rate is greater than or equal to 0.85, the anchor frame does not need to be updated; if the optimal recall is less than 0.85, then the anchor boxes that fit this data set need to be recalculated.
Further, the NWD calculation method is:
Figure BDA0003460669640000031
where C is a constant associated with the data set,
Figure BDA0003460669640000032
wherein, cxa,cya,wa,haPosition information, cx, representing the prediction frame Ab,cyb,wb,hbPosition information representing the prediction frame B, | |)FIs the Frobenius norm, NaGaussian distribution model representing prediction Box A, NbGaussian distribution model representing prediction Block B, NWD (N)a,Nb) Representing the similarity measure of prediction block a and prediction block B. And (3) screening the prediction boxes by using an NMS (network management system) mode, for example, predicting two prediction boxes for a certain defect target: and the prediction frame A and the prediction frame B adopt an NWD calculation method to calculate the similarity of the two prediction frames, and the similarity of the prediction frames is calculated by the position information of the frames.
Compared with the prior art, the invention has the advantages that:
(1) in the prior art, only dead knots, slip knots and defect-free samples exist in a detection defect data set of wood, and the defects are promoted to 9 types, namely dead knots, slip knots, resin, cracks, crack knots, decay, sound knots, color difference and wormholes. Aiming at the variety diversity of the wood defects, the invention adopts two data sets, extracts the defect characteristics of the first data set by using the idea of sliding windows and expands the second data set by using the defect characteristics, so that the data samples with sufficient quality can be obtained essentially, the model is finely adjusted by using a Pseudo-labeling (Pseudo-labeling) method, and the most excellent model is selected from the generated models. And the performance of the model obtained by final training has higher robustness.
(2) The model detection accuracy is not only related to the data set, but mainly to the detection network structure used. According to results shown by experiments on an MC COCO data set, the AP value of a YOLOv5l model in a test set is higher than that of YOLOv3 by 2.2, the speed of YOLOv5 is higher, and the size of the model is reduced by 16% compared with that of YOLOv3, so that the accuracy and the real-time performance of target detection are greatly improved by using the YOLOv5l model, and the method for identifying various wood defects can meet the requirements of industrial accuracy and real-time performance. The invention aims at the difficulty of small target detection of wood defects and adjusts on the basis of Yolov5 while the advantages of a network structure based on Yolov5s are achieved, an improved YOLOv5l network is realized, the possibility of extracting a wood defect characteristic diagram is greatly increased, and the precision and the speed of detecting various wood defects are improved. Specifically, the method modifies the Neck part in the YOLOv5l network structure, and further processes the top-level feature map of the FPN through hole convolution, so that the hole convolution can improve the perception field of view compared with the standard convolution, and since the scale of the defect in the 9 types of defect images is smaller than that of the decayed defect, the feature map of each type of defect can be improved through modifying the FPN layer. Has better effect on the phenomenon of inconsistent size of the wood defects.
(3) Because the phenomenon that the prediction frames overlap exists in the wood defect detection, the method mainly uses an IOU measurement mode as a mode for screening the final prediction frames by using a weighted NMS method in the original network framework, and the sensitivity of the method to the wood defects can enable the IOU values of a plurality of prediction frames to be lower than a set threshold (Nt), thereby leading to false positive prediction. The invention modifies the IOU measurement mode of the weighted NMS to be an NWD measurement mode, and aims at the CIoU loss function which is also based on the IOU measurement and is very sensitive to the small target position deviation of wood defects, the loss function of the bbox is modified to be an NWD loss function.
(4) Aiming at the characteristics of more wood defects and different sizes of the defects, the manual anchor frame calculation is carried out before the pre-training, the original initial value of the anchor frame in the original frame is replaced, and after the k-means + + algorithm calculation, the obtained candidate frame number and size are more time, and more accurate than before the improvement.
(5) Aiming at the problem that the accuracy of an initial model is reduced in the detection process due to the fact that samples are diverse in the wood defect detection process, the cloud service is used for storing image data and realizing model optimization and incremental learning.
Drawings
FIG. 1 is a schematic illustration of a manually sorted thin wooden board;
FIG. 2 is a schematic view of a wood surface defect, wherein the wood defect in FIG. 2a is a color difference, the wood defect in FIG. 2b is a slip knot, and the wood defect in FIG. 2c is a dead knot;
FIG. 3 is a process flow diagram of the improved YOLOv5l network model;
FIG. 4 is a block diagram of the PFN and PAN in the improved YOLOv5l network model;
FIG. 5 is a schematic diagram of the hole convolution of the connection layer in the FPN structure in the improved YOLOv5l network model;
FIG. 6 is an architecture diagram of the improved YOLOv5l network model;
FIG. 7 is a flow chart of a method for detecting surface defects of wood in accordance with the present invention;
FIG. 8 is a schematic structural diagram of a device for detecting surface defects of wood in accordance with the present invention.
Wherein:
1. the system comprises a thin wood board, 2, an industrial camera, 3, a light source, 4, a conveyor belt, 5, a controller, 6, a carrier plate, 7 and a cloud service end.
Detailed Description
The invention is further described below with reference to the accompanying drawings:
the surface defects of the veneer lumber were detected using the detecting apparatus shown in fig. 8. As shown in fig. 8, the inspection apparatus includes a conveyor belt 4 for conveying the wood, an industrial camera 2 disposed above the conveyor belt 4 for capturing an image of the wood, a pair of light sources 3 located at both sides of the industrial camera 2, a controller 5 for controlling the industrial camera, the conveyor belt, and a carrier board, and a cloud server 7. In the implementation, the lenses of the industrial cameras Basler Ace2 and Basler Lens are used for acquisition, and the light source is used for ensuring the definition of the acquired image. The industrial camera is used for collecting data of the defects of the veneer boards. The PC side utilizes Pycharm software to perform a model pre-training stage, the algorithm is based on a Pythroch frame, an initial learning rate is set to be 0.01, a cyclic learning rate is 0.2, a learning rate momentum is 0.937, an optimizer adopts SGD with momentum, training rounds are set for 300 times in total, a batch-size is 10, a PC side system is Ubuntu, a docker mirror image service is adopted, and an Inga GTX2080 Super display card is utilized to perform an accelerated training process. And performing web deployment on the trained model through a flash frame, and performing deployment of a Jeston carrier plate in local equipment.
As shown in fig. 7, the method for detecting surface defects of wood based on the improved YOLOv5l network comprises the following steps: electrifying the detection device, placing the wood board on a conveyor belt, conveying the wood board to the lower part of an industrial camera by the conveyor belt, acquiring an image of the wood board by the industrial camera, and transmitting the acquired image to be detected to a PC (personal computer) end; the image to be detected is input into an improved YOLOv5l network after being preprocessed, the image to be detected is processed by using the processing method shown in FIG. 3, an optimal network model is obtained, and then the defect type and the position information of the image to be detected are obtained by using the optimal network model. And classifying the optimal network model into a defective product or a qualified product according to the inference result of the optimal network model, uploading the inference result to cloud service background data, and displaying a front-end page.
As shown in fig. 3, a processing flow chart of the improved YOLOv5l network model specifically includes the following steps:
(1) and acquiring a public wood defect data set as a first data set, processing images and labels in the first data set, and converting into a txt format.
The disclosed wood defect data set is the prior art, wherein the labeled information of the data set has a format error, and the invention corrects the error information and cleans the data. Converting the format of the labeling information to be suitable for a YOLOv5l network model, and preprocessing the picture, including operations of cutting, segmenting and the like on the black edge of the original picture; the purpose of doing so is to be able to provide more accurate data for following model training, can improve model training speed and precision.
(2) And (4) independently cutting the random defect image in the data set I by using a sliding window method, and classifying the random defect image into the data set II.
The data set in the present invention is divided into two parts, one of which is a data set one based on public wood defect data, which contains over 20000 marked wood surface defects, covering the 9 most common wood defects. The second data set is from data collected from a real-time scene, and the second data set is manually labeled. The invention adopts a deep learning mode, firstly, a pair of network models is pre-trained by using a data set, and optimization is returned according to a training result. Then, the data set two is used for dividing the data set into 7: 2: 1 ratio training, validation and testing. The main processing flow is as follows:
and predicting a batch of unmarked images (test set) in the data set II, and selecting the label larger than the prediction threshold value as a pseudo label. The pseudo labels can reduce the workload of manual labeling on the second data set, and can also continue to train the model1 in such a way, so that the accuracy of the model is improved. The network model1 after training is completed continues to be integrated by the pseudo label data (data for marking the test set) and the training set in the data set two, the model1 continues to be trained by the integrated data, and the model2 is obtained after training is completed.
Through model training verification, the total loss is calculated as the weighted sum of the losses with the label and the losses without the label, and the calculation formula is as follows:
Loss=Labeled Loss+alpha*Unlabeled Loss
wherein, a Labeled Loss value is called "lost" 1, which means a classification Loss, a localization Loss and a confidence Loss.
alpha is a coefficient of the total loss of a pseudo tag as a function of time t (epochs) and is given by the formula:
Figure BDA0003460669640000071
wherein alpha isf=3,T1=100,T2=600。
The Unlabeled Loss value is "Loss 1" ("Loss without label") ", which is a classification 'Loss + localization' Loss + confidence 'Loss'.
Selecting the optimal network model through a verification set divided from the data set II, wherein the specific selection steps are as follows: the method comprises the steps of obtaining a network model1 through pre-training of a data set I, and determining model hyper-parameters in the model1 by using a verification set divided in a data set II, wherein the determination mode is that a Loss function is calculated, the Loss function formula is a class 1 which is classification Loss + localization Loss + confidence Loss, and the meaning is classification Loss + localization Loss + confidence Loss. Similarly, the loss function of the network model2 is computed using the validation set of data set two, and is computed as follows: loss2 ═ Labeled Loss + alpha ═ Unlabeled Loss. The optimal Best model is selected by comparing Loss1 with Loss 2. And finally, selecting an optimal model through the loss value. The determination of the prediction threshold may be made by clustering on the validation set and selecting the appropriate threshold by fine tuning.
The invention adopts the idea of sliding the window to cut partial image data in the public wood defect data set I and reserve the defective picture. These defect images are combined with dataset two for the next training. And enhancing the defect types in the first data set in a non-uniform distribution manner by using a conventional data enhancement mode (random vertical/horizontal folding and color space enhancement). And finally, adopting Mosaic data enhancement, and splicing the 4 pictures with 640 x 640 pixels in size in a random scaling, cutting and arranging mode.
(3) Data set one was pre-trained using the modified YOLOv5l network architecture, scaling the image to 640 x 640 pixel size, and selecting the appropriate anchor box scheme by the adaptive anchor box method.
As shown in fig. 4-6, 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 is finally changed into a 304 × 304 × 32 feature map by adopting slicing and convolution operations, and the Focus is accelerated in order to compress the network layer. The CSP structure solves the problem of repeated gradient information of network optimization in other large convolutional neural network frameworks (Backbones), and integrates the change of the gradient into a characteristic diagram from beginning to end, so that the parameter quantity and the FLOPS value of a model are reduced. Adopt in the middle of the tack structure is FPN + PAN structure, this kind of structure can carry out the multiscale to the characteristic and fuse, the FPN structure is through carrying out the upsampling from the top down for bottom characteristic map contains stronger wood defect's strong semantic information, the PAN structure is from the bottom up downsampled, make the top layer characteristic contain strong wood defect's positional information, two characteristics fuse at last, make not unidimensional characteristic map all contain strong wood defect's semantic information and strong wood defect's characteristic information, the accurate prediction to not unidimensional wood defect picture has been guaranteed.
The improved YOLOv5l network provided by the invention improves the FPN structure, the top-level feature map c3 is further processed by hole convolution to generate p3, and then the p3 and c2 are subjected to feature fusion. The top connection layer a of the FPN structure is composed of 3 branches, one 1 × 1 convolutional layer branch, and 2 3 × 3 convolutional layer branches with respective void rates ar ═ 1 and 2. The 3 x 3 cavity convolution layer with ar being 2 can obtain more global context feature details, and the reasoning capability is enhanced. And finally, after the characteristic graph is spliced, performing characteristic information fusion by adopting a convolution layer of 1 multiplied by 1. The improvement of the method adopts different ars, can improve the adaptability of the model to targets with different scales, and has better effect on the phenomenon of inconsistent sizes of defects on the surface of the wood.
Manually calculating an initial value of an anchor frame in the process before pre-training, counting the width-to-height ratio of all label frames of a data set, recalculating the anchor frame by obtaining the maximum width-to-height ratio of a target as 5:1, and replacing 10 groups of new anchor frame data with default anchor frames. Before training, the marking information in the data set is checked, the optimal recall rate of the marking information of the data set for the default anchor frame is calculated, and when the optimal recall rate is greater than or equal to 0.85, the anchor frame does not need to be updated; if the optimal recall is less than 0.85, then the anchor boxes that fit this data set need to be recalculated. Setting the bpr parameter (namely the basis for recalculating the anchor frame) to 0.85, calculating the anchor frame for multiple times, and selecting a proper anchor frame scheme from results obtained by manual calculation and a kmean clustering method.
The image is scaled during training, and a common way is to scale the original image to a standard size uniformly, and then send the image to a detection network, i.e. an improved YOLOv5l network, and use the YOLOv5l network to adaptively add the least black edges to the image. The calculation steps are as follows:
the first step is as follows: and calculating a scaling ratio, calculating scaling coefficients for the length and the width of the picture respectively, and selecting a smaller scaling coefficient.
The second step is that: the original picture length and width are multiplied by a smaller scaling factor.
The third step: and subtracting the smaller one from the larger one of the calculated length and width to obtain the height which needs to be filled originally, and obtaining the numerical values which need to be filled at the two ends of the height of the picture by using a remainder taking mode.
(4) Through the image adaptation, the image in the data set one is adapted to the standard size and then sent to the detection network.
(5) And the wood defect image enters a detection network, and wood defect features are extracted through the Backbone to generate a feature map. And then, the feature maps of the upper layer are mixed and combined with the image features through the Neck layer.
(6) And predicting the image characteristics through the output layer to generate a boundary frame and a prediction category.
In the post-processing of wood defect detection, the NWD measurement method is adopted by the invention aiming at the screening of a plurality of target frames. The NMS is an integral part of the target detection for suppressing redundant prediction bounding boxes, where the IOU metric is applied, the IOU metric criteria formula is as follows:
Figure BDA0003460669640000091
NMS process flow, first, it sorts all prediction boxes according to score. The prediction box M with the highest score is selected and all other prediction boxes with significant overlap with M (using a predefined threshold Nt) are suppressed. This process is recursively applied to the remaining blocks. The formula is as follows:
Figure BDA0003460669640000101
however, the sensitivity of the IOU to small targets can cause the IOU values for many prediction boxes to be below Nt, resulting in false positive predictions. Therefore, the IOU metric in the NMS is changed into the NWD metric, and the metric can eliminate the frames with large similarity by calculating the similarity between the prediction frame A and the prediction frame B, and the formula is as follows:
Figure BDA0003460669640000102
where C is a constant associated with the data set.
Figure BDA0003460669640000103
Wherein cxa,cya,wa,haPosition information, cx, representing the prediction frame Ab,cyb,wb,hbPosition information representing the prediction frame B, | |)FIs the Frobenius norm. N is a radical ofaTo represent bGaussian distribution model of prediction box A, N represents Gaussian distribution of prediction box B Model (model),NWD(Na,Nb) Representing the similarity measure of prediction block a and prediction block B. And (3) screening the prediction boxes by using an NMS (network management system) mode, for example, predicting two prediction boxes for a certain defect target: and the prediction frame A and the prediction frame B adopt an NWD calculation method to calculate the similarity of the two prediction frames, and the similarity of the prediction frames is calculated by the position information of the frames.
The invention provides an improved Bounding box Loss function of an output end of a YOLOv5L network, which changes a CIoU _ Loss Loss function originally using an IOU measurement mode into NWD _ Loss (namely L)NWD) And as a loss function, firstly calculating the Gaussian distribution of the prediction frame P and the Gaussian distribution of the real frame G, and obtaining a similarity value through normalization operation after calculating the distance measurement between P and G. The calculation formula is as follows:
Figure BDA0003460669640000111
wherein N isPIs a Gaussian distribution model of the prediction frame P (prediction), NgIs a Gaussian distribution model of the real frame G (ground true), LNWDRepresenting the loss function of the Bounding box, NWD (N)p,Ng) Representing a similarity value of a prediction box to a real box. The parameters are updated through back propagation of the loss value, loss between the true value and the predicted value is reduced, and the result predicted by the obtained model is more accurate.
The NWD metrology overcomes the problems of scale and position sensitivity and the detection of small targets for such wood surface defects can improve the accuracy of NMS.
(7) Pt model file best generated (model1) is saved.
(8) And collecting the second live-action data set and manually marking the second live-action data set.
(9) Data set two was as follows 7: 2: the scale of 1 is divided into a training set, a validation set, and a test set.
(10) And (3) predicting a batch of unlabeled wood defect images (test set) in the second data set by using a trained network model1, and selecting labels larger than a prediction threshold value as pseudo labels.
(11) And (3) performing finetune on the data (training set) with the wood defect labels and the data (testing set) without the wood defect labels in the data set II to the network model1, training the network model2, and selecting the best network model best through the verification set.
(12) And (3) locally deploying the best network model best mode in the step (11), deploying the model in a Jetson series carrier plate, photographing the transmitted single thin wood plate by using a conveyor belt device, reasoning through the model in the carrier plate, obtaining the type and the quantity of the surface defects of the wood, uploading the type and the quantity of the surface defects of the wood to a back-end service, and reasoning to obtain a result and analyze whether the wood is classified into a defective product or a qualified product.
(13) And deploying the webpage model of the selected optimal network model best mode through a WEB framework flash of Python.
The above-mentioned embodiments are merely illustrative of the preferred embodiments of the present invention, and do not limit the scope of the present invention, and various modifications and improvements of the technical solution of the present invention by those skilled in the art should fall within the protection scope defined by the claims of the present invention without departing from the spirit of the present invention.

Claims (4)

1. A wood surface defect detection method based on an improved YOLOv5l network is characterized by comprising the following steps: the method comprises the following steps:
s1, acquiring a public wood defect data set as a first data set, and processing images and labels in the first data set;
s2, pre-training a data set I by using an improved YOLOv5l network model, uniformly scaling images in the data set I and sending the images into the improved YOLOv5l network model, selecting a proper anchor frame by using a self-adaptive anchor frame method according to the size of a wood defect image by using the YOLOv5l network model, extracting features through a backsbone layer, extracting a feature diagram of the wood defect image, mixing and combining the image features of an upper layer by using a Neck layer, predicting the image features through an output layer, screening a plurality of prediction frames by using an NMS (network management system) mode, and generating a boundary frame and a prediction category by using an NWD (non-uniform distribution) calculation method in the screening process to obtain a trained network model 1;
s3, collecting live-action wood data as a second data set, randomly selecting a plurality of images from the first data set processed in the step S1 in a sliding window mode for cutting, cutting defect parts in the images separately, storing the cut defect parts into the second data set, and expanding the second data set;
s4, dividing a data set II into a training set, a verification set and a test set, wherein the training set and the verification set mark the defects in the wood image, the image has a wood defect label, the test set does not mark the defects in the wood image, the image does not have the wood defect label, predicting the test set by adopting a trained network model1, marking the wood image with the defects in the test set with a label, and taking the label larger than a set prediction threshold value as a pseudo label;
s5, integrating the training set and the test set in the data set II, inputting the integrated training set and the test set into a network model1 to train a network model1 to obtain a trained network model2, and selecting an optimal network model best mode from the network model1 and the model2 through a verification set;
s6, locally deploying the network model best mode, collecting images of the thin wood boards in real time, inputting the images into the network model best mode, and outputting the types and the number of the wood surface defects by the network model best mode.
2. The method for detecting the surface defects of the wood based on the improved YOLOv5l network as claimed in claim 1, wherein: the connection layer a of the FPN structure in the improved yollov 5l network model is composed of 3 branches, each of which is a 1 × 1 convolutional layer branch and 2 3 × 3 convolutional layer branches with void rates ar ═ 1 and 2, respectively.
3. The method for detecting the surface defects of the wood based on the improved YOLOv5l network as claimed in claim 1, wherein: the self-adaptive anchor frame method specifically comprises the following steps:
firstly, manually calculating an initial value of an anchor frame, counting the width-to-height ratio of all label frames of a data set I to obtain the maximum width-to-height ratio of a target, recalculating the anchor frame and replacing the default anchor frame with the obtained new anchor frame data; then, checking the labeling information in the data set I, and calculating the optimal recall rate of the labeling information of the data set for the default anchor frame; finally, the optimal recall rate is judged, and if the optimal recall rate is greater than or equal to 0.85, the anchor frame does not need to be updated; if the optimal recall is less than 0.85, then the anchor boxes that fit the data set need to be recalculated.
4. The method for detecting the surface defects of the wood based on the improved YOLOv5l network as claimed in claim 1, wherein: the NWD calculation method comprises the following steps:
Figure FDA0003460669630000021
where C is a constant associated with the data set,
Figure FDA0003460669630000022
wherein, cxa,cya,wa,haPosition information, cx, representing the prediction frame Ab,cyb,wb,hbPosition information representing the prediction frame B, | |)FIs the Frobenius norm, NaGaussian distribution model representing prediction Box A, NbGaussian distribution model representing prediction Block B, NWD (N)a,Nb) Representing the similarity measure of prediction block a and prediction block B.
CN202210015819.XA 2022-01-07 2022-01-07 Wood surface defect detection method based on improved YOLOv5l network Pending CN114359235A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210015819.XA CN114359235A (en) 2022-01-07 2022-01-07 Wood surface defect detection method based on improved YOLOv5l network

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210015819.XA CN114359235A (en) 2022-01-07 2022-01-07 Wood surface defect detection method based on improved YOLOv5l network

Publications (1)

Publication Number Publication Date
CN114359235A true CN114359235A (en) 2022-04-15

Family

ID=81108054

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210015819.XA Pending CN114359235A (en) 2022-01-07 2022-01-07 Wood surface defect detection method based on improved YOLOv5l network

Country Status (1)

Country Link
CN (1) CN114359235A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115187982A (en) * 2022-07-12 2022-10-14 河北华清环境科技集团股份有限公司 Algae detection method and device and terminal equipment
CN116309375A (en) * 2023-02-23 2023-06-23 南京林业大学 Method for detecting double-sided defects of solid wood plate and determining intelligent processing coordinates
CN116935221A (en) * 2023-07-21 2023-10-24 山东省计算中心(国家超级计算济南中心) Plant protection unmanned aerial vehicle weed deep learning detection method based on Internet of things

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115187982A (en) * 2022-07-12 2022-10-14 河北华清环境科技集团股份有限公司 Algae detection method and device and terminal equipment
CN115187982B (en) * 2022-07-12 2023-05-23 河北华清环境科技集团股份有限公司 Algae detection method and device and terminal equipment
CN116309375A (en) * 2023-02-23 2023-06-23 南京林业大学 Method for detecting double-sided defects of solid wood plate and determining intelligent processing coordinates
CN116309375B (en) * 2023-02-23 2023-10-24 南京林业大学 Method for detecting double-sided defects of solid wood plate and determining intelligent processing coordinates
CN116935221A (en) * 2023-07-21 2023-10-24 山东省计算中心(国家超级计算济南中心) Plant protection unmanned aerial vehicle weed deep learning detection method based on Internet of things
CN116935221B (en) * 2023-07-21 2024-02-13 山东省计算中心(国家超级计算济南中心) Plant protection unmanned aerial vehicle weed deep learning detection method based on Internet of things

Similar Documents

Publication Publication Date Title
CN109829914B (en) Method and device for detecting product defects
CN106960195B (en) Crowd counting method and device based on deep learning
CN114359235A (en) Wood surface defect detection method based on improved YOLOv5l network
CN111161243A (en) Industrial product surface defect detection method based on sample enhancement
CN114663346A (en) Strip steel surface defect detection method based on improved YOLOv5 network
CN111767927A (en) Lightweight license plate recognition method and system based on full convolution network
US8094971B2 (en) Method and system for automatically determining the orientation of a digital image
CN116863274A (en) Semi-supervised learning-based steel plate surface defect detection method and system
CN110827312A (en) Learning method based on cooperative visual attention neural network
CN112634237A (en) Long bamboo strip surface defect detection method and system based on YOLOv3 improved network
CN113158969A (en) Apple appearance defect identification system and method
CN110728269B (en) High-speed rail contact net support pole number plate identification method based on C2 detection data
CN113393438A (en) Resin lens defect detection method based on convolutional neural network
CN109840905A (en) Power equipment rusty stain detection method and system
CN116703911A (en) LED lamp production quality detecting system
CN114066848A (en) FPCA appearance defect visual inspection system
CN116071315A (en) Product visual defect detection method and system based on machine vision
CN117392042A (en) Defect detection method, defect detection apparatus, and storage medium
CN113962929A (en) Photovoltaic cell assembly defect detection method and system and photovoltaic cell assembly production line
CN115830302B (en) Multi-scale feature extraction fusion power distribution network equipment positioning identification method
CN117152094A (en) Method, device and system for analyzing surface defects of steel plate based on computer vision
CN115908774A (en) Quality detection method and device of deformed material based on machine vision
CN116958035A (en) Product part defect detection method, device, medium and electronic equipment
CN113763384B (en) Defect detection method and defect detection device in industrial quality inspection
CN115908344A (en) Micro LED chip defect detection method based on MLCT-YOLO

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
TA01 Transfer of patent application right

Effective date of registration: 20230111

Address after: No.19, shoukexueyuan Road, East Jingshi Road, Jinan City, Shandong Province

Applicant after: SHANDONG COMPUTER SCIENCE CENTER(NATIONAL SUPERCOMPUTER CENTER IN JINAN)

Applicant after: Qilu University of Technology

Address before: No.19, shoukexueyuan Road, East Jingshi Road, Jinan City, Shandong Province

Applicant before: SHANDONG COMPUTER SCIENCE CENTER(NATIONAL SUPERCOMPUTER CENTER IN JINAN)

TA01 Transfer of patent application right