Wood repair method, device and medium

By improving the backbone network and detection head design of the YOLOv8 model, and combining depthwise separable convolution and lightweight attention modules, the problems of low efficiency and insufficient accuracy in wood defect detection and repair are solved, achieving efficient and accurate automated repair results.

CN120411054BActive Publication Date: 2026-03-27KUNMING UNIV OF SCI & TECH
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-29
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

Existing wood defect detection and repair technologies rely on manual operation, which is inefficient and susceptible to human factors. Furthermore, existing machine vision technologies lack robustness and adaptability in wood defect detection, making it difficult to meet high-precision requirements and resulting in unsatisfactory automated repair effects.

Method used

An improved YOLOv8 model was adopted. By replacing the original modules with MASFAConv and C2f_DSCA modules in the backbone network and adding a P2 detection head to the detection head, combined with depthwise separable convolution and lightweight attention modules, weighted fusion and multi-scale detection of defect bounding boxes were performed to achieve high-precision detection of wood defects.

Benefits of technology

It improves the accuracy and efficiency of wood defect detection, enhances adaptability to changes in wood surface texture and lighting, supports efficient and precise automated repair, and achieves automation and consistency in wood repair.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120411054B_ABST
    Figure CN120411054B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a wood repairing method, device and medium, and belongs to the technical field of wood repairing. The method comprises: acquiring a real-time image of wood; inputting the real-time image of wood into a wood defect detection large model to obtain a defect bounding box and a defect type, wherein the wood defect detection large model is based on an improved YOLOv8 model; replacing a Conv module in a backbone network of an initial YOLOv8 model with a MASFAConv module, replacing a C2f module in a neck network with a C2f_DSCA module, and adding a P2 detection head in a detection head to obtain an improved YOLOv8 model; performing weighted average processing on the defect bounding box by using a weighted box fusion and a multi-scale detection fusion strategy to obtain a target defect bounding box, and generating position information of the target defect bounding box; and controlling a repairing device to repair the wood according to the position information of the target defect bounding box and the defect type. The present disclosure can accurately position wood defects and effectively improve the quality of wood repairing.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure belongs to the technical field of wood repair, and particularly relates to a wood repair method, device and medium. BACKGROUND

[0002] Wood, as a common building and industrial material, its surface defects (such as cracks, dead knots, live knots, etc.) will seriously affect the quality and service life of the product. The traditional wood defect detection method mainly relies on manual visual inspection and simple machine vision technology. However, manual detection is not only inefficient, but also easily affected by human factors, leading to missed or misjudgment. Current wood defect repair usually relies on manual operation or semi-automatic repair technology, and mostly uses putty and other repair materials.

[0003] The traditional repair method relies on manual operation to judge the specific situation of the defect, and manually selects putty for repair, which is not only inefficient, but also easy to produce uneven repair effect, and cannot guarantee the consistency of repair quality. In addition, the existing repair technology cannot realize large-scale automatic application in high-efficiency production environment, and there are many challenges in the repair process.

[0004] Currently, wood defect detection technology has gradually introduced computer vision and image processing methods. Many traditional methods rely on edge detection, morphological processing and other technologies, which lack sufficient robustness and adaptability to wood surface texture, illumination changes and complexity of defects, resulting in unstable detection results, and it is difficult to meet the high-precision requirements to realize full coverage of the repair path.

[0005] In recent years, deep learning, especially the YOLO series algorithm, has been applied to wood defect detection. Although the YOLO algorithm performs well in real-time detection and accuracy, most existing YOLO models are mainly for general object detection tasks, and lack specific optimization for wood defects, so the application in wood defect detection still faces challenges.

[0006] In order to improve the efficiency and quality of wood repair, automated repair technology has gradually become a research hotspot. Some existing automatic repair systems try to realize the automation of the repair process through robot technology, although it has been applied in some simple repair tasks, but most systems still lack accurate defect detection and positioning ability, resulting in unsatisfactory repair effect. SUMMARY

[0007] The present disclosure proposes a wood repair method, device and medium to solve the above technical problems.

[0008] According to a first aspect of the present disclosure, a wood repairing method is provided, the method comprising: acquiring a wood real-time image; inputting the wood real-time image into a wood defect detection large model to obtain a defect bounding box and a defect type, wherein the wood defect detection large model is based on an improved YOLOv8 model; replacing a Conv module in a backbone network of an initial YOLOv8 model with a MASFAConv module, replacing a C2f module in a neck network with a C2f_DSCA module, and adding a P2 detection head in a detection head to obtain an improved YOLOv8 model; performing weighted averaging processing on the defect bounding box by using a weighted box fusion and a multi-scale detection fusion strategy to obtain a target defect bounding box, and generating target defect bounding box position information; and controlling a repairing device to repair the wood according to the target defect bounding box position information and the defect type.

