Wood surface defect detection method and device based on dual-path fusion attention network

By optimizing the YOLOv5s model structure and loss function, and employing DP-DCM, FAM, and FocalModulation, the problems of real-time performance and small target detection in wood surface defect detection were solved, achieving efficient and accurate wood surface defect detection.

CN121527014APending Publication Date: 2026-02-13NANJING FORESTRY UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511627128.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-07
Publication Date
2026-02-13

AI Technical Summary

Technical Problem

Existing deep learning models struggle to guarantee real-time performance in wood surface defect detection, suffer from high computational complexity, are insufficient for detecting small targets, are severely affected by complex background interference, and are sensitive to changes in lighting. As a result, they are difficult to achieve efficient and accurate automated detection in resource-constrained industrial scenarios.

Method used

A dual-path fusion attention network based on YOLOv5s is adopted. By introducing a dual-path downsampling convolutional module (DP-DCM), a fusion attention module (FAM), and a focus modulation module (FocalModulation), and improving the loss function to NWD-Loss, the model structure and loss function are optimized to improve detection accuracy and efficiency.

Benefits of technology

It significantly reduces model parameters and computational load, improves the accuracy and robustness of small target detection, enhances adaptability to complex backgrounds and lighting changes, enables real-time detection, and meets industrial needs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121527014A_ABST
    Figure CN121527014A_ABST
Patent Text Reader

Abstract

The invention discloses a wood surface defect detection method and device based on a dual-path fusion attention network. The method comprises the following steps: acquiring a wood surface image; the wood surface image is input into a pre-trained DFA-Net-YOLO model, and the defect category and position are obtained; wherein the DFA-Net-YOLO model is based on a YOLOv5s framework, comprises a backbone network, a neck network and a head network, and at least comprises the following steps: a) replacing down-sampling layers of the backbone network and the neck network by adopting a dual-path down-sampling convolution module DP-DCM; b) adding a fusion attention module FAM and a focus modulation module FM in the backbone network; and c) taking NWD-Loss as a bounding box regression loss function of the head network. The method can greatly reduce the complexity and calculation amount of the model while guaranteeing the detection precision, and especially optimizes the small target detection performance.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to a wood surface defect detection method and device based on a dual-path fusion attention network, and belongs to the technical field of computer vision. BACKGROUND

[0002] In the wood processing process, accurately and efficiently detecting wood surface defects (such as knots, cracks, insect eyes, decay, etc.) is crucial to ensuring product quality. Traditional manual visual inspection methods are not only inefficient, but also prone to missed detection and false detection due to subjective judgment and visual fatigue. Although non-contact physical detection methods such as ultrasonic waves and stress waves avoid direct contact, they are often greatly affected by environmental temperature and humidity, have high equipment costs, and are difficult to operate, making it difficult to adapt to automated online detection processes.

[0003] In recent years, deep learning target detection models represented by the YOLO series have been widely used in industrial defect detection due to their speed and accuracy. However, directly applying these models to wood defect detection still faces several outstanding problems:

[0004] (1) Real-time performance is difficult to guarantee: Mainstream models such as YOLOv5l / x, YOLOv7, and YOLOv8m are computationally complex and have many parameters, making it difficult to achieve real-time inference on edge devices in high-speed wood production lines.

[0005] (2) High model complexity: These models require high computational and storage capabilities of edge devices, resulting in high deployment costs and making it difficult to promote in resource-constrained industrial scenarios.

[0006] (3) Poor detection performance for small defects: Small cracks, insect eyes, and other defects on the surface of wood are small in size and not obvious in complex and variable wood grain backgrounds. Existing models (including lightweight versions such as YOLOv5s / n and YOLOv8n / s) lack the ability to detect small targets, resulting in high miss detection rates. In addition, commonly used IoU series loss functions (such as CIoU and DIoU) are overly sensitive to the position deviation of small targets, resulting in unstable gradients and further affecting positioning accuracy.

[0007] (4) Complex background interference: Wood itself has diverse and irregular textures, which can easily interfere with real defects, especially when light conditions change, the stability and robustness of the model will decrease.

