Wood board surface defect detection method and system and storage medium
By improving the backbone network of the YOLOv8 model to be the InceptionNext network, combining deep separable convolution and multi-scale feature extraction, the instability of the accuracy and environmental sensitivity of traditional wooden board surface defect detection is solved, and efficient and accurate wooden board surface defect detection is achieved, supporting intelligent manufacturing and automated quality control in the wood processing industry.
Patent Information
- Application Number
- CN202510381835.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-28
- Publication Date
- 2025-07-25
AI Technical Summary
Traditional wooden board surface defect detection technology relies on manual inspection, and the detection accuracy is unstable, it is difficult to adapt to the efficient needs of large-scale production, and is sensitive to environmental factors and difficult to deal with complex defects.
The backbone network of the improved YOLOv8 model is an InceptionNext network, combining depth separation convolution and multi-scale feature extraction, through image preprocessing and model optimization, a wood defect detection model is constructed and high-precision defect detection is performed.
It improves the accuracy and robustness of wood board surface defect detection, reduces manual inspection costs, adapts to complex production environments, and promotes intelligent manufacturing and automated quality control in the wood processing industry.
Smart Images

Figure CN120374516A_ABST
Abstract
Description
Technical Field
[0001] The present invention mainly relates to the technical field of image detection, and specifically relates to a method, system and storage medium for detecting defects on the surface of wooden boards. Background Art
[0002] Traditional techniques for detecting defects on the surface of wooden boards mainly rely on manual inspection and simple image processing techniques. Although manual inspection can judge whether there are defects on the surface of wooden boards through experience, due to the cumbersome detection process and high labor intensity, it is easy to miss and misjudge. In addition, manual inspection is limited by factors such as lighting and worker fatigue, the detection accuracy is unstable, and it is also difficult to meet the high-efficiency requirements of mass production. Traditional techniques for detecting defects on the surface of wooden boards are difficult to handle complex defects in images, especially those similar to the background color or texture, are sensitive to environmental factors such as lighting and surface materials, and are easily interfered, resulting in inaccurate detection results. Therefore, traditional techniques for detecting defects on the surface of wooden boards cannot meet the requirements of modern wood processing and production line automation in terms of accuracy and robustness. Summary of the Invention
[0003] The technical problem to be solved by the present invention is to provide a method, system and storage medium for detecting defects on the surface of wooden boards in view of the deficiencies of the prior art.
[0004] The technical solution of the present invention to solve the above technical problem is as follows:
[0005] A method for detecting defects on the surface of wooden boards includes the following steps:
[0006] Improve the backbone network of the YOLOv8 model to obtain an initial wood defect detection model. Among them, the improved InceptionNext network is used as the backbone network of the YOLOv8 model, and the improved InceptionNext network is obtained by connecting the original InceptionNext network with a fully connected module;
[0007] Collect images of the surface of the wooden board to obtain an initial image of the surface of the wooden board, and preprocess the initial image of the surface of the wooden board to obtain an image of the surface of the wooden board;
[0008] Train the initial wood defect detection model with the image of the surface of the wooden board to obtain a new wood defect detection model and a predicted defect result. Calculate the total loss through the total loss function, calculate the performance index according to the predicted defect result, and optimize the new wood defect detection model according to the total loss and the performance index to obtain an optimal wood defect detection model;
[0009] Detect the target image of the surface of the wooden board through the optimized wood defect detection model to obtain a target defect result.
[0010] Another technical solution for the present invention to solve the above technical problems is as follows:
[0011] A wooden board surface defect detection system, comprising:
[0012] A model construction unit, configured to improve the backbone network of the YOLOv8 model to obtain an initial wood defect detection model. Among them, the improved InceptionNext network is used as the backbone network of the YOLOv8 model, and the improved InceptionNext network is obtained by connecting the original InceptionNext network with a fully connected module;
[0013] An image processing unit, configured to collect an image of the wooden board surface to obtain an initial wooden board surface image, and preprocess the initial wooden board surface image to obtain a wooden board surface image;
[0014] A model optimization unit, configured to train the initial wood defect detection model through the wooden board surface image to obtain a new wood defect detection model and a predicted defect result, calculate a total loss through a total loss function, calculate a performance index according to the predicted defect result, and optimize the new wood defect detection model according to the total loss and the performance index to obtain an optimal wood defect detection model;
[0015] A model prediction unit, configured to detect a target wooden board surface image through the optimized wood defect detection model to obtain a target defect result.
[0016] Another technical solution for the present invention to solve the above technical problems is as follows:
[0017] A wooden board surface defect detection system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method for detecting defects on the surface of a wooden board as described above is implemented.
[0018] Another technical solution for the present invention to solve the above technical problems is as follows:
[0019] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for detecting defects on the surface of a wooden board as described above is implemented.
[0020] The beneficial effects of the present invention are as follows: By preprocessing the image to provide high-quality input for the wood defect detection model, and using the improved InceptionNext network to construct the wood defect detection model, it is possible to adopt depthwise separable convolution and multi-scale feature extraction during the image prediction process to improve the detection accuracy. This not only reduces the computational amount in the convolution operation but also retains more local feature information in the image. The model is optimized according to the total loss and performance metrics, thereby improving the prediction accuracy of the model. By optimizing the wood defect detection model to detect defects in the target image, while ensuring high-precision detection, it significantly reduces the cost and error of manual detection, has strong robustness and adaptability, can operate stably in a complex production environment, and promotes the wood processing industry to achieve intelligent manufacturing and automated quality control. Description of the Drawings
[0021] Figure 1 It is a flowchart of the wood board surface defect detection method provided by an embodiment of the present invention;
[0022] Figure 2 It is a flowchart of the image processing for wood board defect detection provided by an embodiment of the present invention;
[0023] Figure 3 It is a structural diagram of the improved InceptionNext network provided by an embodiment of the present invention;
[0024] Figure 4 It is a schematic diagram of the confusion matrix provided by an embodiment of the present invention;
[0025] Figure 5 It is a schematic diagram of the comparison of performance metrics of different models provided by an embodiment of the present invention;
[0026] Figure 6 It is a block diagram of the wood board surface defect detection system provided by an embodiment of the present invention. Detailed Embodiments
[0027] The principles and features of the present invention are described below with reference to the accompanying drawings. The examples given are only used to explain the present invention and are not intended to limit the scope of the present invention.
[0028] In the detection of wood board surface defects, the fields of computer vision, deep learning, and industrial automation detection are combined. The improved InceptionNext network is used for multi-scale feature extraction, which can effectively process defects of different sizes and types. Compared with the traditional CNN (Convolutional Neural Network), the InceptionNext network performs better in balancing computational efficiency and detection accuracy, and is especially suitable for real-time defect detection in large-scale industrial production. In particular, the defect detection technology applied to wood processing, quality control, and production line automation can maintain high detection accuracy and robustness under the complex textures, color differences, and lighting changes on the wood board surface.
[0029] The present invention further improves its application effect in wood board defect detection by optimizing the model structure and training method, provides a more efficient and accurate automated detection solution for the wood processing industry, can meet the needs of modern industrial production, and improve the automation level of the production line.
[0030] As Figure 1 and Figure 2 shown, a method for detecting wood board surface defects provided by an embodiment of the present invention includes the following steps:
[0031] Improve the backbone network of the YOLOv8 model to obtain an initial wood defect detection model. Among them, the improved InceptionNext network is used as the backbone network of the YOLOv8 model, and the improved InceptionNext network is obtained by connecting the original InceptionNext network with a fully connected module;
[0032] Collect images of the wood board surface to obtain an initial wood board surface image, and preprocess the initial wood board surface image to obtain a wood board surface image;
[0033] Train the initial wood defect detection model with the wood board surface image to obtain a new wood defect detection model and predicted defect results. Calculate the total loss through the total loss function for the predicted defect results, calculate performance indicators based on the predicted defect results, and optimize the new wood defect detection model according to the total loss and the performance indicators to obtain an optimal wood defect detection model;
[0034] Detect the target wood board surface image with the optimized wood defect detection model to obtain target defect results. Specifically, the target defect results are fed back to the operator or the automated control terminal in real time, intuitively showing the location and type of the wood board surface defects, assisting in decision-making and further processing. If the system detects serious defects, it can automatically alarm or perform subsequent repair operations.
[0035] It should be understood that the InceptionNext network is an improved version of the Inception network. Based on its original structure, it is further optimized by adding various convolution techniques to improve the efficiency and accuracy of feature extraction. The InceptionNext network optimizes the depth and width based on multiple convolutional kernels, and adopts techniques such as depthwise separable convolution and 1×1 convolutional layers, which greatly reduce the computational complexity and improve the computational efficiency of the network. This structural design enables the model to balance accuracy and speed when extracting the details of the wooden board surface, especially meeting the requirements of real-time performance in industrial environments. The improved InceptionNext network gradually extracts the low-level and high-level features of the wooden board surface image through multiple convolutional operations. Each convolutional layer extracts image features from different receptive fields, thereby ensuring that even tiny defects can be accurately identified. Using depthwise separable convolution allows the model to process complex images more efficiently, not only significantly improving the accuracy, but also reducing the number of parameters and computational time. After feature extraction, the features output by the network are subjected to defect detection and analysis to determine whether there are defects on the wooden board surface, determine the type of defects, output the types and position coordinates of the defects, display the detection results in real time, and feedback them to the operators or automated terminals to provide a basis for subsequent processing.
[0036] In the embodiments of the present invention, the improved InceptionNext network adopts depthwise separable convolution and multi-scale feature extraction to improve the detection accuracy, greatly reducing the computational complexity. Through the constructed wood defect detection model, it automatically extracts the subtle surface features from the wooden board image, avoiding the human errors and omissions in traditional manual detection methods, and can significantly improve the accuracy, stability and efficiency of the wooden board surface defect detection, enabling the model to have strong real-time performance on the basis of ensuring high precision. Therefore, when used in large-scale wood processing production lines, it can meet the requirements of rapid detection on industrial production lines, effectively reduce the cost and labor intensity of manual detection, reduce the risk of human operation errors, and provide technical support for the realization of automated production in the wood processing industry. It not only improves the quality and efficiency of wooden board defect detection, but also promotes the application and development of intelligent manufacturing in the wood processing industry.
[0037] Preferably, image acquisition is performed on the wooden board surface to obtain an initial wooden board surface image, including:
[0038] Use a high-precision camera to take pictures of the wooden board from multiple angles and perspectives to collect multiple wooden board surface images, ensuring that all areas of the wooden board surface are effectively collected for comprehensive defect detection.
[0039] In the embodiments of the present invention, by collecting the wood board surface images from multiple perspectives, the image data of the wood board surface is obtained in real time. A high-definition and high-resolution image acquisition device is used to ensure that the defect information on the wood board surface can be clearly captured, reducing the omission of some wood board textures or defects during acquisition due to shooting angle problems, and ensuring the comprehensiveness and quality of the data.
[0040] Preferably, as Figure 3 shown, the improved InceptionNext network is obtained by connecting the original InceptionNext network with a fully connected module, and includes:
[0041] Construct the original InceptionNext network, multiple fully connected layers FC and multiple activation function layers, connect the first fully connected layer FC, the first activation function layer ReLU, the second fully connected layer FC and the second activation function layer Sigmoid one by one to obtain a fully connected module, and connect the fully connected module to the output end of the original InceptionNext network to obtain the improved InceptionNext network.
[0042] The ReLU activation function is expressed as:
[0043] ReLU(x) = max(0, x),
[0044] When the input x is greater than 0, the output is x; when the input x is less than or equal to 0, the output is 0. When the input is positive, the gradient is always 1, which can alleviate the gradient disappearance problem and make the training in the deep network easier. The output of the function is centered around 0, which helps to maintain the consistency of the weight update direction during the training process, thereby improving the convergence speed.
[0045] The Sigmoid activation function is expressed as:
[0046]
[0047] The output range is (0, 1), mapping the input value to a value close to 0 or 1. The function is continuous and differentiable within the domain and is used for optimization by the gradient descent method.
[0048] It should be understood that the InceptionNext network includes a Split layer, multiple depthwise separable convolution layers DWConv, an Identity layer, a Concat layer, a Batch Normalization layer, and a multi-layer perceptron MLP connected in sequence; among them, the multiple depthwise separable convolution layers are distributed in parallel, including a 3×3 depthwise separable convolution layer DWConv, a 1×1 depthwise separable convolution layer DWConv, and an 11×1 depthwise separable convolution layer DWConv. Their input ends are all connected to the output end of the Split layer, and their output ends are all connected to the input end of the Concat layer.
[0049] Specifically, replace the multi-layer perceptron MLP in the InceptionNext network with multiple cascaded multi-layer perceptrons MLP to obtain a new InceptionNext network, and connect the fully connected module to the output end of the InceptionNext network to obtain an improved InceptionNext network.
[0050] In the embodiment of the present invention, using the improved InceptionNext network can reduce the computational amount during convolution operations of the model and retain more local feature information. The new InceptionNext network innovates in multi-scale convolution operations, uses small convolution kernels (such as a combination of 1×1, 3×3, and 11×1 convolution kernels) to extract features of different scales, uses depthwise separable convolution layers to improve the computational efficiency and detection accuracy of the model, and at the same time uses multi-level feature fusion to enhance the model's perception ability of defects. By using smaller convolution kernels and deeper network structures, the computational overhead is effectively reduced, and at the same time, the model's recognition ability for defects on the wooden board surface is enhanced. To avoid the common problems of gradient disappearance or explosion in deep networks, the model improves its expressive ability by increasing the number of convolution layers (i.e., cascading multiple multi-layer perceptrons MLP).
[0051] The backbone network of the YOLOv8 model is the CSPDarknet network, and its structure includes: a Focus module, a CSP module, an SPPF module, multiple convolution layers, an activation function layer, and a normalization layer; the Focus module is used to perform slicing operations on the input image to reduce the computational amount; the CSP module consists of multiple convolution layers and a CSP structure and is used to extract features; the SPPF module is a spatial pyramid pooling module and is used for multi-scale feature fusion; the convolution layers include a convolution layer with a 1×1 convolution kernel and a convolution layer with a 3×3 convolution kernel and are used for feature extraction and dimensionality reduction; the activation function layer is a LeakyReLU layer; the normalization layer is a Batch Normalization layer.
[0052] Preferably, the YOLOv8 model includes a backbone network Backbone, a neck network Neck, and a head network Head;
[0053] Replacing the backbone network of the YOLOv8 model with the improved InceptionNext network to obtain a wood defect detection model, which includes:
[0054] Connect the input and output of the improved InceptionNext network, and connect it with the input of the neck network Neck. Connect the output of the neck network Neck with the input of the head network Head to obtain a wood defect detection model.
[0055] Before inputting the wood board surface image into the backbone network, a shallow module is also constructed and sequentially connected with a basic convolutional layer Conv2D, an activation function layer ReLU, and a pooling layer MaxPooling. Connect the output end of the shallow module with the input end of the improved InceptionNext network. Feature extraction is performed on the wood board surface image through the shallow module to obtain a shallow feature map and input it into the backbone network (i.e., the improved InceptionNext network).
[0056] It should be understood that the backbone network is used to extract feature maps of multiple different scales from the input image, the neck network is used to fuse features of multiple different scales, and the head network is used to perform object detection and classification on the fused feature maps.
[0057] In the embodiment of the present invention, the input and output of the improved InceptionNext network are connected in a skip connection, and the input is directly connected to the output, which alleviates the gradient disappearance problem in the deep network and improves the training stability.
[0058] Preferably, the preprocessing of the initial wood board surface image to obtain a wood board surface image includes:
[0059] Perform denoising processing on the initial wood board surface image, adjust the brightness parameter of the denoised initial wood board surface image through an image enhancement algorithm, and modify the size of the adjusted initial wood board surface image according to the set size to obtain a wood board surface image.
[0060] Specifically, remove the noise in the image to ensure that the defect features are clearer; enhance the contrast of the image to make the surface defects easier to distinguish from the background; perform unified size adjustment on the input image to ensure the standardization process when the image is input into the neural network.
[0061] An image enhancement algorithm is used to locally adjust features such as the contrast and brightness of the image to enhance the details in the image. The calculation expression of the image enhancement algorithm is:
[0062]
[0063] Among them, μ is the mean of the image region, σ is the standard deviation of the image region, α and β are adjustable parameters for adjusting contrast and brightness, I(x, y) is the initial wood surface image, and I′(x, y) is the wood surface image.
[0064] It should be understood that algorithms such as mean filtering or Gaussian filtering are used to denoise the initial wood surface image. The image enhancement algorithm used can be the Adaptive Contrast Enhancement algorithm ACE, the Contrast Limited Adaptive Histogram Equalization algorithm CLAHE, or the Retinex image enhancement algorithm.
[0065] In the embodiment of the present invention, the collected image is subjected to illumination equalization processing to balance the brightness distribution in the image and prevent the influence of uneven illumination on the detection result. Adaptive enhancement is performed using an image enhancement algorithm. By locally adjusting features such as the contrast and sharpness of the image, the details of the wood surface in the image are enhanced, and the influence of ambient illumination changes is reduced, providing high-quality input for subsequent deep learning processing.
[0066] Preferably, the training of the initial wood defect detection model using the wood surface image includes:
[0067] The wood surface image is divided by the initial wood defect detection model according to the set number of channels to obtain a plurality of wood surface feature maps. The plurality of wood surface feature maps include a rectangular feature map, a horizontal feature map, a vertical feature map, and an identity feature map. Depth convolution operations are performed on the rectangular feature map according to the set rectangular convolution kernel to obtain a depth rectangular feature map, depth convolution operations are performed on the horizontal feature map according to the set horizontal convolution kernel to obtain a depth horizontal feature map, depth convolution operations are performed on the vertical feature map according to the set vertical convolution kernel to obtain a depth vertical feature map, an identity transformation is performed on the identity feature map to obtain a depth identity feature map, the depth rectangular feature map, the depth horizontal feature map, the depth vertical feature map, and the depth identity feature map are spliced to obtain a wood surface feature map, the wood surface image and the wood surface feature map are fused to obtain a wood defect feature map, and object detection is performed on the wood defect feature map to obtain a new wood defect detection model and predicted defect results (i.e., defect positions and defect types).
[0068] Specifically, the wood defect detection model is composed of an improved InceptionNext network, a neck network, and a head network;
[0069] The improved InceptionNext network extracts a plurality of feature maps of different scales from the wood surface image, including:
[0070] The input wooden board surface image is divided into 4 groups along the channel dimension by the Split layer, and the image segmentation calculation expression is:
[0071] X hw ,X w ,X h ,X id =Split(X)=X :,:g ,X :g:2g ,X :2g:3g ,X :3g: ,
[0072] Among them, X hw is the rectangular feature map, X w is the horizontal feature map, X h is the vertical feature map, X id is the identity feature map, Split(·) is the segmentation function, g is the number of channels of the convolutional branch, and the number of channels g of the convolutional branch is determined according to the set ratio r g and the initial number of channels C, g = r g C; X :,:g represents extracting the 0th to the (g - 1)th channels, X :g:2g represents extracting the gth to the (2g - 1)th channels, X :2g:3g represents extracting the (2g)th to the (3g - 1)th channels, X :3g: represents extracting the (3g)th to the last channel, that is, the input tensor X is sliced along the channel dimension (i.e., grouped convolution).
[0073] The segmented feature maps are input into different parallel branches, which are respectively:
[0074] Perform depth convolution operation on the rectangular feature map through the rectangular convolution kernel branch (i.e., 3×3 depthwise separable convolution layer DWConv) to obtain the depth rectangular feature map. The rectangular convolution kernel calculation expression is:
[0075]
[0076] Perform depth convolution operation on the horizontal feature map through the horizontal convolution kernel branch (i.e., 1×1 depthwise separable convolution layer DWConv) to obtain the depth horizontal feature map. The horizontal convolution kernel calculation expression is:
[0077]
[0078] Perform depth convolution operation on the vertical feature map through the vertical convolution kernel branch (i.e., 11×1 depthwise separable convolution layer DWConv) to obtain the depth vertical feature map. The vertical convolution kernel calculation expression is:
[0079]
[0080] The identity feature map is subjected to an identity transformation through the identity branch (i.e., the input identity feature map is directly output) to obtain a deep identity feature map (i.e., the identity feature map). The identity transformation expression is:
[0081] X′ id = X id ,
[0082] where X hw represents the rectangular feature map, X w represents the horizontal feature map, X h represents the vertical feature map, X id represents the identity feature map, X′ hw represents the deep rectangular feature map, X′ w represents the deep horizontal feature map, X′ h represents the deep vertical feature map, X′ id represents the deep identity feature map, represents depthwise separable convolution, g(·) represents applying depth convolution to the input feature map, g→g represents the mapping from g input channels to g output channels, k s represents the size of the small rectangular convolution kernel Kernel with a default setting of 3, k b represents the size of the large convolution kernel Kernel with a default setting of 11.
[0083] The outputs of each branch (i.e., the deep rectangular feature map, the deep horizontal feature map, the deep vertical feature map, and the deep identity feature map) are concatenated through the Concat layer to obtain the wood board surface feature map. The calculation expression for the concatenation process is:
[0084] X′ = Concat(X′ hw , X′ w , X′ h , X′ id ),
[0085] where X′ represents the wood board surface feature map, and Concat(·) represents the concatenation function.
[0086] The wood board surface image and the wood board surface feature map are fused through the neck network to obtain the wood board defect feature map. Target detection is performed on the wood board defect feature map through the head network to accurately identify different types of wood board surface defects. The defect area is located by annotating with a bounding box, and the severity level is output according to the characteristics of the defect for classification, obtaining a new wood defect detection model and the predicted defect results.
[0087] In the embodiments of the present invention, channel grouping operations are performed through group convolution. By dividing the input channels into multiple groups and performing convolution operations independently for each group, the number of parameters of the convolution kernel can be reduced, thereby improving the calculation efficiency. By improving the InceptionNext network to optimize the convolution layer structure and adopting technologies such as depthwise separable convolution and 1×1 convolution layers, the model can significantly improve the calculation efficiency while maintaining high accuracy, meeting the real-time detection requirements in large-scale industrial production. The defect types on the wooden board surface are identified through a classification algorithm, and it is judged whether there are defects on the wooden board surface according to the output results of the neural network (i.e., the neck network), and the defect types are accurately classified.
[0088] Preferably, training the initial wood defect detection model with the wooden board surface image further includes:
[0089] Adjusting the learning rate of each parameter of the initial wood defect detection model through the cosine annealing algorithm to obtain the optimal learning rate corresponding to each parameter;
[0090] Optimizing each parameter of the initial wood defect detection model according to the optimal learning rate corresponding to each parameter through the Adam optimization algorithm to obtain a new wood defect detection model and predicted defect results (i.e., defect positions and defect types).
[0091] Specifically, the learning rate is adjusted based on the cosine function and is used in the training of deep neural networks to help the learning rate gradually decrease during the training process. The calculation expression of the cosine annealing algorithm is:
[0092]
[0093] where η0 is the set initial learning rate, η min is the set minimum learning rate, T is the set total number of training steps, t is the current step, and η t is the optimal learning rate.
[0094] Through the Adam optimization algorithm that combines momentum and adaptive learning rate, the learning rate of each parameter is adjusted according to the first moment (i.e., the mean) and the second moment (i.e., the variance) of the model parameter gradient. Specifically:
[0095] Initialize the parameters of the model θ0, the learning rate η, the first moment estimate m0, and the second moment estimate v0, where m0 = 0 and v0 = 0;
[0096] In the t-th iterative training, obtain the model parameter gradient of the model during training
[0097] Update the first - order moment estimate to obtain a new first - order moment estimate \(m\). t The updated expression for the first - order moment estimate is as follows:
[0098]
[0099] Update the second - order moment estimate to obtain a new second - order moment estimate \(v\). t The updated expression for the second - order moment estimate is as follows:
[0100]
[0101] Calculate the bias correction of the first - order moment estimate The bias - correction expression is as follows:
[0102]
[0103] Calculate the bias correction of the second - order moment estimate The bias - correction expression is as follows:
[0104]
[0105] Update each parameter \(\theta\) of the model t to obtain a new parameter \(\theta\). t+1 The updated parameter expression is as follows:
[0106]
[0107] Where \(\beta_1\) and \(\beta_2\) are the decay factors of momentum and second - order moment respectively, which are set as constants to prevent division - by - zero errors.
[0108] It should be understood that the learning rate \(\eta\) is calculated for each training step \(t\) during the set training period \(T\). t Through the Adam optimization algorithm, according to the learning rate \(\eta\). t Adjust each parameter of the model, update the model parameters, so as to complete the training process of the model at each training step \(t\) during the training period \(T\).
[0109] In the embodiments of the present invention, combined with the optimization strategy of learning - rate scheduling, using the learning - rate scheduling and optimization algorithm, the method of adjusting the learning rate based on the cosine function, which is usually used in the training of deep neural networks, can help the learning rate gradually decrease during the training process; the optimization algorithm that combines momentum and adaptive learning rate adjusts the learning rate of each parameter according to the first - order moment (i.e., the mean of parameter gradients) and the second - order moment (i.e., the variance of parameter gradients) of the gradient, ensuring that the model can converge efficiently during the training process, improving the detection accuracy, and making the training process more stable and efficient.
[0110] Preferably, calculating the total loss by the total loss function for the predicted defect results includes:
[0111] Calculate the predicted bounding box of the pre-annotated ground truth bounding box and the predicted defect result through the bounding box regression loss function to obtain the bounding box regression loss;
[0112] Calculate the predicted class label of the pre-annotated ground truth class label and the predicted defect result through the classification loss function to obtain the classification loss;
[0113] Calculate the total loss by the total loss function for the bounding box regression loss and the classification loss.
[0114] Specifically, the bounding box regression loss uses the Smooth L1 loss function, and the expression of the Smooth L1 loss function is:
[0115]
[0116] where Smooth L1 is the bounding box regression loss, and x is the difference between the predicted bounding box b pred and the ground truth bounding box b gt , that is, the difference between the predicted bounding box coordinates and the ground truth bounding box coordinates. If |x| < 1, the squared loss is used; if |x| ≥ 1, the linear loss is used;
[0117] The classification loss uses the cross-entropy loss function, and the expression of the cross-entropy loss function is:
[0118]
[0119] where CE(p, y) is the classification loss, p i is the probability of the i-th predicted class label predicted by the model, y i is the ground truth class label, and C is the total number of classes;
[0120] Combine the bounding box regression and classification losses to obtain the total loss function, and the expression of the total loss function is:
[0121] Joint Loss = λ reg Smooth L1(b pred , b gt ) + λ cls ·CE(p, y),
[0122] where Joint Loss is the total loss, λ reg is the weight of the bounding box regression loss, λ cls is the weight of the classification loss, b pred is the predicted bounding box, and b gt is the ground truth bounding box.
[0123] It should be understood that a bounding box is usually represented by four coordinates, namely the x - coordinate and y - coordinate of the center point of the bounding box, as well as the width and height of the bounding box. The specific calculation formula for the bounding box regression loss is as follows:
[0124] Smooth L1(b pred ,b gt )=Smooth L1(x pred -x gt )+Smooth L1(y pred -y gt )+Smooth L1(w pred -w gt )+Smooth L1(h pred -h gt ),
[0125] wherein, Smooth L1(b pred ,b gt ) is the bounding box regression loss, x pred is the x - coordinate of the center point of the predicted bounding box, x gt is the x - coordinate of the center point of the ground - truth bounding box, y pred is the y - coordinate of the center point of the predicted bounding box, y gt is the y - coordinate of the center point of the ground - truth bounding box, w pred is the width of the predicted bounding box, w gt is the width of the ground - truth bounding box, h pred is the height of the predicted bounding box, h gt is the height of the ground - truth bounding box.
[0126] In the embodiments of the present invention, a combined loss function that combines bounding box regression and classification loss is constructed to further improve the localization accuracy and detection effect of the model.
[0127] Preferably, as Figure 4 shown, calculating the performance index according to the predicted defect result includes:[[]]
[0128] Constructing a confusion matrix according to the predicted defect result and the pre - annotated ground - truth defect result. The confusion matrix includes true positives, false positives, and false negatives. By using the precision expression to calculate the true positives and the false positives, the precision is obtained. By using the recall expression to calculate the true positives and the false negatives, the recall is obtained.
[0129] Specifically, the confusion matrix is a 2×2 matrix used to statistically analyze the relationship between the prediction results and the true labels in a classification task. In an object detection task, the confusion matrix includes four key metrics, namely:[[]]
[0130] True Positive (TP) is the number of targets correctly detected by the model, that is, the number of cases where the model predicts a positive class and the actual is also a positive class.
[0131] False Positive (FP) is the number of targets incorrectly detected by the model (false detection), that is, the number of cases where the model predicts a positive class and the actual is a negative class.
[0132] False Negative (FN) is the number of targets not detected by the model (missed detection), that is, the number of cases where the model predicts a negative class and the actual is a positive class.
[0133] True Negative (TN) is the number of targets not detected by the model (missed detection), that is, the number of cases where the model predicts a negative class and the actual is also a negative class. In object detection tasks, TN is usually not calculated because the background area is usually very large and unclear.
[0134] The precision expression for calculating Precision is:
[0135]
[0136] The recall expression for calculating Recall is:
[0137]
[0138] In the embodiments of the present invention, by calculating Precision and Recall, the performance of the classification model can be comprehensively evaluated. A high Precision means high reliability of the model's prediction of the positive class, and a high Recall means strong recognition ability of the model for positive class samples. Adjust the prediction threshold of the model according to requirements to achieve the best balance between Precision and Recall.
[0139] Preferably, as Figure 5 shown in (a)-(k) of , the comparison results of various performance indicators of the wood defect detection model of the present invention and the unimproved original YOLOv8 model during the training process, including evaluation indicators such as Precision, Recall, mean average precision mAP50, and mean average precision mAP50-95, all show a steadily increasing trend in the present invention, indicating that the model performance is continuously optimized during the training process. Table 1 is the performance index table of the training results of different models.
[0140] Table 1
[0141] Algorithm Precision Recall mAP50 mAP50-95 The present invention 0.890 0.810 0.83 0.47 YOLOv8 0.875 0.860 0.87 0.52
[0142] As can be seen from Table 1, compared with the YOLOv8 model, the wood defect detection model (i.e., the present invention) constructed based on the improved InceptionNext network is slightly inferior in recall rate, but has higher precision and is suitable for tasks requiring high precision and low false alarms. In the wood defect detection task, reducing false alarms is crucial. Therefore, the present invention is more suitable for such application scenarios.
[0143] As Figure 6 shown, a wood board surface defect detection system provided by an embodiment of the present invention includes:
[0144] A model construction unit for improving the backbone network of the YOLOv8 model to obtain an initial wood defect detection model. Among them, the improved InceptionNext network is used as the backbone network of the YOLOv8 model, and the improved InceptionNext network is obtained by connecting the original InceptionNext network with a fully connected module;
[0145] An image processing unit for collecting an image of the wood board surface to obtain an initial wood board surface image, and preprocessing the initial wood board surface image to obtain a wood board surface image;
[0146] A model optimization unit for training the initial wood defect detection model through the wood board surface image to obtain a new wood defect detection model and a predicted defect result, calculating a total loss through a total loss function, calculating a performance index according to the predicted defect result, and optimizing the new wood defect detection model according to the total loss and the performance index to obtain an optimal wood defect detection model;
[0147] A model prediction unit for detecting a target wood board surface image through the optimized wood defect detection model to obtain a target defect result.
[0148] A wood board surface defect detection system provided by an embodiment of the present invention includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the method for detecting wood board surface defects as described above is implemented.
[0149] A computer-readable storage medium provided by an embodiment of the present invention stores a computer program, and when the computer program is executed by a processor, the method for detecting wood board surface defects as described above is implemented.
[0150] For the above wood board surface defect detection system and storage medium, reference can be made to the implementation content and beneficial effects of the method for detecting wood board surface defects described in detail above, which will not be elaborated here.
[0151] It should be noted that, in this document, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the terms "comprising", "including" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or elements inherent to such process, method, article or device.
[0152] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems and units described above can refer to the corresponding processes in the foregoing method embodiments, and will not be described herein again.
[0153] In several embodiments provided in this application, it should be understood that the disclosed systems and methods can be implemented in other ways. For example, the system embodiments described above are merely illustrative. For example, the division of units is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed.
[0154] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they can be located in one place, or distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiments of the present invention.
[0155] The above are only the preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A method for detecting surface defects of wooden boards, characterized in that, The steps are as follows: Improve the backbone network of the YOLOv8 model to obtain an initial wood defect detection model. Among them, the improved InceptionNext network is used as the backbone network of the YOLOv8 model, and the improved InceptionNext network is obtained by connecting the original InceptionNext network with a fully connected module; Collect images of the wood board surface to obtain an initial wood board surface image, and preprocess the initial wood board surface image to obtain a wood board surface image; Train the initial wood defect detection model with the wood board surface image to obtain a new wood defect detection model and predicted defect results. Calculate the total loss through the total loss function for the predicted defect results, calculate performance indicators based on the predicted defect results, and optimize the new wood defect detection model according to the total loss and the performance indicators to obtain an optimal wood defect detection model; Detect the target wood board surface image with the optimized wood defect detection model to obtain target defect results.
2. The method for detecting surface defects of a wooden board according to claim 1, characterized in that, The improved InceptionNext network is obtained by connecting the original InceptionNext network with a fully connected module, including: Construct the original InceptionNext network, multiple fully connected layers and multiple activation function layers. Connect the first fully connected layer, the first activation function layer, the second fully connected layer and the second activation function layer one by one to obtain a fully connected module, and connect the fully connected module to the output end of the original InceptionNext network to obtain the improved InceptionNext network.
3. The method for detecting surface defects of a wooden board according to claim 1, wherein The preprocessing of the initial wood board surface image to obtain a wood board surface image includes: Denoise the initial wood board surface image, adjust the brightness parameter of the denoised initial wood board surface image through an image enhancement algorithm, and modify the size of the adjusted initial wood board surface image according to the set size to obtain a wood board surface image.
4. The method for detecting surface defects of a wooden board according to claim 1, wherein, The training of the initial wood defect detection model with the wood board surface image includes: The initial wood defect detection model divides the wood board surface image according to the set number of channels, obtaining multiple wood board surface feature maps. The multiple wood board surface feature maps include a rectangular feature map, a horizontal feature map, a vertical feature map, and an identity feature map. A depth convolution operation is performed on the rectangular feature map according to the set rectangular convolution kernel to obtain a depth rectangular feature map. A depth convolution operation is performed on the horizontal feature map according to the set horizontal convolution kernel to obtain a depth horizontal feature map. A depth convolution operation is performed on the vertical feature map according to the set vertical convolution kernel to obtain a depth vertical feature map. An identity transformation is performed on the identity feature map to obtain a depth identity feature map. The depth rectangular feature map, the depth horizontal feature map, the depth vertical feature map, and the depth identity feature map are concatenated to obtain a wood board surface feature map. The wood board surface image and the wood board surface feature map are fused to obtain a wood board defect feature map, and object detection is performed on the wood board defect feature map.
5. The method for detecting surface defects of a wooden board according to claim 1, characterized in that, The training of the initial wood defect detection model using the wood board surface image further includes: Adjusting the learning rates of the various parameters of the initial wood defect detection model through the cosine annealing algorithm to obtain the optimal learning rate corresponding to each parameter; Optimizing the various parameters of the initial wood defect detection model according to the optimal learning rate corresponding to each parameter through the Adam optimization algorithm.
6. The method for detecting surface defects of wooden boards according to claim 1, characterized in that, The calculation of the total loss by the total loss function for the predicted defect result includes: Calculating the bounding box regression loss by the bounding box regression loss function for the pre-annotated true bounding box and the predicted bounding box of the predicted defect result; Calculating the classification loss by the classification loss function for the pre-annotated true class label and the predicted class label of the predicted defect result; Calculating the total loss by the total loss function for the bounding box regression loss and the classification loss.
7. The method for detecting surface defects of wooden boards according to claim 1 or 6, characterized in that, The calculation of the performance metrics according to the predicted defect result includes: Constructing a confusion matrix according to the predicted defect result and the pre-annotated true defect result. The confusion matrix includes true positives, false positives, and false negatives. Calculating the precision by the precision expression for the true positives and the false positives, and calculating the recall by the recall expression for the true positives and the false negatives.
8. A wooden board surface defect detection system, characterized in that, Including: A model construction unit for improving the backbone network of the YOLOv8 model to obtain an initial wood defect detection model. Among them, the improved InceptionNext network is used as the backbone network of the YOLOv8 model, and the improved InceptionNext network is obtained by connecting the original InceptionNext network with a fully connected module; An image processing unit for collecting an image of the wood board surface to obtain an initial wood board surface image, and preprocessing the initial wood board surface image to obtain a wood board surface image; A model optimization unit, which is used to train the initial wood defect detection model through the wood board surface image to obtain a new wood defect detection model and a predicted defect result, calculate the total loss through a total loss function, calculate performance indicators according to the predicted defect result, and optimize the new wood defect detection model according to the total loss and the performance indicators to obtain an optimal wood defect detection model; A model prediction unit, which is used to detect the target wood board surface image through the optimized wood defect detection model to obtain a target defect result.
9. A wooden board surface defect detection system, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements a wood board surface defect detection method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements a wood board surface defect detection method according to any one of claims 1 to 7.
Citation Information
Cited By
Lightweight low-light image enhancement method and device
CN120807347A