Wood surface defect detection method based on improved YOLOv81, electronic equipment and storage medium

By improving the YOLOv8l model, FasterNet and enhanced weighted bidirectional feature pyramid network EFPN, combined with DRM module, the problem of insufficient detection speed and accuracy in wood surface defect detection is solved, and efficient and accurate defect detection is achieved.

CN119478523APending Publication Date: 2025-02-18QILU UNIVERSITY OF TECHNOLOGY (SHANDONG ACADEMY OF SCIENCES) +2

Patent Information

Application Number
CN202411592705.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-08
Publication Date
2025-02-18

AI Technical Summary

Technical Problem

In the prior art, wood surface defect detection relies on manual detection, resulting in unstable detection quality, inconsistent standards, and inefficient efficiency. Traditional deep learning models have shortcomings in feature extraction and multi-scale expression capabilities.

Method used

Using the improved YOLOv8l model, the enhanced weighted bidirectional feature pyramid network EFPN was designed by using FasterNet to improve Backbone, and the DRM module was introduced to enhance the multi-scale feature extraction capability.

Benefits of technology

It improves the efficiency and accuracy of wood surface defect detection, reduces the number of model parameters and calculations, enhances the ability to express multi-scale features, and solves the shortcomings of traditional models in terms of detection speed and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119478523A_ABST
    Figure CN119478523A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of wood defect detection, and particularly relates to a wood surface defect detection method based on improved YOLOv81, electronic equipment and a storage medium. The method comprises the following steps of: improving the Backbone of the traditional YOLOv81 by using Faster Net, and reducing the parameter quantity and the calculation quantity by using the design of partial convolution PConv in the Faster Net; an enhanced weighted bidirectional feature pyramid network EFPN is provided, information exchange between different feature layers is enhanced through an auxiliary branch, and an expansion re-parameter module DRM is designed to fully capture features on different scales. The improved YOLOv81 is more suitable for detecting the multi-scale defects on the surface of the wood, the detection precision is improved, the parameter quantity and the calculated quantity are smaller, and an efficient and accurate solution is provided for detecting the defects on the surface of the wood.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of wood defect detection, and more specifically, relates to a wood surface defect detection method based on improved YOLOv8l, an electronic device and a storage medium. Background Art

[0002] As an important natural resource, wood is widely used in industries such as construction, furniture, and papermaking. However, affected by natural and human factors, wood inevitably has various defects, which are the most important factors affecting the use value of wood, and also affect the quality, aesthetics, and practicality of wood products. At present, veneer and plywood production dominates the wood processing market in China, and is widely used in the coating and decorative surfaces of furniture, doors, or interior design elements. In the processing of plywood, it is necessary to reasonably select veneer, because the growth environment, storage and transportation after log peeling, and later wood processing will lead to many veneer surface defects, such as dead knots, live knots, cracks, bark, notches, and dry scars, which will destroy the consistency and integrity of the veneer, reduce the mechanical strength, and affect the use and service life of the board. Therefore, detecting defects on the veneer surface is a crucial step in the plywood processing process, which is very important for the sorting, composition, or subsequent repair of veneers.

[0003] So far, the detection of surface defects of veneer boards usually relies on manual inspection, which requires a large number of workers to work for a long time and at a high intensity, resulting in problems such as unstable inspection quality, inconsistent inspection standards, and poor inspection efficiency. Therefore, it is urgent to design an automated and intelligent solution to overcome the current problems.

[0004] In recent years, deep learning-based defect detection methods have been used due to their outstanding capabilities in feature extraction and image classification. These methods are usually implemented based on object detection algorithms in the field of computer vision. Some researchers have applied object detection algorithms to wood defect detection, and trained the models with a large amount of image data to enable them to accurately detect wood defects. Object detection algorithms can be divided into two-stage detection algorithms (such as R-CNN, Fast R-CNN, Faster R-CNN, etc.) and single-stage detection algorithms (such as YOLO series, SSD, DETR, etc.) according to the network structure. Two-stage detection algorithms usually have high computational costs and are difficult to meet the real-time requirements of industrial applications. In contrast, single-stage detection algorithms predict and classify objects in an end-to-end manner. They usually have faster inference speeds, but their accuracy is relatively low due to the absence of a region proposal subnetwork (RPN). However, in recent years, through continuous improvements, these algorithms have been able to achieve higher accuracy while maintaining faster inference speeds. YOLOv8 achieves faster detection speeds and higher accuracy with its anchor-free method and more advanced design. In YOLOv8, after the image is preprocessed, the features in the image are first extracted through Backbone, then fused in Neck, and finally passed to Head. The category and position of the target are obtained through a series of convolutional layers and classification and regression loss functions.

[0005] However, since wood surface defects vary significantly in object scale, size, and aspect ratio, the traditional Backbone, due to its deep network structure, tends to extract more redundant information when extracting defect features, which leads to large model parameters and calculations, slow detection speed, and inaccurate positioning of key information. In addition, the traditional Neck suffers from feature information loss and degradation during feature layer interaction, which weakens the model's ability to express multi-scale features. These factors limit the accuracy and efficiency of wood surface defect detection.