[0009] In some embodiments, the processing of the wood real-time image by the wood defect detection large model comprises: expanding the wood real-time image by using a depth separable convolution to obtain two initial branch features; processing the initial features in the branches by using a sub-module composed of a plurality of bottleneck structure modules of the depth separable convolution in series, each module internally using two layers of depth separable convolution, including a depth separable convolution for feature compression and a depth separable convolution for feature expansion, and when the number of input channels is the same as the number of output channels, using a residual connection, after multiple series processing, forming a plurality of local branch features; concatenating the two initial branch features and the plurality of local branch features in the channel dimension; performing adaptive reweighting on the concatenated features by using a lightweight attention module based on convolution, which uses two layers of convolution, the first layer of convolution being reduced in dimension and activated by SiLU, and the second layer of convolution being increased in dimension and activated by a Sigmoid activation function to obtain channel attention weights, and finally multiplying the weights with the original concatenated features channel by channel; and mapping the features weighted by the adaptive weights to the target output channel by using a layer of depth separable convolution.

[0010] In some embodiments, before the wood real-time image is expanded by using the depth separable convolution, the method further comprises: performing global average pooling and maximum pooling on the wood real-time image by using channel attention, and generating a channel mask through convolution layer mapping; performing global average pooling and maximum pooling on the wood real-time image by using spatial attention, and generating a spatial mask through convolution mapping; fusing the channel mask and the spatial mask by using a weighting coefficient to obtain an initially reweighted output; inputting the initially reweighted output again into the channel attention and the spatial attention to obtain new channel masks and spatial masks; and fusing the new channel masks and the spatial masks by using a weighting coefficient to obtain a finally reweighted output.

[0011] In some embodiments, the defect types include cracks and knots.

[0012] According to a second aspect of the present disclosure, a wood repairing device is provided, comprising: a wood real-time image acquisition module configured to acquire a wood real-time image; a wood defect identification module configured to input the wood real-time image into a wood defect detection large model to obtain a defect bounding box and a defect type, wherein the wood defect detection large model is based on an improved YOLOv8 model; the Conv module in the backbone network of the initial YOLOv8 model is replaced by the MASFAConv module, the C2f module in the neck network is replaced by the C2f_DSCA module, and the P2 detection head is added in the detection head to obtain the improved YOLOv8 model; a target defect bounding box position information generation module configured to perform weighted average processing on the defect bounding box by using a weighted box fusion and a multi-scale detection fusion strategy to obtain a target defect bounding box and generate target defect bounding box position information; and a wood repairing control module configured to control the wood repairing device to repair the wood according to the target defect bounding box position information and the defect type.

[0013] According to a third aspect of the present disclosure, a wood repairing device is provided, comprising: a memory; and a processor coupled to the memory, the processor being configured to execute a wood repairing method as described above based on instructions stored in the memory.

[0014] According to a fourth aspect of the present disclosure, a computer readable storage medium is provided, having computer program instructions stored thereon, the instructions being executed by a processor to implement a wood repairing method as described above.

[0015] By adopting the technical solution, the embodiment of the present disclosure can achieve the beneficial technical effects: the present disclosure is based on the YOLOv8 model framework, and targeted improvements are made in the model backbone, neck network and detection head design, fully considering the actual situation of complex wood surface texture and various defect sizes. In the backbone network, a new MASFConv module is used to replace the original Conv module. In the neck network, part of the original C2f module is replaced by the improved C2f_DSCA module. The improved C2f_DSCA module retains the advantages of multi-branch feature fusion while adopting the design of depth separable convolution (DSC), and all the original 1x1 convolution is replaced by 3x3 convolution to improve the receptive field, thereby expanding the receptive field and enhancing the ability to capture local spatial information. To further improve the sensitivity of the model to local defects (such as elongated cracks and insect eyes), a lightweight attention module based on convolution is introduced inside the C2f_DSCA module. This module uses two layers of 3x3 convolution, SiLU activation function and Sigmoid activation function to generate channel adaptive attention weights, and reweights the features after multi-branch concatenation, thereby highlighting the defect region features. To make up for the shortcomings of the traditional YOLOv8 model in small target detection, the present scheme adds a P2 detection head in the detection head. The P2 detection head is mainly responsible for capturing low-level fine-grained feature information, and improves the detection accuracy of small defects on the wood surface by fusing the P2 layer output with other high-level features.

[0016] Depth separable convolution is a 3x3 convolution kernel that performs depth convolution and point-by-point convolution. Compared with traditional convolution, DSC significantly reduces the number of parameters and computational complexity while maintaining strong feature extraction capability, effectively capturing local texture information in wood cracks and insect eyes. And use depth separable convolution to build a bottleneck structure, realize feature compression and recovery through two layers of 3x3 depth separable convolution, and use residual connection when the input and output channels are the same. This module is repeatedly stacked in a multi-branch structure, which can deeply mine local details and help enhance the feature representation of small defects. Finally, through two layers of 3x3 convolution, the SiLU activation function and the Sigmoid activation function are activated in the middle, realizing channel adaptive reweighting. This allows the concatenated multi-branch features to be reweighted, highlighting key defect information and suppressing irrelevant background noise. In the post-processing stage, the present disclosure combines the weighted frame fusion (WBF) algorithm to weight and fuse the detection frames output by each layer of network, reducing duplicate frames and improving detection accuracy. At the same time, it supports multi-scale input to infer the same image and finally fuse the results to adapt to the complex wood surface patterns and large changes in lighting in production scenarios. In terms of automated repair, the present disclosure combines the Modbus TCP protocol with the YOLOv8 defect detection path coordinates and the PLC control repair system to realize efficient and accurate defect data transmission and repair instruction issuance. Attached Figure Description