[0008] Therefore, there is an urgent need for a lightweight real-time detection method that can significantly reduce model complexity and computational load while ensuring detection accuracy, particularly optimizing small target detection performance and enhancing adaptability to complex textures and light changes. SUMMARY

[0009] Objective: In view of at least one of the above technical problems, the present application provides a wood surface defect detection method and device based on a dual-path fusion attention network, which is based on YOLOv5s, introduces a dual-path down-sampling convolution module (DP-DCM), a fusion attention module (FAM), and a focal modulation module (Focal Modulation), and improves the loss function (replaces CIoU-Loss with NWD-Loss), achieving a good balance between detection accuracy and running efficiency.

[0010] The technical scheme adopted by the present application is:

[0011] In a first aspect, the present application provides a wood surface defect detection method based on a dual-path fusion attention network, comprising:

[0012] Obtaining a wood surface image;

[0013] Inputting the wood surface image into a pre-trained DFA-Net-YOLO model to obtain defect categories and positions; wherein the DFA-Net-YOLO model is based on a YOLOv5s framework, including a backbone network, a neck network, and a head network, and at least including:

[0014] a) replacing the down-sampling layers of the backbone network and the neck network with a dual-path down-sampling convolution module DP-DCM;

[0015] b) adding a fusion attention module FAM and a focal modulation module FM to the backbone network;

[0016] c) using NWD-Loss as the bounding box regression loss function of the head network.

[0017] In some embodiments, the backbone network is used to extract deep features of the wood surface image to obtain multi-scale feature maps, including a first scale feature map, a second scale feature map, and a third scale feature map; the processing process includes: the wood surface image passes through a first convolution layer Conv, a first DP-DCM, a first C3, a second DP-DCM, a second C3 to obtain the first scale feature map, the first scale feature map passes through a third DP-DCM, a third C3 to obtain the second scale feature map, the second scale feature map passes through a fourth DP-DCM, a fourth C3, a fusion attention module FAM, and a focal modulation module FM to obtain the third scale feature map;

[0018] The neck network processing process comprises: a third scale feature map passing through a second convolution layer Conv to obtain a first intermediate fusion feature map, the first intermediate fusion feature map being spliced with the second scale feature map after first upsampling, and then passing through a fifth C3 and a third convolution layer Conv to obtain a second intermediate fusion feature map; the second intermediate fusion feature map being spliced with the first scale feature map after second upsampling and then passing through a sixth C3 to obtain a first fusion feature map, the first fusion feature map being spliced with the second intermediate fusion feature map after fifth DP-DCM and then passing through a seventh C3 to obtain a second fusion feature map, the second fusion feature being spliced with the first intermediate fusion feature map after sixth DP-DCM and then passing through a seventh C3 to obtain a third fusion feature map;

[0019] The head network processing process comprises: classifying the first fusion feature map, the second fusion feature map and the third fusion feature map according to the category of defects and boundary box regression to obtain the category of defects and the position of defects corresponding thereto; wherein the boundary box regression adopts an NWD loss function.

[0020] In some embodiments, the dual-path down-sampling convolution module DP-DCM comprises:

[0021] (1) a first path adopting a depth separable convolution and an average pooling;

[0022] (2) a second path adopting a maximum pooling and a wavelet transform convolution WTConv;

[0023] (3) the feature maps output by the two paths being spliced in the channel dimension and then compressed through a 1x1 convolution.

[0024] In some embodiments, the fusion attention module FAM comprises a channel attention submodule and a spatial attention submodule arranged in parallel, the channel attention submodule being implemented using a 1D convolution, and the spatial attention submodule being implemented using a 2D convolution; wherein,

[0025] The channel attention submodule performs global average pooling on the input feature map to capture global context information of the channel, inputs the result of the global average pooling into a shared multi-layer perception network to generate a channel weight vector, normalizes the weight through a Sigmoid activation function, and performs channel weighting on the original input feature map to obtain a channel weighted feature map;

[0026] The spatial attention submodule performs average pooling and maximum pooling on the channel weighted feature map along the channel dimension respectively, splices the results of the average pooling and the maximum pooling, generates a spatial weight map through a convolution layer, normalizes the weight through a Sigmoid activation function, and performs spatial weighting on the channel weighted feature map to obtain an output feature map.