[0006] Chinese patent document CN117876663A discloses a wood defect detection method and system based on deep neural network, which includes the following steps: obtaining a wood defect data set, and dividing the defect data set into a training set, a validation set and a test set; constructing an initial defect detection model based on the YOLOv8 model, including: replacing the Conv module of the Neck network in the YOLO model with the RFCA module; and replacing the ReLU activation function in the RFCA attention mechanism with the SiLU activation function. A small target decoupling detection head is added to the head part to improve the detection ability of small targets. Secondly, the CIoU loss function is replaced by the Wise-IoU loss function. Finally, the idea of ​​transfer learning is introduced to construct an improved YOLOv8 model. The initial defect detection model is trained using the training set to obtain the final defect detection model; the validation set is input into the final defect detection model, and the detection results are output. Then the test set, local video and real-time collected images on the mobile terminal are input into the wood defect intelligent detection system, and the detection results are output.

[0007] In view of the above problems, the present invention proposes a wood surface defect detection method based on improved YOLOv8l. Summary of the invention

[0008] The present invention aims to overcome at least one defect of the above-mentioned prior art, and provides a wood surface defect detection method based on improved YOLOv8l, which provides an efficient and accurate solution for wood surface defect detection.

[0009] The detailed technical scheme of the present invention is as follows:

[0010] A wood surface defect detection method based on improved YOLOv8l, the method comprising:

[0011] S1, wood defect image collection, and then mark the defects in the dataset;

[0012] S2. Improve the YOLOv8 model to get the improved YOLOv8l model: First, use FasterNet to improve Backbone;

[0013] Then, an enhanced weighted bidirectional feature pyramid network EFPN is designed, the original Neck structure PANet in YOLOv8 is replaced by EFPN, and the DRM module is introduced into EFPN;

[0014] S3, based on the labeled data, the improved YOLOv8l model is imported to detect wood surface defects;

[0015] Preferably, according to the present invention, the use of FasterNet to improve Backbone refers to: using FasterNet to replace the original Backbone network CSPDarkNet53 in YOLOv8;

[0016] The overall architecture of FasterNet has four layers, each of which is preceded by an embedding layer or a merging layer for spatial downsampling and channel number expansion. Each layer contains a series of FasterNet basic blocks, namely FasterNet Block. Each FasterNet Block contains a partial convolution PConv layer followed by two point-by-point convolution Conv 1×1, and Shortcut is used to reuse input features.

[0017] The partial convolution PConv is the core content of FasterNet. The working principle of PConv is to apply conventional convolution Conv on part of the input channel while keeping the remaining channels unchanged. This method reduces the amount of calculation and memory access while maintaining the resolution of the feature map; the computational complexity of PConv is lower than that of conventional convolution, but higher than depth convolution / grouped convolution, which improves the computing performance while reducing computing resources. In addition, FasterNet further appends point-by-point convolution Conv1×1 to PConv, allowing feature information to flow through all channels.

[0018] Preferably, according to the present invention, the specific process of the enhanced weighted bidirectional feature pyramid network EFPN is as follows:

[0019] a) First, the feature layers C2, C3, C4, and C5 extracted by the backbone network are normalized into a unified channel through a 1×1 convolution operation. Since different feature layers have different resolutions, these feature layers are adjusted to the same size through upsampling or downsampling operations;

[0020] b) Use the bidirectional weighted feature pyramid network BiFPN to perform preliminary feature fusion to obtain feature layers C2′, C3′, C4′, and C5′;

[0021] c) Use ASFF operation to fuse the features of the two levels, and obtain the corresponding feature vector after fusion on layer l in the following way

[0022]

[0023] In formula (1), Represents the feature vector at position (i, j) of the feature map adjusted from feature layer n to feature layer l; and are the spatial weights from two different feature layers to feature layer l, which are adaptively learned by the network and satisfy the following constraints:

[0024]

[0025] In formula (3), and It is a hyperparameter that controls the softmax function;

[0026] d) Finally, the fused feature layer obtained after the ASFF operation is processed by the DRM module to obtain auxiliary branches, namely feature layers C2″, C3″, C4″ and C5″; each auxiliary branch is added to the corresponding feature layer in the bidirectional weighted feature pyramid network BiFPN after upsampling or downsampling operation, and then the feature map generated after the addition is processed by the DRM module to obtain the output {P2, P3, P4, P5} of EFPN, and the output is passed to the subsequent Head part; in EFPN, bilinear interpolation is used as the upsampling operation and 3×3 convolution with a step size of 2 is used as the downsampling operation.

[0027] Preferably, according to the present invention, the auxiliary branch adopts different fusion strategies for different feature layers, as follows:

[0028] In the top-down path of the preliminary feature fusion process of BiFPN, for the C2′ layer, the information loss of the C4 and C5 layers is more serious than that of the C3 layer, and an auxiliary branch C4″ is introduced to the C2′ layer to reduce the information loss: Since the semantic difference between the C5 layer and the C2′ layer is greater than the difference between the C4 layer and the C2′ layer, the C5 layer is first fused to the C4 layer through the ASFF operation instead of directly merging with the C2′ layer. This operation can reduce the information loss of the high layer while minimizing the semantic difference between different layers. Then, the DRM module is used to enhance the multi-scale feature extraction to obtain the auxiliary branch C4″; finally, the auxiliary branch C4″ is added to the feature layer C2′, and then the added feature layer is processed by the DRM module to obtain the feature layer P2;

[0029] Similarly, in the bottom-up path, for the C5′ layer, the information loss of the C2 and C3 layers is more serious than that of the C4 layer, and an auxiliary branch C3″ is introduced to the C5′ layer: first, the C2 layer is fused to the C3 layer through the ASFF operation, and then the multi-scale feature extraction is enhanced through the DRM module to obtain the auxiliary branch C3″. Finally, the auxiliary branch C3″ is added to the feature layer C5′, and then the added feature layer is processed by the DRM module to obtain the feature layer P5.

[0030] In the bottom-up path of the initial feature fusion process of BiFPN, for the C3′ layer, the information loss of the C5 layer is more serious than that of the C2 and C4 layers, and an auxiliary branch C5″ is introduced to the C3′ layer: first, the C4 layer is fused to the C5 layer through the ASFF operation to further reduce the semantic difference across layers; then the multi-scale feature extraction is enhanced through the DRM module to obtain the auxiliary branch C5″; finally, the auxiliary branch C5″ is added to the feature layer C3′, and then the added feature layer is processed by the DRM module to obtain the feature layer P3;

[0031] Similarly, in the top-down path, for the C4′ layer, the information loss of the C2 layer is more serious than that of the C3 and C5 layers, and an auxiliary branch C2″ is introduced to the C4′ layer: first, the C3 layer is fused to the C2 layer through the ASFF operation, and then the multi-scale feature extraction is enhanced through the DRM module to obtain the auxiliary branch C2″; finally, the auxiliary branch C2″ is added to the feature layer C4′, and then the added feature layer is processed by the DRM module to obtain the feature layer P4.

[0032] Preferably according to the present invention, the DRM module contains many dilated re-parameter blocks DRB, and the dilated re-parameter blocks DRB include a 9×9 convolution with a dilation rate of 1, two 5×5 convolutions with dilation rates of 1 and 2, and two 3×3 convolutions with dilation rates of 3 and 4, respectively. The outputs of these five convolutions are combined by summing after batch normalization BN. During training, the DRB module can extract multi-scale features more effectively, because the enhanced large-kernel convolution can capture a wider range of feature dependencies, and the dilated convolutions of multiple small kernels can more effectively extract more complex spatial patterns. During the reasoning process, through the structural re-parameterization technology, the batch normalization layer is merged into the convolution layer, and the dilated convolutions of multiple small kernels are integrated into the large-kernel convolution, converting the entire DRB block into a single non-dilated convolution, which is equivalent to eliminating the reasoning cost of the additional dilated convolution operation.

[0033] Preferably, according to the present invention, step S3 is specifically as follows: after the image is input into the model, the model first extracts features from the image through FasterNet to generate feature maps of different levels, and performs spatial pyramid pooling SPPF operation after FasterNet, and then fuses the feature maps of different levels through EFPN to integrate low-dimensional detail information and high-dimensional semantic information, enriching the multi-scale expression capability of the model; finally, at the Head layer, the input feature map is calculated through four different convolution groups, and the bounding box, category probability and confidence score are obtained.

[0034] In another aspect of the present invention, there is also provided an electronic device, comprising:

[0035] at least one processor; and

[0036] A memory storing instructions, which, when executed by the at least one processor, enable the at least one processor to execute the wood surface defect detection method based on the improved YOLOv8l as described above.

[0037] In another aspect of the present invention, a machine-readable storage medium is provided, which stores executable instructions, and when the instructions are executed, the machine executes the above-mentioned method for detecting wood surface defects based on improved YOLOv8l.

[0038] Compared with the prior art, the present invention has the following beneficial effects:

[0039] (1) The present invention proposes an efficient wood surface defect detection method based on improved YOLOv8l, uses FasterNet to improve the traditional YOLOv8l Backbone, and utilizes the design of partial convolution PConv in FasterNet to reduce the computational redundancy and memory access of irrelevant channels, thereby improving the calculation speed and extracting spatial features more efficiently.

[0040] (2) The present invention proposes an enhanced weighted bidirectional feature pyramid network (EFPN), which strengthens the information exchange between different feature layers through auxiliary branches, and designs a dilated heavy parameter module (DRM) to fully capture features at different scales to achieve a larger receptive field without increasing additional computational consumption.