[0017] The accompanying drawings, which form part of this specification, illustrate embodiments of this disclosure and, together with the specification, serve to explain the principles of this disclosure.

[0018] This disclosure can be more clearly understood with reference to the accompanying drawings and the following detailed description.

[0019] Figure 1 This is one of the flowcharts illustrating a wood repair method according to some embodiments of the present disclosure.

[0020] Figure 2 This is a second flowchart illustrating a wood repair method according to some embodiments of the present disclosure.

[0021] Figure 3 This is a diagram illustrating the overall architecture of a YOLOv8 model according to some embodiments of the present disclosure.

[0022] Figure 4 This is an overall architecture diagram of the C2f_DSCA module according to some embodiments of the present disclosure.

[0023] Figure 5 This is a schematic diagram illustrating residual connections according to some embodiments of the present disclosure.

[0024] Figure 6 This is an architectural diagram illustrating MSWFAConv according to some embodiments of the present disclosure.

[0025] Figure 7 This is an architectural diagram illustrating the MSWFA according to some embodiments of the present disclosure.

[0026] Figure 8 This is a block diagram illustrating a wood repair apparatus according to some embodiments of the present disclosure.

[0027] Figure 9 This is a block diagram illustrating a wood repair apparatus according to other embodiments of the present disclosure.

[0028] Figure 10 This is a block diagram illustrating a computer system for implementing some embodiments of the present disclosure. Detailed Implementation

[0029] Various exemplary embodiments of the present disclosure will now be described in detail with reference to the accompanying drawings. It should be noted that, unless otherwise specifically stated, the relative arrangement, numerical expressions, and values ​​of the components and steps set forth in these embodiments do not limit the scope of the present disclosure.

[0030] It should be understood that the dimensions of the various elements shown in the figures are chosen primarily to facilitate recognition of the various elements and it should be appreciated that the dimensions of the various elements may be disproportionately represented for the sake of clarity.

[0031] Techniques, methods, and apparatus known to those of ordinary skill in the relevant art can not be discussed in any detail in order to avoid obscuring the present disclosure.

[0032] In all of the compositions and methods shown and discussed herein, any specific values should be interpreted as merely exemplary, and not as a limitation of the compositions and methods. Thus, other examples of the exemplary compositions and methods can have different values.

[0033] It should be noted that like reference numerals and letters refer to like items throughout the attached drawings, and thus, once an item is defined in one drawing, it is not necessary that it be further discussed in the remaining drawings.

[0034] Figure 1 is one of the flowcharts showing a wood repairing method according to some embodiments of the present disclosure. As shown in Figure 1 the wood repairing method includes steps S110 to S140.

[0035] In step S110, a wood real-time image is acquired.

[0036] In step S120, the wood real-time image is input into a wood defect detection large model to obtain a defect bounding box and a defect type, wherein the wood defect detection large model is based on an improved YOLOv8 model; a Conv module in a backbone network of an initial YOLOv8 model is replaced with a MASFAConv module, a C2f module in a neck network is replaced with a C2f_DSCA module, and a P2 detection head is added in a detection head to obtain the improved YOLOv8 model. Channel attention is used to perform global average pooling and maximum pooling on the wood real-time image, and a channel mask is generated through convolution layer mapping;

[0037] The processing of the wood real-time image by the wood defect detection large model includes: using spatial attention to perform global average pooling and maximum pooling on the wood real-time image, and generating a spatial mask through convolution mapping; and through a weighting coefficient fusing the channel mask and the spatial mask to obtain a first re-weighted output; inputting the first re-weighted output again into the channel attention and the spatial attention to obtain a new channel mask and a new spatial mask; and through a weighting coefficient The new channel mask and the spatial mask are fused to obtain a final reweighted output; a depth separable convolution is used to expand the real-time image of the wood to obtain two initial branch features; a sub-module composed of a plurality of bottleneck structure modules of the depth separable convolution is used to process the initial features in the branch, two layers of the depth separable convolution are used in each module, including the depth separable convolution for feature compression and the depth separable convolution for feature expansion, when the number of input channels is the same as the number of output channels, a residual connection is used, after a plurality of serial processing, a plurality of local branch features are formed; the two initial branch features and the plurality of local branch features are spliced in the channel dimension; a lightweight attention module based on convolution is used to adaptively reweight the spliced features, the module uses two layers of convolution, the first layer of convolution is reduced in dimension and activated by SiLU, the second layer of convolution is increased in dimension and activated by a Sigmoid activation function to obtain channel attention weights, and finally the weights are multiplied with the original spliced features in each channel; the features weighted by the adaptive weights are mapped to the target output channel through a layer of depth separable convolution.