[0027] In some embodiments, the focus modulation module FM uses three groups of depth convolution kernels: 3×3, 5×5, and 7×7, and dynamically aggregates the output through a gating mechanism.

[0028] Hierarchical feature extraction: For input features, depthwise separable convolution is used to extract multi-scale contextual features on different receptive fields;

[0029] Gated aggregation: Adaptive weighted aggregation of extracted multi-scale contextual features to obtain aggregated contextual information;

[0030] Element-level affine transformation: The aggregated contextual information is modulated onto the original input features through a lightweight projection layer.

[0031] In some embodiments, the NWD-Loss model the predicted bounding box and the ground truth bounding box as two-dimensional Gaussian distributions, and uses the Wasserstein distance between the normalized two Gaussian distributions as the loss metric.

[0032] In some embodiments, the DFA-Net-YOLO model has ≤6M parameters and an inference speed ≥100FPS with a 640×640 input.

[0033] Secondly, this application provides a wood surface defect detection device based on a dual-path fusion attention network, including a processor and a storage medium;

[0034] The storage medium is used to store instructions;

[0035] The processor is configured to operate according to the instructions to execute the method according to the first aspect.

[0036] Thirdly, this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in the first aspect.

[0037] Fourthly, this application provides a computer device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the method described in the first aspect.

[0038] Fifthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the method described in the first aspect.

[0039] Beneficial effects: The wood surface defect detection method and device based on dual-path fusion attention network provided in this application have the following advantages:

[0040] (1) Significantly improves real-time performance and reduces deployment costs:

[0041] By introducing lightweight DP-DCM and focus modulation modules, the DFA-Net model reduces the number of model parameters by approximately 17.1% (from 7.0M to 5.8M) and computational cost (FLOPs) by approximately 20.3% (from 15.8G to 12.6G) compared to the original YOLOv5s, while maintaining high accuracy. Real-world testing on an NVIDIA GeForce RTX 4060 Ti showed an inference speed of 105 FPS, far exceeding the real-time industrial detection requirements (>30 FPS), significantly reducing the deployment cost of edge devices.

[0042] (2) Effectively improves the detection accuracy of small targets:

[0043] Thanks to the multi-scale feature extraction of DP-DCM, contextual modeling of the focus modulation module, and optimization of NWD-Loss, DFA-Net significantly improves the detection performance of small-sized defects (such as cracks with an average size <32×32 pixels). Experiments show that for small target defects, DFA-Net achieves a recall rate of 93%, which is 6.5 percentage points higher than the original YOLOv5s (86.5%); the localization accuracy of small targets (mAP@0.5:0.95) also improves by 0.5% (with NWD-Loss contributing significantly).

[0044] (3) Enhance robustness to complex backgrounds and lighting changes:

[0045] The FAM module effectively suppresses background interference from complex wood textures (such as live / dead knot textures) through channel and spatial attention mechanisms. The multi-scale dynamic focusing mechanism of the focus modulation module enhances illumination adaptability. On a complex dataset containing five types of defects (cracks, live knots, dead knots, notches, and bark inclusions), DFA-Net achieves an overall mAP@0.5 of 93% (see [link to DFA module]). Figure 6 The fluctuation range is <1%.

[0046] (4) Optimize small target positioning performance:

[0047] After replacing CIoU-Loss with NWD-Loss, the localization error of small targets (such as cracks) was reduced by more than 30% (the IoU mutation problem was alleviated by modeling with Gaussian distribution), the model convergence speed was improved by 18%, and the inference speed was improved from 75 FPS to 105 FPS. Attached Figure Description

[0048] Figure 1 This is a flowchart illustrating a wood surface defect detection method based on a dual-path fusion attention network according to an embodiment of this application; a schematic diagram of the DFA-Net-YOLO model.

[0049] Figure 2This is a schematic diagram of defect detection results according to an embodiment of this application;

[0050] Figure 3 This is a schematic diagram of a dual-path downsampling convolutional module (DP-DCM) according to an embodiment of this application;

[0051] Figure 4 This is a schematic diagram of a Fusion Attention (FAM) module according to one embodiment of this application;