[0041] (3) The present invention uses the target detection algorithm of computer vision to effectively improve the efficiency of wood surface defect detection, and reduces the problems of inconsistent detection standards, strong subjectivity, unstable accuracy, low detection efficiency, etc. caused by manual detection. The improved YOLOv8l model of the present invention significantly reduces the number of parameters and the amount of calculation, improves the detection accuracy, and solves the problems of the original YOLOv8l with large number of parameters, large amount of calculation, and weak multi-scale defect detection ability. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] Figure 1 This is the original YOLOv8 network structure diagram described in Example 1 of the present invention.

[0043] Figure 2 It is a comparison diagram between traditional convolution and partial convolution in Example 1 of the present invention.

[0044] Figure 3 This is a diagram of the FasterNet network structure in Example 1 of the present invention.

[0045] Figure 4 These are the surface defects of the seven types of wood in Example 1 of the present invention.

[0046] Figure 5 This is a structural diagram of EFPN in Example 1 of the present invention.

[0047] Figure 6 It is a structural diagram of C2f and DRM in Example 1 of the present invention.

[0048] Figure 7 This is a structural diagram of the expanded heavy parameter block DRB in Example 1 of the present invention.

[0049] Figure 8 This is the wood defect image acquisition system in Example 1 of the present invention.

[0050] Fig. 9 It is the wood defect image in Example 1 of the present invention.

[0051] Fig.10 This is a result diagram after data annotation in Example 1 of the present invention.

[0052] Fig.11 It is a structural diagram of the improved YOLOv8 model in Example 1 of the present invention.

[0053] Fig.12 This is a diagram of wood surface defect detection results in Example 1 of the present invention. DETAILED DESCRIPTION

[0054] The present disclosure is further described below in conjunction with the accompanying drawings and embodiments.

[0055] Embodiment 1,

[0056] This embodiment provides a wood surface defect detection method based on improved YOLOv8l, the method comprising the following steps:

[0057] S1, wood defect image collection, and then mark the defects in the dataset;

[0058] S2. Improve the YOLOv8 model to get the improved YOLOv8l model: First, use FasterNet to improve Backbone;

[0059] Then, an enhanced weighted bidirectional feature pyramid network EFPN is designed, the original Neck structure PANet in YOLOv8 is replaced by EFPN, and the DRM module is introduced into EFPN;

[0060] S3. Based on the labeled data, the improved YOLOv8l model is imported to detect wood surface defects.

[0061] The wood defect image acquisition refers to: acquiring wood defect images through an image acquisition system, the image acquisition system is as follows: Figure 8As shown, it includes: (1) global shutter industrial camera: ME2P-1230-23U3C-VF8, Daheng Image Co., Ltd., Beijing, China, the camera has 4096×3000 pixels and 23.5FPS; (2) surface light source: HFL700400-1H75-C24-T1, Shenzhen Jingqing Optoelectronics Co., Ltd., Guangdong, China, white light; (3) black box, used to block the light source; (4) industrial computer: IPC-510, Advantech Technology (China) Co., Ltd., Jiangsu, China; (5) conveyor belt, used to transport wood, the collected wood defect images are shown in Fig. 9 shown.

[0062] Data annotation refers to the use of Roboflow online annotation tools to annotate defects in the data set, including seven types of defects, namely, dead knots, slip knots, bark, cracks, gaps, dry scars, and knife resistance. Fig.10 shown.

[0063] The improved YOLOv8 model to obtain an improved YOLOv8l model comprises the following steps:

[0064] 1. Improve Backbone

[0065] YOLOv8 is the eighth version of the YOLO series. It is based on the previous versions of YOLO and introduces new features and improvements. Like previous YOLO versions, YOLOv8 consists of Backbone, Neck and Head, but YOLOv8 uses the C2f structure with richer gradient flow to replace the original C3 structure. In the Head part, the original coupling head is replaced with the current mainstream decoupling head structure, and Anchor-Based is also replaced with Anchor-Free. The specific network structure of YOLOv8 is as follows: Figure 1 As shown in the figure, the CBS module and C2f module in Backbone in YOLOv8 are mainly composed of a series of convolutional layers, which are responsible for processing the information extracted from the input image.

[0066] like Figure 2 As shown in (a)Conv in the figure, the traditional convolution operation extracts the features of the input data by sliding a convolution kernel on all channels of the feature map. This method is prone to extracting more redundant information when processing various types of defects on the wood surface, resulting in a large amount of calculation and insufficient accuracy in extracting key information.