[0038] The present disclosure is based on the YOLOv8 model framework, and specific improvements and designs are made on the model backbone, neck network and detection head, fully considering the actual situation of complex wood surface texture and various defect sizes.

[0039] As shown in Figure 3 , in the backbone network, a new MASFConv module is used to replace the original Conv module. In the neck network, part of the original C2f module is replaced by the improved C2f_DSCA module. As shown in Figure 4 , the improved C2f_DSCA module retains the advantages of multi-branch feature fusion, uses a depth separable convolution (DSC) design, and changes all original 1x1 convolutions to 3x3 convolutions to improve the receptive field, thereby expanding the receptive field and enhancing the ability to capture local spatial information. To further improve the sensitivity of the model to local defects (such as long cracks and insect eyes), a lightweight attention module based on convolution is introduced into the C2f_DSCA module. The module uses two layers of 3x3 convolution, uses SiLU activation function and Sigmoid activation function to generate channel adaptive attention weights, and reweights the features after multi-branch splicing, thereby highlighting the defect area features.

[0040] To make up for the shortcomings of the traditional YOLOv8 model in small target detection, the P2 detection head is added in the detection head. The P2 detection head is mainly responsible for capturing low-level fine-grained feature information, and improves the detection accuracy of small defects on the wood surface by fusing the P2 layer output with other high-level features.

[0041] The depth separable convolution is used to perform depth convolution and point-by-point convolution with a 3x3 convolution kernel. Compared with the traditional convolution, the DSC significantly reduces the number of parameters and the computational complexity, while maintaining strong feature extraction capability, effectively capturing local texture information in wood cracks and bug eyes. And a bottleneck structure is constructed by using the depth separable convolution, feature compression and recovery are realized by two layers of 3x3 depth separable convolution, and residual connection is used when the input and output channels are the same, as shown in Figure 5 This module is repeatedly stacked in a multi-branch structure, which can deeply mine local details and help to enhance the feature representation of micro defects. Finally, through two layers of 3x3 convolution, the intermediate is activated by SiLU activation function and Sigmoid activation function, realizing channel adaptive reweighting. This makes it possible to reweight the multi-branch features after splicing, highlight key defect information, and suppress irrelevant background noise.

[0042] In step S130, the weighted frame fusion and multi-scale detection fusion strategy are used to perform weighted average processing on the defect boundary frame to obtain the target defect boundary frame, and the position information of the target defect boundary frame is generated.

[0043] The present disclosure combines the weighted frame fusion WBF algorithm to make weighted fusion for the detection frame output by each layer of network, reduces the repeated frame, and improves the detection accuracy; at the same time, supports multi-scale input (such as 640, 960, 1280, etc.) to infer the same image, and finally fuses the result to adapt to the production scene of complex wood surface patterns and large changes in illumination.

[0044] In step S140, the target defect boundary frame position information and the defect type are used to control the repair device to repair the wood.

[0045] In the aspect of automatic repair, the present disclosure combines the Modbus TCP protocol with the YOLOv8 defect detection path coordinates and the PLC control repair system to realize efficient and accurate defect data transmission and repair instruction issuance.

[0046] As Figure 2As shown, the system connects the PLC through the Modbus TCP protocol through the IP address. After the program starts, a separate thread will read the PLC coil 0 state through Modbus communication at regular intervals. When the read coil address changes from 0 to 1, the program will set the Boolean value of the photo trigger to True, indicating that a photo detection process is needed. The current frame image will be obtained from the Hikvision industrial camera, and after the acquisition is completed, the Boolean value of the photo trigger will be reset to False. While obtaining the current frame image, the position of the PLC in the assembly line is read, and then the detection thread is started to perform defect detection processing on the obtained current frame image. Inside the detection thread, the YOLO model is used to detect the obtained image, and the defect bounding box coordinates and category information are obtained. For each detected defect, the camera pixel to actual field physical coordinate conversion is performed according to the defect four corner point coordinates. Then, according to the actual physical coordinates of the defect, a trajectory planning algorithm is used to ensure that the glue output and coverage range are optimal each time the valve is opened, effectively covering the defect area within a limited time, significantly enhancing the repair effect and production efficiency.

[0047] The wood defect position coordinates and other information detected by the YOLOv8 model are transmitted in real time to the PLC in the form of standardized 16-bit integers, thereby controlling the PLC to perform the repair task. The specific glue repair interval can be set by changing the step size. After all the coordinates are transmitted, the assembly line position is sent to the PLC at a specific address for reading. After all the data is sent, a completion signal is sent to a specific completion signal address to realize a closed loop of the entire process. At the same time, the system has a friendly human-computer interaction interface, providing real-time detection result display and system state monitoring. In view of possible abnormal situations such as communication failure and camera error, the system designs a perfect abnormal handling mechanism to ensure the stable operation of the system.