[0052] Figure 5 This is a schematic diagram of a focus modulation module (FM) according to an embodiment of this application;

[0053] Figure 6 This is a schematic diagram of the PR curve of the improved model according to an embodiment of this application; Detailed Implementation

[0054] The present application will be further described below with reference to the accompanying drawings and embodiments. The following embodiments are only used to more clearly illustrate the technical solutions of the present application, and should not be used to limit the scope of protection of the present application.

[0055] In the description of this application, "several" means one or more, "multiple" means two or more, "greater than," "less than," and "exceeding" are understood to exclude the stated number, while "above," "below," and "within" are understood to include the stated number. The use of "first" and "second" in the description is merely for distinguishing technical features and should not be construed as indicating or implying relative importance, or implicitly indicating the number of indicated technical features, or implicitly indicating the order of the indicated technical features.

[0056] In the description of this application, the terms "one embodiment," "some embodiments," "illustrative embodiment," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of this application. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Furthermore, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples.

[0057] The term "and / or" simply describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. Additionally, the character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0058] Example 1: This example provides a method for detecting surface defects in wood based on a dual-path fusion attention network, such as... Figure 1 As shown, it includes:

[0059] Acquire images of the wood surface;

[0060] The wood surface image is input into a pre-trained DFA-Net-YOLO model to obtain defect categories and locations; wherein, the DFA-Net-YOLO model is based on the YOLOv5s framework, including a backbone network, a neck network, and a head network, and includes at least:

[0061] a) Replace the downsampling layers of the backbone and neck network with a dual-path downsampling convolutional module DP-DCM;

[0062] b) Add the Fusion Attention Module (FAM) and Focus Modulation Module (FM) to the backbone network;

[0063] c) Use NWD-Loss as the bounding box regression loss function for the head network.

[0064] like Figure 1 As shown, the backbone network sequentially includes: a first convolutional layer Conv, a first DP-DCM, a first C3, a second DP-DCM, a second C3, a third DP-DCM, a third C3, a fourth DP-DCM, a fourth C3, a fusion attention module FAM, and a focus modulation module FM. This is used to extract deep features from the wood surface image to obtain multi-scale feature maps, including a first-scale feature map, a second-scale feature map, and a third-scale feature map. The specific processing steps include: the wood surface image passes through the first convolutional layer Conv, the first DP-DCM, the first C3, the second DP-DCM, and the second C3 to obtain a first-scale feature map; the first-scale feature map passes through the third DP-DCM and the third C3 to obtain a second-scale feature map; and the second-scale feature map passes through the fourth DP-DCM, the fourth C3, the fusion attention module FAM, and the focus modulation module FM to obtain a third-scale feature map.

[0065] The neck network processing includes: the third-scale feature map is passed through the second convolutional layer (Conv) to obtain the first intermediate fused feature map; the first intermediate fused feature map is upsampled and then concatenated with the second-scale feature map; then it is passed through the fifth C3 and the third convolutional layer (Conv) to obtain the second intermediate fused feature map; the second intermediate fused feature map is upsampled and then concatenated with the first-scale feature map; then it is passed through the sixth C3 to obtain the first fused feature map; the first fused feature map is passed through the fifth DP-DCM and then concatenated with the second intermediate fused feature map; then it is passed through the seventh C3 to obtain the second fused feature map; the second fused feature map is passed through the sixth DP-DCM and then concatenated with the first intermediate fused feature map; then it is passed through the seventh C3 to obtain the third fused feature map.

[0066] The head network processing includes: classifying defects and regressing bounding boxes using the first fused feature map, the second fused feature map, and the third fused feature map to obtain the defect category and the corresponding defect location; wherein the bounding box regression uses the NWD loss function.

[0067] In some embodiments, such as Figure 3 As shown, the dual-path downsampling convolutional module DP-DCM includes:

[0068] (1) The first path uses depthwise separable convolution and average pooling;

[0069] (2) The second path uses max pooling and wavelet transform convolution WTConv;

[0070] (3) The feature maps output by the two paths are concatenated in the channel dimension and then compressed by 1×1 convolution.

[0071] The Dual-Path Downsampling Convolutional Module (DP-DCM) replaces the downsampling layer in the original model, combining wavelet transform with a dual-path feature fusion mechanism. For example... Figure 3 As shown, its main workflow includes:

[0072] (1) The input feature map first passes through an average pooling layer to initially reduce the spatial dimension and computational cost;

[0073] (2) Divide the pooled feature map into two parts evenly in the channel dimension;

[0074] (3) Path 1: A portion of the feature map is processed by depthwise separable convolution to extract local spatial features;

[0075] (4) Path 2: Another part of the feature map first goes through the max pooling layer, and then the wavelet transform convolution (WTConv) is applied to extract multi-scale frequency domain features, which enhances the ability to represent irregular and small targets.

[0076] (5) Concat the feature maps output by path one and path two along the channel dimension to fuse local details and multi-scale contextual information to form the final output feature map.

[0077] In some embodiments, such as Figure 4 As shown, the fusion attention module (FAM) includes parallel channel attention submodules and spatial attention submodules. The channel attention submodule is implemented using 1D convolution, and the spatial attention submodule is implemented using 2D convolution.

[0078] The channel attention submodule performs global average pooling (GAP) on the input feature map to capture the global context information of the channels. The result of global average pooling GAP is input into a shared multilayer perceptron (MLP) network to generate channel weight vectors. The weights are normalized by the sigmoid activation function and then channel-weighted with the original input feature map to obtain the channel-weighted feature map.

[0079] The spatial attention submodule performs average pooling and max pooling along the channel dimension on the channel-weighted feature map. The results of average pooling and max pooling are concatenated and passed through a convolutional layer to generate a spatial weight map. The weights are normalized by the Sigmoid activation function and spatially weighted with the channel-weighted feature map to obtain the output feature map.

[0080] The Fusion Attention Module (FAM) can dynamically focus on key channels and spatial regions related to defects, effectively suppressing interference from complex wood grain backgrounds.

[0081] In some embodiments, such as Figure 5 As shown, the focus modulation module FM employs three groups of depthwise convolutional kernels (3×3, 5×5, and 7×7) and dynamically aggregates the output through a gating mechanism. The processing specifically includes:

[0082] Hierarchical feature extraction: For input features, depthwise separable convolution is used to extract multi-scale contextual features on different receptive fields;

[0083] Gate aggregation: Adaptively weighted aggregation of extracted multi-scale contextual features to obtain aggregated contextual information;

[0084] Element-level affine transformation: The aggregated contextual information is modulated onto the original input features through a lightweight projection layer.

[0085] This fusion attention module captures long-range dependencies and rich context with low computational overhead, enhancing the model's ability to perceive small defects and adapt to different lighting conditions.

[0086] In some embodiments, the NWD loss function (NWD-Loss) models the predicted bounding box and the ground truth bounding box as two-dimensional Gaussian distributions, and uses the Wasserstein distance between the normalized two Gaussian distributions as the loss metric. NWD-Loss replaces CIoU-Loss in the original YOLOv5 as the primary loss function for bounding box regression to address the issue of small target localization accuracy.

[0087] More specifically, the bounding box is modeled as a two-dimensional Gaussian distribution (using the center point as the mean and half the side length as the standard deviation to construct the covariance matrix), which is to predict the bounding box. and the true bounding box Convert them to Gaussian distributions N(μ) respectively p ,Σp) and N(μ g ,Σg); To predict the x and y coordinates of the bounding box center, To predict the width and height of the bounding box; The x and y coordinates of the center of the true bounding box. The width and height of the actual bounding box; μ p Σp represents the mean and covariance matrix of the predicted bounding box, and μ represents... g Σg represents the mean and covariance matrix of the true bounding box.

[0088] Calculate the Wasserstein distance between two Gaussian distributions :

[0089]

[0090] Normalize the Wasserstein distance to obtain the normalized distance. : ,

[0091] NWD Loss Function This NWD loss function provides a smoother gradient for small targets, significantly alleviating the severe fluctuations and gradient vanishing problems of IoU-type losses on small targets, and effectively improving the localization accuracy and detection stability of small targets.

[0092] Simulation examples,

[0093] (1) Raw data acquisition and data preprocessing