[0067] To address the above issues, FasterNet was used to replace the original Backbone network CSPDarkNet53 in YOLOv8. FasterNet is a new neural network architecture that aims to improve computing speed without sacrificing accuracy, especially in visual tasks. The core of FasterNet is Partial Convolution, or PConv for short, which is a new type of convolution operation that extracts spatial features more efficiently by reducing redundant calculations and memory accesses. Figure 2 As shown in (b) PConv in Figure 1, the working principle of PConv is to apply conventional convolution Conv on part of the input channel while keeping the remaining channels unchanged. This method reduces the amount of calculation and memory access while maintaining the resolution of the feature map. The computational complexity FLOPs of PConv is lower than that of conventional convolution, but higher than that of depth convolution / grouped convolution, which improves the computing performance while reducing computing resources. In addition, FasterNet further appends point-by-point convolution Conv 1×1 to PConv, allowing feature information to flow through all channels. This ensures that the model fully and effectively utilizes information from all channels. Therefore, the present invention uses FasterNet to improve the Backbone in YOLOv8, which can not only effectively reduce the number of parameters and computation of the model, but also improve the feature extraction efficiency of the model.

[0068] Figure 3 The overall architecture of FasterNet used in the present invention is shown. It has four layers, each of which is preceded by an embedding layer or a merging layer for spatial downsampling and channel number expansion; the embedding layer is a regular 4×4 convolution with a stride of 4, and the merging layer is a regular 2×2 convolution with a stride of 2. Each layer contains a series of FasterNet basic blocks, namely FasterNet Block, each FasterNet Block contains a PConv layer followed by two Conv 1×1, and Shortcut is used to reuse input features.

[0069] 2. Improve Neck

[0070] The role of the Neck structure is to perform feature fusion. Its purpose is to align the feature map sizes of the feature maps extracted by the backbone network by upsampling or downsampling, and then fuse them to better utilize the feature information. Figure 1, the original Neck structure in YOLOv8 is PANet, which uses three feature maps C3, C4, and C5 extracted from Backbone. The feature map C5 close to the vertex usually contains richer semantic information, while the feature map C3 close to the bottom contains more detailed positioning information. The Neck structure completes the feature fusion operation through top-down and bottom-up paths, upsamples the deep feature maps through bilinear interpolation, and downsamples the shallow features through a 3×3 convolution with a step size of 2. However, in the top-down and top-down feature fusion process in the Neck structure, multiple fusion and up-and-down sampling operations lead to information loss and degradation in the feature maps, and because different feature maps have different levels of semantic information, the original Neck structure may reduce the fusion effect of the feature maps by simply and roughly adding and splicing the feature maps, which affects the multi-scale representation ability of the model. However, as Figure 4 As shown in the figure, wood surface defects have large scale variations, and the size and aspect ratio of defects are obviously different; the above-mentioned shortcomings of the original Neck structure in YOLOv8 will affect the detection accuracy of the model for multi-scale surface defects of wood. In order to solve the above problems, the present invention designs an enhanced weighted bidirectional feature pyramid network EFPN to replace PANet.

[0071] In addition, there are many small target defects in wood surface defects, such as dead knots, slipknots, and dry scars. In the original Neck structure of YOLOv8, only three high-dimensional feature maps C3, C4, and C5 are used, which are obtained by continuously downsampling the high-resolution input image by Backbone. As the network layer deepens, the resolution of the feature map gradually decreases, which may cause small targets to be unable to be accurately represented on the high-dimensional feature map. This is because the small targets themselves occupy fewer pixels in the high-resolution input image. After multiple downsamplings, these small targets may only occupy a few pixels on the high-dimensional feature map, or even completely lost, making detection difficult. In addition, although the high-dimensional feature map is rich in semantic information, it is insufficient in retaining spatial detail information. Small target detection needs to consider both the semantic features and fine spatial location information of the target. Due to the low resolution of the high-dimensional feature map, it may not provide enough spatial details to accurately locate small targets.

[0072] Considering the above problems, the present invention specially introduces the C2 feature layer when designing EFPN to obtain higher resolution and more detailed spatial detail information. The EFPN structure diagram proposed by the present invention is as follows: Figure 5As shown, the feature maps are represented as C2, C3, C4, and C5 respectively. Initially, these features are normalized to a uniform number of channels through a 1×1 convolution operation. Then, a bidirectional weighted feature pyramid network BiFPN is used for preliminary feature fusion. In addition, auxiliary branches Auxiliarybranches are designed to compensate for the information loss of the feature layer during the preliminary feature fusion process, improve the fusion effect of the feature map, enrich the detail information and semantic information of each layer of the feature map, and thus enhance the multi-scale feature representation capability of the model. In EFPN, the present invention uses bilinear interpolation as an upsampling operation and a 3×3 convolution with a step size of 2 as a downsampling operation.

[0073] like Figure 5 As shown, the auxiliary branch in the EFPN proposed in the present invention adopts different fusion strategies for different feature layers, as follows:

[0074] (1) Taking the C2′ layer as an example, in the initial feature fusion process of BiFPN, that is, the top-down path, see Figure 5 As shown in the thick red line in , the information loss of C4 and C5 layers is more serious than that of C3 layer, so an auxiliary branch C4″ is introduced to reduce the information loss. Since the semantic difference between C5 layer and C2′ layer is greater than that between C4 layer and C2′ layer, C5 layer is first fused with C4 layer through ASFF operation instead of directly fused with C2′ layer. This operation can reduce the information loss of high layer while minimizing the semantic difference between different layers. Then, the DRM module is applied to enhance the multi-scale feature extraction to obtain the feature layer C4″. Finally, the feature layer C4″ is added to the feature layer C2′. Similarly, for the C5′ layer, the information loss of C2 and C3 layers is more serious than that of the C4 layer, that is, the bottom-up path, see Figure 5 The thick blue line in . Therefore, the C2 layer is first fused with the C3 layer through the ASFF operation, and then the C3″ layer is obtained through the DRM module and added to C5′. The subsequent operations of the C5′ layer are the same as those of the C2′ layer.

[0075] (2) Taking the C3′ layer as an example, in the initial feature fusion process of BiFPN, that is, the bottom-up path, see Figure 5 The thick red line in the figure shows that the information loss of C5 layer is more serious than that of other layers. Therefore, an auxiliary branch C5″ is added to C3′ layer, which fuses C4 layer with C5 layer through ASFF operation to further reduce the semantic difference across layers. DRM operation is also used to enhance multi-scale feature extraction. Similarly, for C4′ layer, the information loss of C2 layer is also more serious than that of other layers, that is, the top-down path, see Figure 5 Thick blue line in . Therefore, an auxiliary branch C2″ is added to the C4′ layer, which is obtained by a similar operation as C5″.

[0076] Specifically, the present invention integrates two levels of features in the auxiliary branch through the ASFF operation, which can adaptively learn the spatial fusion weights of each feature layer. Then, the auxiliary branch is fused to the corresponding feature layer in BiFPN. The whole process is as follows:

[0077] a) First, the feature layers extracted by the backbone network are normalized to a unified channel through a 1×1 convolution operation. Since different feature layers have different resolutions, these feature layers are adjusted to the same size through upsampling or downsampling operations.

[0078] b) Secondly, use ASFF operation: Represents the feature vector at the feature map position (i, j) adjusted from feature layer n to feature layer l. The corresponding feature vector after fusion on layer l is obtained by the following method

[0079]

[0081] in and are the spatial weights from two different feature layers to feature layer l. These weights are adaptively learned by the network and satisfy the following constraints:

[0082]

[0083] in and is a hyperparameter that controls the softmax function.

[0084] c) Finally, the fused feature layer obtained by the ASFF operation is processed by the DRM operation and the auxiliary branches are obtained. Then, each auxiliary branch is added to the corresponding feature layer in BiFPN after upsampling or downsampling operation. In this way, the features of all levels are adaptively aggregated to obtain the output {P2, P3, P4, P5} of EFPN and pass it to the subsequent Head part.

[0085] For example, in EFPN, the C4 and C5 layers are unified to the same channel through 1×1 convolution. Then, after the upsampling operation, the C5 layer is fused with the C4 layer through the ASFF operation:

[0086]

[0087] Subsequently, the auxiliary branch C4″ is obtained through DRM module processing, and then added to the C2′ layer through upsampling operation. Finally, the output feature layer P2 is generated after further DRM module processing.

[0088] The upsampling or downsampling operation means that if a high-level feature map is fused to a low-level feature map, the high-level feature map needs to be upsampled first; conversely, if a low-level feature map is fused to a high-level feature map, the low-level feature map needs to be downsampled first.

[0089] 3. Improved convolution calculation

[0090] The C2f module is used in the YOLOv8 model to enhance feature extraction capabilities. Figure 6 As shown in part (a) of the figure, the C2f module includes residual connections and a series of bottleneck structures Bottlenecks. The number of channels of the bottleneck input is half of the number of channels of the C2f module input, which effectively reduces the computational cost. The residual connection and multi-branch architecture increase the gradient flow in back propagation, improving the convergence speed and efficiency. However, simply increasing the number of bottlenecks is not enough to improve the model's ability to extract effective features, especially when detecting wood surface defects. This is because wood surface defects have different scales and irregular shapes, which results in a large amount of background information contained in the bounding box.

[0091] In order to solve the above problems, the present invention designs a DRM module, such as Figure 6 As shown in part (b) of the paper, it is introduced into the improved Neck structure, namely EFPN. It contains many dilated heavy parameter blocks DRB to achieve a larger receptive field without increasing additional computational consumption. DRB uses non-dilated convolutions with small convolution kernels and multiple dilated convolutions with small convolution kernels to enhance non-dilated convolutions with large convolution kernels, which has a more flexible receptive field and can improve the performance of feature extraction without increasing the inference cost.

[0092] like Figure 7 As shown in the figure, the dilated reparameter block DRB includes a 9×9 convolution with a dilation rate of 1, two 5×5 convolutions with dilation rates of 1 and 2, and two 3×3 convolutions with dilation rates of 3 and 4. The outputs of these convolutions are combined by summing after batch normalization BN. During training, the DRB module can extract multi-scale features more effectively, because the enhanced large-kernel convolution can capture a wider range of feature dependencies, and the dilated convolutions with multiple small kernels can more effectively extract more complex spatial patterns. During inference, through the structural reparameterization technique, the batch normalization layer is merged into the convolution layer, and the dilated convolutions with multiple small kernels are integrated into the large-kernel convolution; this operation converts the entire DRB block into a single non-dilated convolution, which is equivalent to eliminating the inference cost of the additional dilated convolution operation.