[0048] For the wood defect detection scene, the overall architecture of the YOLOv8 model is improved and optimized. First, a large number of wood surface defect images are collected in the industrial field, and the defects in them are labeled using a labeling tool. The defect types are divided into two categories: cracks and knots. Through data enhancement methods such as rotation, cropping, and brightness adjustment, the data set is expanded to improve the generalization ability of the model. Then, using the hyperparameter optimization tool Optuna, the optimal learning rate, batch size, and training round are automatically searched to obtain the best YOLOv8 model. On this basis, in view of the problem of complex wood surface texture and small defect targets difficult to detect, the network structure of YOLOv8 is improved in multiple places. First, replace Conv with MASFConv in the backbone network to further improve the ability to capture details and the accuracy of defect positioning in the process of wood defect recognition. The designed C2f_DSCA module is used to replace part of the C2f module in the original model neck network to enhance the feature extraction ability of small defects. The designed C2f_DSCA module is a structure that combines depth separable convolution and convolution attention mechanism, balancing lightweight and feature expression ability. It reweights through multi-branch feature fusion and channel attention, making the model more sensitive to small targets and richer in feature expression without significantly increasing the parameter amount, thus effectively improving the model's response ability to small defects in complex backgrounds. At the same time, a lightweight attention mechanism is introduced to further emphasize the defect region features. While fusing multi-scale information, this attention module only brings very small computational overhead, but significantly improves the feature expression ability, enabling the model to focus more on the wood defect area and less on the background noise. Finally, a P2 branch is added, making a total of four detection branches, which can better cover various scales from small targets to large targets.

[0049] In some embodiments, mainly for the C2f module in the YOLOv8 model backbone, a newly designed C2f_DSCA module is proposed. This module uses full-process 3x3 (convolution kernel height and width 3 rows by 3 columns) depth separable convolution (DSC), and independently designs a lightweight attention mechanism based on convolution (ConvAtt) to enhance the feature capture ability of small target defects such as wood surface cracks and insect eyes, while reducing model parameter amount and computational complexity.

[0050] First step, feature expansion and branch initialization: in the left branch of the module, first use a layer of 3x3 depth separable convolution (DSC) to expand the input features. The module consists of two parts, the first part is depth convolution, that is, a 3x3 convolution is performed on each input channel to extract local spatial information; then another layer of 3x3 convolution is used, that is, the original point-by-point convolution is replaced by 3x3 convolution to realize channel transformation.

[0051] This step maps the input features to twice the number of hidden channels, and then splits them equally along the channel dimension to obtain two initial feature branches, laying the foundation for subsequent multi-branch fusion.

[0052] Second step, local feature extraction and residual fusion: In the right branch, a sub-module composed of a series of bottleneck structure modules with n depth separable convolutions is used to further process part of the features in the branch. Each module internally uses two layers of 3x3 depth separable convolution, where the first layer of depth separable convolution realizes feature compression, and the second layer of depth separable convolution realizes feature expansion. When the number of input and output channels is the same, a residual connection is used inside the module to add the input directly to the output, alleviating the problem of information loss. After n times of series processing, multiple local feature branches are formed, which can deeply mine the fine texture information of the wood defect area. n can be modified and adapted according to the computer performance and computational demand.

[0053] Third step, multi-branch feature concatenation and convolution attention fusion: The two initial features divided in the first step and the branch features obtained by processing the depth separable convolution bottleneck structure module in the second step are concatenated in the channel dimension. The total number of channels of the concatenated features is (2+n) times the number of hidden channels. In order to further strengthen the important information of the defect area, a designed lightweight attention module based on convolution is used to adaptively reweight the concatenated features. This module uses two layers of 3x3 convolution, the first layer of convolution is reduced in dimension and activated by SiLU, the second layer of convolution is increased in dimension and activated by the Sigmoid activation function to obtain the channel attention weight, and finally the weight is multiplied with the original concatenated feature channel by channel to realize dynamic adjustment of information.

[0054] Fourth step, output mapping and feature integration: In the right branch, the features reweighted by the lightweight attention module based on convolution are mapped to the target output channel through a layer of 3x3 depth separable convolution. This layer not only adjusts the number of channels, but also further integrates the feature information of each branch to ensure that the output feature map contains not only rich local detail information, but also high discrimination ability. The output features of this module will be used as the input of the subsequent detection head for the final prediction of the defect frame.

[0055] In some embodiments, as Figure 6 and Figure 7As shown, in order to further improve the detail capture ability and the accuracy of defect positioning in the wood board defect recognition process, a multi-stage attention is added on the basis of the conventional convolutional neural network, and a weighted fusion method is used to balance the contributions of channel attention and spatial attention. Through continuous iteration and optimization, in the wood board defect recognition, especially for the subtle features such as knots (live knot and dead knot), the detection effect is significantly improved. A module named MASFAConv (Multi Stage Attention Fusion Attention Convolution) is designed to replace the Conv module in the backbone.