[0094] Data Source: The raw data collected by this method consists of high-resolution surface images from timber production lines. The images should cover various common defect types, such as knots (live and dead knots), cracks, bark inclusions, and notches. To ensure the generalization ability of the model, data collection needs to be carried out under different lighting conditions, different wood species (such as pine, oak, and cedar), and different surface texture backgrounds.

[0095] Data cleaning and labeling: Remove blurry, overly dark, or overly bright invalid images. Use tools such as LabelImg to annotate the bounding boxes of defects in valid images and generate corresponding VOC or YOLO format label files.

[0096] Data augmentation: To expand the dataset and improve model robustness, a series of online and offline data augmentation techniques were applied to the training set images, including: random horizontal / vertical flipping, random rotation (±10°), random brightness / contrast adjustment, addition of Gaussian noise, and Mosaic enhancement. These operations effectively simulated various complex scenarios that might be encountered on a production line, preventing model overfitting.

[0097] (2) Model building and training

[0098] Using YOLOv5s as the baseline model, a DFA-Net model was built, with specific improvements including:

[0099] (1) A dual-path downsampling convolutional module (DP-DCM) is introduced into the backbone network to replace some of the standard convolutional layers. This module enhances the ability to capture small targets and multi-scale defects while reducing the amount of computation by fusing spatial details and frequency domain context information.

[0100] (2) Embedded Fusion Attention Module (FAM), which integrates channel attention and spatial attention mechanisms, dynamically focuses on feature regions related to defects, effectively suppressing interference from complex wood grain backgrounds.

[0101] (3) A Focal Modulation module is introduced. Through hierarchical feature extraction, gated aggregation and element-level affine transformation, long-range dependencies and rich context are captured with low computational overhead, enhancing the model’s ability to perceive small defects and adapt to changes in illumination.

[0102] (4) In the bounding box regression task of the detection head, the NWD loss function (NWD-Loss) is used instead of the traditional CIoU-Loss. By modeling the bounding box as a Gaussian distribution and calculating the normalized Wasserstein distance, a smoother gradient signal is provided for small targets, which significantly improves the localization accuracy.

[0103] The preprocessed image data is fed into the DFA-Net model constructed in this application for end-to-end training and inference. The training process employs the following strategy:

[0104] The AdamW optimizer is employed, along with a cosine annealing learning rate scheduling strategy, to promote more stable model convergence. Gradient clipping is also introduced to prevent gradient explosion during training.

[0105] Model Pruning and Quantization: After model training, to further reduce model size and improve inference speed for adaptation to more peripheral devices, this application performs channel pruning on the trained DFA-Net model, removing redundant channels that contribute little to the output. Subsequently, the pruned model is quantized using INT8, converting the FP32 weights and activation values ​​into low-precision integers, significantly reducing model storage requirements and computational overhead.

[0106] Knowledge distillation (optional): When resources permit, a larger and more accurate teacher model (such as YOLOv5l) can be used to guide the training of DFA-Net (student model), thereby further improving the performance of the student model by transferring the knowledge of the teacher model.

[0107] After the model is trained, it is tested, and the final output is the defect detection result of the input image. Each result includes:

[0108] Defect categories: such as "cracks," "knots," "notches," etc. (See also...) Figure 2 )

[0109] Confidence score: The degree of confidence the model has in the prediction result.

[0110] Bounding box coordinates: precisely pinpoint the location of defects in the image.

[0111] These results can be displayed in real time on the user interface or transmitted to the production line control system via the network to trigger subsequent operations such as sorting and alarms.

[0112] Performance Validation: Model Evaluation and Performance Analysis: The optimized DFA-Net model was comprehensively evaluated using metrics such as precision, recall, F1 score, mean average precision (mAP), and frame rate (FPS). It was compared with the original YOLOv5 and other improved YOLO series models to verify its performance advantages in wood surface defect detection. Experimental results show that DFA-Net maintains high precision while reducing the number of model parameters by approximately 17.1% and computational cost by approximately 20.3%. On an NVIDIA GeForce RTX 4060 Ti, the inference speed reaches 105 FPS, meeting the real-time detection requirements of industry. Furthermore, for small target defects, the precision is improved to 93%, and the localization accuracy is also significantly improved.