[0093] Finally, the annotated data is imported into the improved YOLOv8l model for wood surface defect detection: After the image is input into the model, the model first extracts features from the image through FasterNet to generate feature maps at different levels, and then performs spatial pyramid pooling SPPF operation after FasterNet. After that, the feature maps at different levels are fused through EFPN to integrate low-dimensional detail information and high-dimensional semantic information, enriching the multi-scale expression ability of the model. Finally, at the Head layer, the input feature map is calculated through four different convolution groups, and the bounding box, category probability and confidence score are obtained; the structure diagram of the improved YOLOv8 model is shown below: Fig.11 shown.

[0094] In order to verify the actual effect of the present invention, a comparative experiment was conducted between the YOLOv8l model and the improved model. The experimental results are shown in Table 1. The experimental results show that the number of parameters and the amount of calculation of the improved model have been significantly reduced, and the model mAP@50 has increased by about 2.4%, which has improved the multi-scale detection capability of the model and achieved the expected goal. Fig.12 shown.

[0095] Model <![CDATA[Parameters / 10 7 ]]> GFLOPs mAP50 mAP50-95 YOLOv8l 42.82 204.8 0.572 0.281 Improved Model 22.07 140.2 0.596 0.296

[0096] Table 1 Model comparison data

[0097] Embodiment 2,

[0098] This embodiment also provides an electronic device, including:

[0099] at least one processor; and

[0100] A memory storing instructions, which, when executed by the at least one processor, enable the at least one processor to execute the wood surface defect detection method based on the improved YOLOv8l as described above.

[0101] In this embodiment, the electronic device may include, but is not limited to: personal computers, server computers, workstations, desktop computers, laptop computers, notebook computers, mobile computing devices, smart phones, tablet computers, cellular phones, personal digital assistants (PDAs), handheld devices, messaging devices, wearable computing devices, consumer electronic devices, and the like.

[0102] Embodiment 3,

[0103] This embodiment also provides a machine-readable storage medium storing executable instructions, which, when executed, enable the machine to execute the above-mentioned method for detecting wood surface defects based on improved YOLOv8l.

[0104] Specifically, a system or device equipped with a readable storage medium can be provided, on which software program codes that implement the functions of any of the above-mentioned embodiments are stored, and a computer or processor of the system or device can read and execute instructions stored in the readable storage medium.

[0105] In this case, the program code itself read from the machine-readable medium can realize the function of any one of the above embodiments, and thus the machine-readable code and the machine-readable storage medium storing the machine-readable code constitute part of this specification.

[0106] Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tapes, non-volatile memory cards, and ROMs. Optionally, the program code may be downloaded from a server computer or a cloud via a communication network.

[0107] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the technical solution of the present invention, and are not intended to limit the specific implementation methods of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the claims of the present invention shall be included in the protection scope of the claims of the present invention.

Claims

1. A wood surface defect detection method based on improved YOLOv8l, characterized in that: The method comprises: S1, wood defect image collection, and then mark the defects in the dataset; S2. Improve the YOLOv8 model to get the improved YOLOv8l model: First, use FasterNet to improve Backbone; Then, an enhanced weighted bidirectional feature pyramid network EFPN is designed, the original Neck structure PANet in YOLOv8 is replaced by EFPN, and the DRM module is introduced into EFPN; S3. Based on the labeled data, the improved YOLOv8l model is imported to detect wood surface defects.

2. A wood surface defect detection method based on improved YOLOv81 according to claim 1, characterized in that: The use of FasterNet to improve Backbone means: using FasterNet to replace the original Backbone network CSPDarkNet53 in YOLOv8; The FasterNet has four layers, each of which is preceded by an embedding layer or a merging layer for spatial downsampling and channel number expansion. Each layer contains a series of FasterNet basic blocks, each of which contains a partial convolution PConv layer followed by two point-by-point convolution Conv 1×1, and a Shortcut is used to reuse input features. The partial convolution PConv applies a regular convolution Conv on a portion of the input channels while keeping the remaining channels unchanged.