[0056] The advantage is to avoid introducing too many parameters and operation amount, to ensure smooth operation on a conventional hardware platform, and to retain the lightweight feature. The channel level information aggregation and spatial level attention mechanism are combined, and multiple iterations are performed to avoid information omission. Through the settable weight coefficients α and β, the influence proportion of the two-stage attention on feature extraction is flexibly adjusted.

[0057] First step, multi-stage attention and weighted fusion: before entering the multi-branch feature splicing and global attention reweighting, the embodiment first processes the features through two steps, i.e., multi-stage attention branch initialization and layer-by-layer attention enhancement and weighted fusion.

[0058] First stage: in the forward propagation function of the model, the input features are first extracted to perform channel attention and spatial attention. Channel attention obtains statistics by performing global average pooling and maximum pooling on the input features, and then generates a channel mask through a fully connected or convolutional layer; spatial attention obtains a spatial mask by taking the maximum and average of the feature map in the channel dimension and then performing convolution. Then, through the defined weighting coefficients fuse between channel and spatial attention to obtain the output of the first reweighting At this time, the network can preliminarily highlight the channel and spatial position information corresponding to the potential defect area.

[0059] Second stage: the output of the first step is input again to the channel attention and spatial attention module, and similarly, new attention weights are extracted; through the defined weighting coefficients further balance between channel and spatial attention results, and element-by-element multiplication to form a new output This process, to some extent, enhances the network's perception of key textures and regions, making it easier to capture subtle features of nodes and scars. Residual connections will be used in this stage and subsequent branching operations, meaning that the input is directly superimposed on the output when matching the number of channels, thus ensuring smooth information flow between features and mitigating the gradient vanishing or detail loss problems that may occur in deep networks.

[0060] Under the continuous action of the above two stages, the model will continuously stack attention effects from lower to higher levels, and through... and The adjustment enables flexible allocation of channel and spatial information. The output features from the first step are combined with features from other branches for multi-branch concatenation, and then further reweighted through the global attention module to obtain better defect detection performance.

[0061] The second step, multi-branch feature convergence: After multiple stages of attention enhancement and weighting in the first step, multiple feature branches with different representation capabilities are formed. All branch outputs are stacked according to the channel dimension. Let the initial number of branches be... The number of channels output by each branch is 1. Then the total number of channels in the concatenated feature map is In terms of spatial dimensions The concatenation operation maintains consistency with the original branch. This concatenation operation effectively integrates information from different perspectives of interest, providing a richer feature base for subsequent global attention.

[0062] The third step, dimensionality reduction convolution and nonlinear mapping: To alleviate the problem of excessively large feature channel numbers and enhance the expression of key features during fusion, a 3×3 convolution operation is used to reduce the dimensionality of the concatenated features with a large number of channels. Let the dimensionality reduction factor be... The number of channels after dimensionality reduction is Meanwhile, the SiLU nonlinear activation function is used to enhance representational power, making the subsequent attention generation process more flexible. This process is equivalent to extracting a more discriminative compressed representation from the high-dimensional concatenated features, thereby reducing computational load and mitigating interference from redundant features.

[0063] The fourth step, dimensionality-upgrading convolution and channel attention inference: After obtaining the intermediate features after dimensionality reduction, another convolutional layer is used to upgrade the dimensionality, restoring the number of channels to their original size, and then a channel attention weight map is generated using the Sigmoid activation function. To balance lightweight design and full representation, Sigmoid activation is chosen to construct the channel mask. Specifically, the size of the convolution output is the same as the concatenated features, and the importance of the current channel is represented by the weight coefficients for each channel. This process is called the channel attention mechanism, which can significantly highlight channel features that contribute to the target defect region and suppress noisy channels.

[0064] Step 5, Global Feature Reweighting and Output: The channel attention weights obtained in Step 4 are multiplied channel-by-channel with the concatenated features, achieving a global redistribution of the fused feature map. This multiplication operation can be seen as adaptively amplifying or weakening different channels, allowing the network to focus on identifying and locating key patterns in defect regions. Simultaneously, to ensure the final output closely connects to subsequent tasks, an additional 3×3 convolution is inserted after this process to perform a matching mapping of the number of channels. The mapping is then performed back to the channel dimension required by the backbone network or detection head. At this point, the multi-branch features, after global attention reweighting, can form a unified, more discriminative high-dimensional representation for subsequent detection or classification of defective targets.

[0065] Figure 8 This is a block diagram illustrating a wood repair apparatus according to some embodiments of the present disclosure.

[0066] like Figure 8 As shown, the wood repair device 800 includes a real-time wood image acquisition module 810, a wood defect recognition module 820, a target defect bounding box location information generation module 830, and a wood repair control module 840.

[0067] The real-time wood image acquisition module 810 is configured to acquire real-time wood images;