[0113] System integration and application: Deploy the trained and optimized DFA-Net-YOLO model to industrial edge devices and integrate it into the visual inspection system of the wood production line.

[0114] The wood surface defect detection method based on a dual-path fusion attention network provided in this application has the following significant advantages:

[0115] (1) Significantly improves real-time performance and reduces deployment costs:

[0116] By introducing lightweight DP-DCM and focus modulation modules, the DFA-Net model reduces the number of model parameters by approximately 17.1% (from 7.0M to 5.8M) and computational cost (FLOPs) by approximately 20.3% (from 15.8G to 12.6G) compared to the original YOLOv5s, while maintaining high accuracy. Real-world testing on an NVIDIA GeForce RTX 4060 Ti showed an inference speed of 105 FPS, far exceeding the real-time industrial detection requirements (>30 FPS), significantly reducing the deployment cost of edge devices.

[0117] (2) Effectively improves the detection accuracy of small targets:

[0118] Thanks to the multi-scale feature extraction of DP-DCM, contextual modeling of the focus modulation module, and optimization of NWD-Loss, DFA-Net significantly improves the detection performance of small-sized defects (such as cracks with an average size <32×32 pixels). Experiments show that for small target defects, DFA-Net achieves a recall rate of 93%, which is 6.5 percentage points higher than the original YOLOv5s (86.5%); the localization accuracy of small targets (mAP@0.5:0.95) also improves by 0.5% (with NWD-Loss contributing significantly).

[0119] (3) Enhance robustness to complex backgrounds and lighting changes:

[0120] The FAM module effectively suppresses background interference from complex wood textures (such as live / dead knot textures) through channel and spatial attention mechanisms. The multi-scale dynamic focusing mechanism of the focus modulation module enhances illumination adaptability. On a complex dataset containing five types of defects (cracks, live knots, dead knots, notches, and bark inclusions), DFA-Net achieves an overall mAP@0.5 of 93% (see [link to DFA module]). Figure 6 The fluctuation range is <1%.

[0121] (4) Optimize small target positioning performance:

[0122] After replacing CIoU-Loss with NWD-Loss, the localization error of small targets (such as cracks) was reduced by more than 30% (the IoU mutation problem was alleviated by modeling with Gaussian distribution), the model convergence speed was improved by 18%, and the inference speed was improved from 75 FPS to 105 FPS.

[0123] In some embodiments, a wood surface defect detection system includes:

[0124] (1) An image acquisition device for acquiring images of the wood surface;

[0125] (2) An edge computing device, on which the DFA-Net-YOLO model is deployed;

[0126] (3) The sorting device removes defective wood based on the test results.

[0127] In some embodiments, the edge computing device is an NVIDIA Jetson series or equivalent ARM-A architecture embedded device.

[0128] This application also provides the use of the method in online sorting of surface defects in solid wood panels, plywood, and OSB particleboard.

[0129] Example 2: Based on Example 1, this example provides a wood surface defect detection device based on a dual-path fusion attention network, including a processor and a storage medium;

[0130] The storage medium is used to store instructions;

[0131] The processor is configured to operate according to the instructions to execute the method according to Embodiment 1.

[0132] Example 3: Based on Example 1, this example provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in Example 1.

[0133] Example 4: Based on Example 1, this example provides a computer device, including a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the method described in Example 1.

[0134] Example 5: Based on Example 1, this example provides a computer program product, including a computer program that, when executed by a processor, implements the method described in Example 1.

[0135] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0136] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, as well as combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0137] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0138] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0139] The above description is only a preferred embodiment of this application. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of this application, and these improvements and modifications should also be considered within the scope of protection of this application.

Claims

1. A method for detecting surface defects in wood based on a dual-path fusion attention network, characterized in that, include: Acquire images of the wood surface; The wood surface image is input into a pre-trained DFA-Net-YOLO model to obtain defect categories and locations; wherein, the DFA-Net-YOLO model is based on the YOLOv5s framework, including a backbone network, a neck network, and a head network, and includes at least: a) Replace the downsampling layers of the backbone and neck network with a dual-path downsampling convolutional module DP-DCM; b) Add the Fusion Attention Module (FAM) and Focus Modulation Module (FM) to the backbone network; c) Use NWD-Loss as the bounding box regression loss function for the head network.