3. A wood surface defect detection method based on improved YOLOv81 according to claim 1, characterized in that: The specific process of the enhanced weighted bidirectional feature pyramid network EFPN is as follows: a) The feature layers C2, C3, C4, and C5 extracted by the backbone network are normalized into a unified channel through a 1×1 convolution operation. Since different feature layers have different resolutions, these feature layers are adjusted to the same size through upsampling or downsampling operations; b) Use the bidirectional weighted feature pyramid network BiFPN to perform preliminary feature fusion to obtain feature layers C2′, C3′, C4′, and C5′; c) Use ASFF operation to fuse the features of the two levels, and obtain the corresponding feature vector after fusion on layer l in the following way In formula (1), Represents the feature vector at position (i, j) of the feature map adjusted from feature layer n to feature layer l; and are the spatial weights from two different feature layers to feature layer l, which are adaptively learned by the network and satisfy the following constraints: In formula (3), and It is a hyperparameter that controls the softmax function; d) The fused feature layer obtained after the ASFF operation is processed by the DRM module to obtain auxiliary branches, namely feature layers C2″, C3″, C4″ and C5″; each auxiliary branch is added to the corresponding feature layer in the bidirectional weighted feature pyramid network BiFPN after upsampling or downsampling operation, and then the feature map generated after the addition is processed by the DRM module to obtain the output {P2, P3, P4, P5} of EFPN, and the output is passed to the subsequent Head part; in EFPN, bilinear interpolation is used as the upsampling operation and 3×3 convolution with a step size of 2 is used as the downsampling operation.

4. A wood surface defect detection method based on improved YOLOv81 according to claim 3, characterized in that: The auxiliary branch adopts different fusion strategies for different feature layers, as follows: In the preliminary feature fusion process of BiFPN, for the C2′ layer, the information loss of the C4 and C5 layers is more serious than that of the C3 layer. The auxiliary branch C4″ is introduced to the C2′ layer to reduce the information loss: first, the C5 layer is fused to the C4 layer through the ASFF operation; then, the multi-scale feature extraction is enhanced through the DRM module to obtain the auxiliary branch C4″; finally, the auxiliary branch C4″ is added to the feature layer C2′, and then the added feature layer is processed by the DRM module to obtain the feature layer P2; Similarly, for the C5′ layer, the information loss of the C2 and C3 layers is more serious than that of the C4 layer, and an auxiliary branch C3″ is introduced to the C5′ layer: first, the C2 layer is fused to the C3 layer through the ASFF operation, and then the multi-scale feature extraction is enhanced through the DRM module to obtain the auxiliary branch C3″. Finally, the auxiliary branch C3″ is added to the feature layer C5′, and then the added feature layer is processed by the DRM module to obtain the feature layer P5. In the preliminary feature fusion process of BiFPN, for the C3′ layer, the information loss of the C5 layer is more serious than that of the C2 and C4 layers, and the auxiliary branch C5″ is introduced to the C3′ layer: first, the C4 layer is fused to the C5 layer through the ASFF operation; then the multi-scale feature extraction is enhanced through the DRM module to obtain the auxiliary branch C5″; finally, the auxiliary branch C5″ is added to the feature layer C3′, and then the added feature layer is processed by the DRM module to obtain the feature layer P3; Similarly, for the C4′ layer, the information loss of the C2 layer is more serious than that of the C3 and C5 layers, and an auxiliary branch C2″ is introduced to the C4′ layer: first, the C3 layer is fused to the C2 layer through the ASFF operation, and then the multi-scale feature extraction is enhanced through the DRM module to obtain the auxiliary branch C2″; finally, the auxiliary branch C2″ is added to the feature layer C4′, and then the added feature layer is processed by the DRM module to obtain the feature layer P4.

5. A wood surface defect detection method based on improved YOLOv81 according to claim 4, characterized in that: The DRM module contains many dilated re-parameter blocks DRB, which include a 9×9 convolution with a dilation rate of 1, two 5×5 convolutions with dilation rates of 1 and 2 respectively, and two 3×3 convolutions with dilation rates of 3 and 4 respectively. The outputs of these five convolutions are combined by summing after batch normalization BN; during the inference process, through the structural re-parameterization technology, the batch normalization layer is merged into the convolution layer, and multiple small-core dilated convolutions are integrated into the large-core convolution, converting the entire DRB block into a single non-dilated convolution.

6. A wood surface defect detection method based on improved YOLOv81 according to claim 1, characterized in that: The step S3 is specifically as follows: after the image is input into the model, the model first extracts features from the image through FasterNet to generate feature maps at different levels, and performs spatial pyramid pooling SPPF operation after FasterNet; then, the feature maps at different levels are fused through EFPN to integrate low-dimensional detail information and high-dimensional semantic information, enriching the multi-scale expression capability of the model; finally, at the Head layer, the input feature map is calculated through four different convolution groups, and the bounding box, category probability and confidence score are obtained.

7. An electronic device, characterized in that: The electronic device comprises: at least one processor; and A memory storing instructions, which, when executed by the at least one processor, enables the at least one processor to execute a wood surface defect detection method based on improved YOLOv81 as described in any one of claims 1 to 6.

8. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores executable instructions, which, when executed, enable the machine to execute a wood surface defect detection method based on improved YOLOv81 as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Wood defect detection method and system based on deep neural network

    CN117876663A

Cited By

  • Wood repairing method and device and medium

    CN120411054A

  • Wood repair method, device and medium

    CN120411054B