[0068] The wood defect recognition module 820 is configured to input real-time wood images into a large-scale wood defect detection model to obtain defect bounding boxes and defect types. The large-scale wood defect detection model is based on an improved YOLOv8 model. The Conv module in the backbone network of the initial YOLOv8 model is replaced with a MASFAConv module, the C2f module in the neck network is replaced with a C2f_DSCA module, and a P2 detection head is added to the detection head to obtain the improved YOLOv8 model.

[0069] The target defect bounding box location information generation module 830 is configured to perform weighted averaging on the defect bounding box using a weighted box fusion and multi-scale detection fusion strategy to obtain the target defect bounding box and generate the target defect bounding box location information at the same time.

[0070] The timber repair control module 840 is configured to control the repair device to repair the timber based on the target defect bounding box location information and the defect type.

[0071] Figure 9 This is a block diagram illustrating a wood repair apparatus according to other embodiments of the present disclosure. Figure 9As shown, the timber repair apparatus 900 includes a memory 910 and a processor 920 coupled to the memory 910. The memory 910 is used to store instructions for performing embodiments of the timber repair method. The processor 920 is configured to perform timber repair methods in any of the embodiments of this disclosure based on the instructions stored in the memory 910.

[0072] Figure 10 This is a block diagram illustrating a computer system for implementing some embodiments of the present disclosure.

[0073] like Figure 10 As shown, the computer system 1000 can be represented in the form of a general computing device. The computer system 1000 includes a memory 1010, a processor 1020, and a bus 1030 connecting different system components.

[0074] The memory 1010 may include, for example, system memory, non-volatile storage media, etc. The system memory may store, for example, an operating system, application programs, a boot loader, and other programs. The system memory may include volatile storage media, such as random access memory (RAM) and / or cache memory. The non-volatile storage media may store, for example, instructions for executing corresponding embodiments of at least one of the wood repair methods. Non-volatile storage media include, but are not limited to, disk storage, optical storage, flash memory, etc.

[0075] The processor 1020 can be implemented using a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates, or transistors, or other discrete hardware components. Correspondingly, each module, such as the real-time wood image acquisition module, the wood defect recognition module, the target defect bounding box location information generation module, and the wood repair control module, can be implemented by executing instructions from the central processing unit (CPU)'s runtime memory to perform the corresponding steps, or by implementing dedicated circuitry for executing the corresponding steps.

[0076] Bus 1030 can use any of the various bus architectures. For example, bus architectures include, but are not limited to, Industry Standard Architecture (ISA) bus, Micro Channel Architecture (MCA) bus, and Peripheral Component Interconnect (PCI) bus.

[0077] The computer system 1000 may also include an input / output interface 1040, a network interface 1050, a storage interface 1060, etc.

[0078] These interfaces 1040, 1050, and 1060, as well as the memory 1010 and processor 1020, can be connected via bus 1030. Input / output interface 1040 provides a connection interface for input / output devices such as monitors, mice, and keyboards. Network interface 1050 provides a connection interface for various networked devices. Storage interface 1060 provides a connection interface for external storage devices such as floppy disks, USB flash drives, and SD cards.

[0079] Various aspects of this disclosure are described herein with reference to flowchart illustrations and / or block diagrams of methods, apparatus, and computer program products according to embodiments of this disclosure. It should be understood that each block of the flowchart illustrations and / or block diagrams, and combinations thereof, can be implemented by computer-readable program instructions.

[0080] These computer-readable program instructions are provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable device to produce a machine, such that execution of the instructions by the processor produces means for implementing the functions specified in one or more boxes of the flowchart and / or block diagram.

[0081] These computer-readable program instructions may also be stored in a computer-readable storage medium. These instructions cause a computer to work in a particular manner to produce an article of manufacture, including instructions that implement the functions specified in one or more boxes in a flowchart and / or block diagram.

[0082] This disclosure may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects.

[0083] The wood repair method, apparatus, and medium according to this disclosure have now been described in detail. To avoid obscuring the concept of this disclosure, some details known in the art have not been described. Those skilled in the art will fully understand how to implement the technical solutions disclosed herein based on the above description.

[0084] While specific embodiments of this disclosure have been described in detail by way of example, those skilled in the art should understand that the examples are for illustrative purposes only and not intended to limit the scope of this disclosure. Those skilled in the art should understand that modifications can be made to the above embodiments without departing from the scope and spirit of this disclosure. The scope of this disclosure is defined by the appended claims.

Claims