2. The method according to claim 1, characterized in that, The backbone network is used to extract deep features from the wood surface image to obtain multi-scale feature maps, including a first-scale feature map, a second-scale feature map, and a third-scale feature map. The processing includes: the wood surface image is processed through a first convolutional layer (Conv), a first DP-DCM, a first C3, a second DP-DCM, and a second C3 to obtain a first-scale feature map; the first-scale feature map is processed through a third DP-DCM and a third C3 to obtain a second-scale feature map; and the second-scale feature map is processed through a fourth DP-DCM, a fourth C3, and fused with an attention module (FAM) and a focus modulation module (FM) to obtain a third-scale feature map. The neck network processing includes: the third-scale feature map is passed through the second convolutional layer (Conv) to obtain the first intermediate fused feature map; the first intermediate fused feature map is upsampled and then concatenated with the second-scale feature map; then it is passed through the fifth C3 and the third convolutional layer (Conv) to obtain the second intermediate fused feature map; the second intermediate fused feature map is upsampled and then concatenated with the first-scale feature map; then it is passed through the sixth C3 to obtain the first fused feature map; the first fused feature map is passed through the fifth DP-DCM and then concatenated with the second intermediate fused feature map; then it is passed through the seventh C3 to obtain the second fused feature map; the second fused feature map is passed through the sixth DP-DCM and then concatenated with the first intermediate fused feature map; then it is passed through the seventh C3 to obtain the third fused feature map. The head network processing includes: classifying defects and regressing bounding boxes using the first fused feature map, the second fused feature map, and the third fused feature map to obtain the defect category and the corresponding defect location; wherein the bounding box regression uses the NWD loss function.

3. The method according to claim 1, characterized in that, The dual-path downsampling convolutional module DP-DCM includes: (1) The first path uses depthwise separable convolution and average pooling; (2) The second path uses max pooling and wavelet transform convolution WTConv; (3) The feature maps output by the two paths are concatenated in the channel dimension and then compressed by 1×1 convolution.

4. The method according to claim 1, characterized in that, The fused attention module (FAM) includes parallel channel attention submodules and spatial attention submodules. The channel attention submodule is implemented using 1D convolution, and the spatial attention submodule is implemented using 2D convolution. The channel attention submodule performs global average pooling on the input feature map to capture the global context information of the channels. The result of global average pooling is input into a shared multilayer perceptron network to generate channel weight vectors. The weights are normalized by the sigmoid activation function and then channel-weighted with the original input feature map to obtain the channel-weighted feature map. The spatial attention submodule performs average pooling and max pooling along the channel dimension on the channel-weighted feature map. The results of average pooling and max pooling are concatenated and passed through a convolutional layer to generate a spatial weight map. The weights are normalized by the Sigmoid activation function and spatially weighted with the channel-weighted feature map to obtain the output feature map.

5. The method according to claim 1, characterized in that, The focus modulation module FM uses three groups of depth convolution kernels: 3×3, 5×5, and 7×7, and dynamically aggregates the output through a gating mechanism. Hierarchical feature extraction: For input features, depthwise separable convolution is used to extract multi-scale contextual features on different receptive fields; Gated aggregation: Adaptive weighted aggregation of extracted multi-scale contextual features to obtain aggregated contextual information; Element-level affine transformation: The aggregated contextual information is modulated onto the original input features through a lightweight projection layer.

6. The method according to claim 1, characterized in that, The NWD-Loss model the predicted bounding box and the ground truth bounding box as two-dimensional Gaussian distributions, and uses the Wasserstein distance between the normalized two Gaussian distributions as the loss metric.

7. The method according to claim 1, characterized in that, The DFA-Net-YOLO model has ≤6M parameters and an inference speed ≥100FPS with a 640×640 input.

8. A wood surface defect detection device based on a dual-path fusion attention network, characterized in that, Including processor and storage media; The storage medium is used to store instructions; The processor is configured to operate according to the instructions to perform the method according to any one of claims 1 to 7.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method according to any one of claims 1 to 7.

10. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the method according to any one of claims 1 to 7.