Solid wood plate foreground and background characteristic classification method based on double-branch network
By using a foreground and background characteristic classification method based on a dual-branch network, the problems of low efficiency and insufficient classification accuracy of manual visual inspection in solid wood flooring production are solved, and efficient and accurate foreground and background characteristic classification of solid wood boards is achieved.
Patent Information
- Application Number
- CN202512029855.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-30
- Publication Date
- 2026-04-21
AI Technical Summary
In the production of solid wood flooring, existing technologies rely on manual visual inspection, which is inefficient and inconsistent in standards. General convolutional neural network models are unable to simultaneously optimize the visual characteristics of white edges and wood grain, resulting in low classification accuracy and severe imbalance of extreme samples, leading to a high rate of missed detections.
A foreground-background feature classification method for solid wood panels based on a dual-branch network is adopted. By introducing a task-specific dual-branch architecture, SCConv feature extraction and ECA attention mechanism, combined with the Focal Loss loss function, the decoupled learning of foreground and background features and the optimization of classification tasks are achieved.
It significantly improves classification accuracy and robustness. By optimizing task priority through collaborative combination strategies and priority decision-making, it enhances the model's efficiency and generalization ability in background classification, while reducing learning difficulty and false negative rate.
Smart Images

Figure CN121904450A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image classification and deep learning technology, specifically relating to a method for classifying foreground and background characteristics of solid wood panels based on a dual-branch network. Background Technology
[0003] In the production of solid wood flooring, accurately classifying the white edges, color differences, colors, and natural grain of raw materials is a crucial step in determining product quality and value. Currently, this step mainly relies on manual visual inspection, which suffers from low efficiency and inconsistent standards. Although deep learning technology offers the possibility of automation, general convolutional neural network models still face significant challenges in handling this specific task. First, the visual characteristics of white edges or colors (as background) differ greatly from those of wood grain (as foreground features). A single model struggles to optimize the learning of both features simultaneously, leading to feature conflicts and task interference, limiting overall classification accuracy. Furthermore, wood grain features require models with a stronger ability to capture subtle variations, which general network structures are insufficiently suited for. More importantly, the extreme sample imbalance in the production line, where solid wood boards requiring texture classification (foreground) may outnumber those with defects such as white edges or color differences, or solid wood boards requiring color classification (background), easily leads to model training bias towards the majority class, resulting in a high rate of missed defects. Therefore, existing technologies urgently need an innovative solution specifically designed to address these challenges and achieve accurate, efficient, and robust classification. Summary of the Invention
[0004] Purpose of the invention: To address the aforementioned problems in the existing technology, this invention provides a method for classifying the foreground and background characteristics of solid wood panels based on a dual-branch network.
[0005] Technical solution: The present invention provides a method for classifying foreground and background characteristics of solid wood panels based on a dual-branch network, specifically including the following steps:
[0006] S1: Acquire images of solid wood boards, and then scale and standardize the acquired solid wood board images. The height of the scaled image is h pixels and the width is w pixels, where w > h.
[0007] S2: The image processed by S1 is passed through the Stem module of the RepViT model to obtain the initial feature map F1;
[0008] S3: Input feature map F1 into the first N Fused Stage modules (0 < N < 4, N ∈ Z) shared by the foreground and background branches, complete one or more feature transformations and downsampling, and output feature map F2;
[0009] S4: Pass feature map F2 through 3-N Fused Stage modules in the background branch and 3-N Fused Stage modules in the foreground branch to output feature maps F3 and F4 respectively;
[0010] S5: Input feature map F3 into Stage4 module of background branch to obtain deep semantic feature map F5. Process feature map F4 through SCConv to obtain feature map F6.
[0011] S6: Pass feature maps F5 and F6 through an average pooling layer and a fully connected layer respectively to obtain the background branch classification result and the foreground branch classification result.
[0012] Preferably, the background branch in S6 can be classified into color characteristic categories such as white edge, color difference, dark color and light color; the foreground branch can be further classified into texture characteristics such as straight lines, circular lines, curved lines, etc.
[0013] Preferably, the foreground and background characteristic classification method for solid wood panels based on a dual-branch network is characterized in that the loss function during the training of the background branch in S6 is Focal loss, which is calculated using the following formula:
[0014]
[0015] in, This represents the model's predicted probability for the target class. The weights of the samples in the target class. It is the focus factor.
[0016] Preferably, in step S6, SCConv first processes the input feature map X1 through a spatial reconstruction unit (SRU) to suppress redundancy in the spatial dimension, generating spatially refined features X2∈R. C×H×W The generated spatially refined feature X2 is then input into the channel reconstruction unit (CRU) for processing to reduce redundancy in the channel dimension, resulting in the channel refined feature Y1∈R. C×H×W .
[0017] Preferably, the foreground branch Stage4 module consists of a RepViTSEBlock module and a RepViTBlock module connected in sequence; the FFN in the RepViTBlock module is replaced with ECA-FFN, wherein the ECA-FFN has an ECA attention mechanism between the two 1×1 convolutional layers of the original FFN.
[0018] Preferably, the ECA attention mechanism is applicable to the input feature map X3∈R C×H×W First, global average pooling is performed on the input feature map X3 to obtain the channel statistical descriptor z∈R.C×1×1 Next, a one-dimensional convolution with a kernel size of k is used to capture local interactions between channels, and a sigmoid activation function is applied to the output to generate channel attention weights w∈R. C×1×1 Finally, the attention weight w is weighted channel-by-channel with the input feature map X2 to obtain the output feature map Y2∈R. C×H×W ;
[0019] The kernel size k is adaptively determined by the number of channels C:
[0020]
[0021] Where γ and b are hyperparameters, and |·|odd represents taking the nearest odd number.
[0022] Preferably, during the training phase, the model first trains the stem module, the first N shared Fused Stages, and the background branch to obtain the optimal background branch weights. Then, the foreground branch is trained in the second phase. First, the optimal stem layer weights, the first N shared Fused Stages, and the background branch weights are loaded. Then, the loaded weights are frozen, and the foreground branch is trained.
[0023] Preferably, during the inference phase, the background branch and the foreground branch simultaneously output their respective prediction results. A fusion decision is made on the prediction results of the two branches. The fusion decision combines the background category output by the background branch with the foreground sub-category output by the foreground branch to generate the final joint classification result.
[0024] Preferably, during the inference phase, the background branch and the foreground branch simultaneously output their respective prediction results. A priority decision is made for the output results of the two branches. Specifically, if the category output by the background branch belongs to a specific set directly determined by color characteristics, then the output category of the background branch is directly used as the final classification result of the image; if the category output by the background branch does not belong to the aforementioned specific set, then the output is ignored, and the texture subdivision category output by the foreground branch is used as the final classification result of the image; wherein the specific set directly determined by color characteristics includes one or both of white edges and color differences.
[0025] Beneficial effects: Compared with the prior art, the present invention has the following advantages:
[0026] (1) This invention introduces a task-specific dual-branch architecture to achieve decoupled learning of foreground and background features, making the feature extraction process more targeted. Specifically, the combination and arrangement strategy can effectively generate rich composite category representations by synergistically combining a small number of basic categories of foreground and background, which significantly reduces the learning difficulty of the model directly modeling complex patterns. The priority decision strategy clarifies the dependency relationship between foreground and background classification tasks, optimizes task priority through conditional decision-making between branches, and fundamentally improves the accuracy and robustness of the overall classification model.
[0027] (2) This invention uses SCConv instead of Stage for feature extraction, which reduces spatial and channel feature redundancy and optimizes network depth. By lightweighting and enhancing local modeling, the efficiency and generalization ability of the model in background classification are improved, balancing computational efficiency and feature representation.
[0028] (3) This invention integrates the ECA attention mechanism into the texture classification branch, realizing channel-adaptive feature optimization. This innovation addresses the fine-grained requirements of foreground classification by enhancing the model's discriminative ability through the attention mechanism, enabling the model to better capture changes in texture at different scales and in different directions.
[0029] (4) This invention introduces Focal Loss as the loss function for the background branch to solve the model training problem caused by the extreme imbalance between the number of foreground and background samples. Compared with the standard cross-entropy loss function, Focal Loss introduces an adjustable focusing parameter to dynamically reduce the loss contribution of easily classifiable samples during training, thereby focusing the training on samples that are difficult to distinguish. Attached Figure Description
[0030] Figure 1 This is a schematic diagram of the overall structure of the classification method using fusion decision-making in this invention;
[0031] Figure 2 This is a schematic diagram of the overall structure of the priority decision classification method used in this invention;
[0032] Figure 3 This is a schematic diagram of the SCConv module structure of the present invention;
[0033] Figure 4 This is a schematic diagram of the ECA module structure of the present invention;
[0034] Figure 5This is a schematic diagram comparing the confusion matrix of the model of this invention with the confusion matrix of other models when using fusion decision. In the figure, (a) is the ResNet model; (b) is the MobileViT model; (c) is the RepViT model; and (d) is the model of this invention. In each confusion matrix, WE-CT represents white-edged curved-grain solid wood board, LC-CT represents light-colored curved-grain solid wood board, CD-CT represents color difference curved-grain solid wood board, DC-CT represents dark-colored curved-grain solid wood board, WE-ST represents white-edged straight-grain solid wood board, LC-ST represents light-colored straight-grain solid wood board, CD-ST represents color difference straight-grain solid wood board, and DC-ST represents dark-colored straight-grain solid wood board.
[0035] Figure 6 This is a schematic diagram comparing the confusion matrix of the model of this invention with the confusion matrix of other models when using priority decision. In the figure, (a) is the MobileViT model; (b) is the ConvNeXt model; (c) is the RepViT model; and (d) is the network model of this invention. In each confusion matrix, WE represents white-edged solid wood board, CT represents curved-grain solid wood board, RT represents ring-grain solid wood board, and ST represents straight-grain solid wood board. Detailed Implementation
[0036] This embodiment provides a method for classifying the foreground and background characteristics of solid wood panels based on a dual-branch network, such as... Figure 1-4 As shown, the specific steps include:
[0037] S1: Acquire images of solid wood boards, and then scale and standardize the acquired solid wood board images. The scaled images have a height of 160 pixels and a width of 1280 pixels.
[0038] S2: The image processed by S1 is processed through the Stem module of the RepViT model to obtain the initial feature map F1, with a size of 48×40×320 in the order of channel, height, and width.
[0039] S3: Input feature map F1 into the first Fused Stage module shared by the foreground and background branches, complete one feature transformation and downsampling, and output feature map F2 with dimensions of 96×20×160 in the order of channel, height, and width.
[0040] S4: The feature map F2 is passed through the two Fused Stage modules of the background branch and the two Fused Stage modules of the foreground branch to output feature maps F3 and F4 respectively. The size is 384×5×40 in the order of channel, height and width.
[0041] S5: Input feature map F3 into Stage4 module of background branch to obtain deep semantic feature map F5. Process feature map F4 through SCConv to obtain feature map F6. The size is in the order of channel, height and width. The size of F5 and F6 is 384×5×40.
[0042] S6: Pass feature maps F5 and F6 through an average pooling layer and a fully connected layer respectively to obtain the background branch classification result and the foreground branch classification result.
[0043] In S6, the background branch can be categorized by color characteristics such as white edges, color difference, dark colors, and light colors; the foreground branch can be further subdivided into texture characteristics such as straight lines, circular lines, and curved lines.
[0044] The loss function used during background branch training in S6 is Focal loss, which is calculated using the following formula:
[0045]
[0046] in, This represents the model's predicted probability for the target class. The weights of the samples in the target class. It is the focal factor, with a value of 2.
[0047] In S6, SCConv first processes the input feature map X1 through a Spatial Reconstruction Unit (SRU) to suppress redundancy in the spatial dimension, generating spatially refined features X2∈R. C×H×W The generated spatially refined feature X2 is then input into the channel reconstruction unit (CRU) for processing to reduce redundancy in the channel dimension, resulting in the channel refined feature Y1∈R. C×H×W .
[0048] The foreground branch Stage4 module consists of the RepViTSEBlock module and the RepViTBlock module, which are connected in sequence. The FFN in the RepViTBlock module is replaced with ECA-FFN, where ECA-FFN has an ECA attention mechanism between the two 1×1 convolutional layers of the original FFN.
[0049] The ECA attention mechanism is applied to the input feature map X3∈R. C×H×W First, global average pooling is performed on the input feature map X3 to obtain the channel statistical descriptor z∈R. C×1×1 Next, a one-dimensional convolution with a kernel size of k is used to capture local interactions between channels, and a sigmoid activation function is applied to the output to generate channel attention weights w∈R. C×1×1 Finally, the attention weight w is weighted channel-by-channel with the input feature map X2 to obtain the output feature map Y2∈R. C×H×W ;
[0050] The kernel size k is adaptively determined by the number of channels C:
[0051]
[0052] Where γ and b are hyperparameters, taking values of 2 and 1 respectively, and |·|odd represents taking the nearest odd number.
[0053] During the training phase, the model first trains the stem module, the shared first Fused Stage, and the background branch to obtain the optimal background branch weights. Then, the foreground branch is trained in the second phase. First, the optimal stem layer weights, the shared first Fused Stage, and the background branch weights are loaded. Then, the loaded weights are frozen and the foreground branch is trained.
[0054] During the inference phase, when using a fusion decision strategy, the background branch includes four categories: white edge, color difference, light color, and dark color, while the foreground branch includes two categories: straight grain and curved grain. The prediction results of the background branch and the foreground branch are combined to obtain the final classification result, which includes eight categories: white edge-curved grain solid wood flooring, white edge-straight grain solid wood flooring, color difference-curved grain solid wood flooring, color difference-straight grain solid wood flooring, light color-curved grain solid wood flooring, light color-straight grain solid wood flooring, dark color-curved grain solid wood flooring, and dark color-straight grain solid wood flooring.
[0055] The above-mentioned classification method for foreground and background characteristics of solid wood panels employs a fusion decision scheme, using the collected solid wood panel image data as the dataset, such as... Figure 5 As shown in Table 1, the performance of the proposed method for classifying foreground and background characteristics of solid wood panels based on a dual-branch network is verified, and compared with existing methods.
[0056] Table 1. Comparison of the classification results of the fusion decision-making strategy of this invention with other classification methods.
[0057]
[0058] By analyzing Table 1, it can be seen that the foreground and background characteristic classification method for solid wood panels based on a dual-branch network proposed in this invention improves the accuracy by 1.2% compared to the original model.
[0059] During the inference phase, when employing a priority decision-making strategy, the background branch includes two categories: white edges and textures, while the foreground branch includes three categories: circular patterns, curved patterns, and straight patterns. If the background branch predicts a white edge, it is directly used as the final classification result; if the background branch predicts a texture, the texture sub-category output by the foreground branch is used as the final classification category.
[0060] Table 2. Comparison of the classification results of the priority decision-making strategy of this invention with other classification methods.
[0061]
[0062] Using the priority decision scheme in the above-mentioned classification method for foreground and background characteristics of solid wood panels, and taking another batch of collected solid wood panel image data as the dataset, such as... Figure 6 As shown in Table 2, the performance of the proposed method for classifying foreground and background characteristics of solid wood panels based on a dual-branch network is verified, and compared with existing methods.
[0063] By analyzing Table 2, it can be seen that the foreground and background characteristic classification method for solid wood panels based on a dual-branch network proposed in this invention improves the accuracy by 2.3% compared to the original model.
Claims
1. A method for classifying foreground and background characteristics of solid wood panels based on a dual-branch network, characterized in that, Including the following steps: S1: Acquire images of solid wood panels, then scale and standardize the acquired solid wood panel images. The scaled images have a height of h pixels and a width of w pixels, where w > h. S2: The image processed by S1 is passed through the Stem module of the RepViT model to obtain the initial feature map F1; S3: Input feature map F1 into the first N Fused Stage modules shared by the foreground and background branches, 0 < N < 4, N ∈ Z, complete one or more feature transformations and downsampling, and output feature map F2; S4: Pass feature map F2 through 3-N Fused Stage modules in the background branch and 3-N Fused Stage modules in the foreground branch to output feature maps F3 and F4 respectively; S5: Input feature map F3 into Stage4 module of background branch to obtain deep semantic feature map F5. Process feature map F4 through SCConv to obtain feature map F6. S6: Perform average pooling and fully connected operations on the feature maps F5 and F6 respectively to obtain the classification results of the background branch and the foreground branch, which are used to jointly classify the foreground texture characteristics and background color characteristics of solid wood panels.
2. The method for classifying foreground and background characteristics of solid wood panels based on a dual-branch network according to claim 1, characterized in that, In step S6, the background branch is used to classify solid wood board samples into at least one of the color characteristic categories such as white edge, color difference, dark color and light color; the foreground branch is used to classify solid wood board samples into at least one of the texture characteristic subcategories such as straight grain, ring grain, and curved grain.
3. The method for classifying foreground and background characteristics of solid wood panels based on a dual-branch network according to claim 1, characterized in that, During the model training phase, the background branch uses Focal loss as the loss function, which is defined as follows: , In the formula, This represents the model's predicted probability for the target class. The weights of the samples in the target class. It is the focus factor.
4. The method for classifying foreground and background characteristics of solid wood panels based on a dual-branch network according to claim 1, characterized in that, In step S5, SCConv first processes the input feature map X1 through a spatial reconstruction unit (SRU) to suppress redundancy in the spatial dimension, generating a spatially refined feature X2∈R. C×H×W The generated spatially refined feature X2 is then input into the channel reconstruction unit (CRU) for processing to reduce redundancy in the channel dimension, resulting in the channel refined feature Y1∈R. C×H×W .
5. The method for classifying foreground and background characteristics of solid wood panels based on a dual-branch network according to claim 1, characterized in that, The foreground branch Stage4 module consists of a RepViTSEBlock module and a RepViTBlock module connected in sequence; the FFN in the RepViTBlock module is replaced with ECA-FFN, wherein the ECA-FFN has an ECA attention mechanism between the two 1×1 convolutional layers of the original FFN.
6. The method for classifying foreground and background characteristics of solid wood panels based on a dual-branch network according to claim 5, characterized in that, The ECA attention mechanism is for input feature map X3∈R C×H×W First, global average pooling is performed on the input feature map X3 to obtain the channel statistical descriptor z∈R. C×1×1 Next, a one-dimensional convolution with a kernel size of k is used to capture local interactions between channels, and a sigmoid activation function is applied to the output to generate channel attention weights w∈R. C×1×1 Finally, the attention weight w is weighted channel-by-channel with the input feature map X2 to obtain the output feature map Y2∈R. C×H×W ; The kernel size k is adaptively determined by the number of channels C: , Where γ and b are hyperparameters, and |·|odd represents taking the nearest odd number.
7. The method for classifying foreground and background characteristics of solid wood panels based on a dual-branch network according to claim 1, characterized in that, During the model training phase, the first phase of training first trains the model's stem module, the shared first N Fused Stages, and the background branch to obtain the optimal background branch weights. Then, the second phase of training for the foreground branch is performed. First, the optimal stem layer weights, the shared first N Fused Stages, and the background branch weights are loaded. Then, the loaded weights are frozen, and the foreground branch is trained.
8. A method for classifying foreground and background characteristics of solid wood panels based on a dual-branch network according to any one of claims 1-7, characterized in that, During the model inference phase, the background branch and the foreground branch simultaneously output their respective prediction results. A fusion decision is then made on the prediction results of the two branches. The fusion decision combines the background category output by the background branch with the foreground sub-category output by the foreground branch to generate the final joint classification result.
9. A method for classifying foreground and background characteristics of solid wood panels based on a dual-branch network according to any one of claims 1-7, characterized in that, During the model inference stage, the background branch and the foreground branch simultaneously output their respective prediction results. A priority decision is made on the output results of the two branches. Specifically, if the category output by the background branch belongs to a specific set directly determined by color characteristics, then the output category of the background branch is directly used as the final classification result of the image. If the category output by the background branch does not belong to the specific set mentioned above, the output is ignored, and the texture subdivision category output by the foreground branch is taken as the final classification result of the image; the specific set directly determined by color characteristics includes one or both of white edges and color differences.