1. A method for repairing wood, characterized in that, The method includes: Acquire real-time images of the timber; Real-time images of wood are input into a large-scale wood defect detection model to obtain defect bounding boxes and defect types. The large-scale wood defect detection model is based on an improved YOLOv8 model. The Conv module in the backbone network of the initial YOLOv8 model is replaced with a MASFAConv module, the C2f module in the neck network is replaced with a C2f_DSCA module, and a P2 detection head is added to the detection head to obtain the improved YOLOv8 model. The MASFAConv module incorporates multi-stage attention and uses a weighted fusion method to balance channel attention and spatial attention. The C2f_DSCA module introduces a lightweight attention module based on convolution. We employ a weighted average method for the defect bounding box using weighted box fusion and multi-scale detection fusion to obtain the target defect bounding box and simultaneously generate the target defect bounding box location information. The repair device is controlled to repair the wood based on the location information of the target defect boundary box and the defect type; The large-scale wood defect detection model processes real-time wood images, including: The real-time image of wood is expanded using depthwise separable convolution to obtain two initial branch features; The initial features in the branches are processed by a sub-module consisting of multiple bottleneck structure modules with depthwise separable convolutions connected in series. Each module uses two layers of depthwise separable convolutions, including depthwise separable convolutions for feature compression and depthwise separable convolutions for feature expansion. When the number of input channels is the same as the number of output channels, residual connection is used. After multiple series processing, multiple local branch features are formed. The two initial branch features and multiple local branch features are concatenated along the channel dimension; A lightweight attention module based on convolution is used to adaptively reweight the concatenated features. This module uses two convolutional layers. The first convolutional layer reduces the dimensionality and is activated by SiLU. The second convolutional layer increases the dimensionality and is activated by the Sigmoid activation function to obtain the channel attention weights. Finally, the weights are multiplied with the original concatenated features channel by channel. The adaptively weighted features are mapped to the target output channel through a depthwise separable convolution layer. Simultaneously, prior to the expansion of the real-time wood image using depth-separable convolution, the method further includes: Channel attention is used to perform global average pooling and max pooling on real-time wood images, and channel masks are generated by mapping through convolutional layers. Spatial attention is used to perform global average pooling and max pooling on real-time wood images, and a spatial mask is generated by convolution mapping. Through weighting coefficients By fusing the channel mask and the spatial mask, the first reweighted output is obtained; The output of the initial reweighting is then input back into the channel attention and spatial attention to obtain new channel masks and spatial masks; Through weighting coefficients By combining the new channel mask and spatial mask, the final reweighted output is obtained.

2. The wood repair method according to claim 1, characterized in that, The defect types include cracks and knots.

3. A wood repair device, characterized in that, include: The real-time wood image acquisition module is used to acquire real-time images of wood. A wood defect recognition module is used to input real-time wood images into a large-scale wood defect detection model to obtain defect bounding boxes and defect types. The large-scale wood defect detection model is based on an improved YOLOv8 model. The Conv module in the backbone network of the initial YOLOv8 model is replaced with a MASFAConv module, the C2f module in the neck network is replaced with a C2f_DSCA module, and a P2 detection head is added to the detection head to obtain the improved YOLOv8 model. The MASFAConv module incorporates multi-stage attention and uses a weighted fusion method to balance channel attention and spatial attention. The C2f_DSCA module introduces a lightweight attention module based on convolution. The target defect bounding box location information generation module is used to perform weighted averaging on the defect bounding box using weighted box fusion and multi-scale detection fusion strategies to obtain the target defect bounding box, and at the same time generate the target defect bounding box location information. The timber repair control module is used to control the repair device to repair the timber based on the target defect boundary box location information and defect type. The large-scale wood defect detection model processes real-time wood images, including: The real-time image of wood is expanded using depthwise separable convolution to obtain two initial branch features; The initial features in the branches are processed by a sub-module consisting of multiple bottleneck structure modules with depthwise separable convolutions connected in series. Each module uses two layers of depthwise separable convolutions, including depthwise separable convolutions for feature compression and depthwise separable convolutions for feature expansion. When the number of input channels is the same as the number of output channels, residual connection is used. After multiple series processing, multiple local branch features are formed. The two initial branch features and multiple local branch features are concatenated along the channel dimension; A lightweight attention module based on convolution is used to adaptively reweight the concatenated features. This module uses two convolutional layers. The first convolutional layer reduces the dimensionality and is activated by SiLU. The second convolutional layer increases the dimensionality and is activated by the Sigmoid activation function to obtain the channel attention weights. Finally, the weights are multiplied with the original concatenated features channel by channel. The adaptively weighted features are mapped to the target output channel through a depthwise separable convolution layer. Simultaneously, prior to the expansion of the real-time wood image using depth-separable convolution, the method further includes: Channel attention is used to perform global average pooling and max pooling on real-time wood images, and channel masks are generated by mapping through convolutional layers. Spatial attention is used to perform global average pooling and max pooling on real-time wood images, and a spatial mask is generated by convolution mapping. Through weighting coefficients By fusing the channel mask and the spatial mask, the first reweighted output is obtained; The output of the initial reweighting is then input back into the channel attention and spatial attention to obtain new channel masks and spatial masks; Through weighting coefficients By combining the new channel mask and spatial mask, the final reweighted output is obtained.

4. A wood repair device, characterized in that, include: Memory; as well as A processor coupled to the memory, the processor being configured to execute the wood repair method as described in any one of claims 1 to 2 based on instructions stored in the memory.

5. A computer-readable storage medium, characterized in that, It stores computer program instructions that, when executed by a processor, implement the wood repair method as described in any one of claims 1 to 2.

Citation Information

Patent Citations

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

    CN119478523A