A method for wood identification based on near-infrared spectroscopy using a wavelet convolution network
By using multi-scale feature fusion and feature-level reconstruction of wavelet convolutional networks, the problems of low signal-to-noise ratio, overlapping of closely related species, and identification of unknown counterfeit samples in wood identification are solved, achieving high-precision wood identification and anti-counterfeiting effects.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- FUZHOU UNIV
- Filing Date
- 2026-04-29
- Publication Date
- 2026-06-09
AI Technical Summary
Existing technologies for wood identification suffer from low spectral signal-to-noise ratio, weak features, severe spectral overlap among closely related species, and a lack of anti-counterfeiting mechanisms, resulting in low identification accuracy and easy misjudgment of unknown counterfeit samples.
A dual-stream deep learning model for multi-scale feature fusion is constructed by using wavelet convolutional networks and combining wavelet transform with deep learning. This model includes a classification network and a rejection network. Multi-scale features are extracted through wavelet transform and rejection is reconstructed at the feature level to achieve high-precision wood identification.
It significantly improves the ability to distinguish closely related tree species, enhances anti-counterfeiting performance, and has an efficient and easy-to-deploy model structure, making it suitable for embedded chips with limited computing resources.
Smart Images

Figure CN122176487A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the interdisciplinary field of wood science, spectral analysis technology, and artificial intelligence. Specifically, it relates to a near-infrared spectroscopy method for wood identification based on wavelet convolutional networks. More particularly, it involves a method that utilizes deep learning algorithms to perform multi-scale feature fusion analysis on near-infrared spectral data, thereby achieving high-precision classification and identification of wood species and effectively rejecting and preventing counterfeit wood. This invention is especially suitable for rapid, non-destructive on-site testing and authenticity verification of rare and endangered woods such as rosewood and Guibourtia at customs ports, timber trading markets, and forestry quality inspection departments. Background Technology
[0002] Timber, as a natural polymer material with biological properties, is an indispensable resource for human societal development. With the overexploitation of global forest resources, rare and valuable timber is increasingly depleted, and many rare tree species, including rosewood, have been listed in the controlled appendices of the Convention on International Trade in Endangered Species of Wild Fauna and Flora (CITES). Driven by enormous economic interests, the timber trade market is rife with counterfeiting and substandard products. For example, unscrupulous individuals often use inexpensive "closely related" species that are extremely similar to valuable timber in terms of physical and mechanical properties or appearance (such as using *Guibourtia terreus* to impersonate *Dalbergia cochinchinensis*), and even soak non-valuable timber in chemical reagents to counterfeit rosewood. This not only seriously disrupts market order and harms the legitimate rights and interests of consumers, but also poses significant enforcement challenges to customs supervision and the protection of endangered species.
[0003] Currently, the legally mandated standard method for identifying timber species primarily relies on wood anatomy. This method requires professionals to soften, slice, and stain wood samples, then observe their microscopic anatomical features such as pores, axial parenchyma, and rays under an optical microscope. While this method is highly accurate, it has significant limitations in practical application: First, it is a destructive testing method; the sample preparation process is irreversible and will damage the integrity of the sample, making it unsuitable for testing finished furniture or cultural relics. Second, it is inefficient; the identification cycle for a single component typically takes several days, making it difficult to meet the "second-level" rapid inspection requirements for large-volume timber clearance by customs. Third, it is highly subjective, heavily reliant on the experience of identification experts; for "sister species" within the same genus, due to their minimal differences in anatomical features, misidentification is highly likely.
[0004] In recent years, near-infrared spectroscopy (NIRS) technology has attracted much attention in the field of wood testing due to its rapid, non-destructive, and environmentally friendly characteristics. NIRS records the vibrational absorption information of overtones and combination frequencies of hydrogen-containing groups (CH, OH, NH) within wood, reflecting the fingerprint characteristics of wood's chemical components (cellulose, hemicellulose, lignin, extracts). However, applying NIRS technology to practical wood identification still faces three major technical bottlenecks:
[0005] First, the spectral signal has a low signal-to-noise ratio and weak features. Wood is a natural heterogeneous and porous material. Its surface roughness, moisture content variations, and grain orientation all produce strong scattering effects on incident light, resulting in a large amount of high-frequency random noise, baseline drift, and light scattering interference mixed in the collected spectrum. Traditional preprocessing methods (such as Savitzky-Golay smoothing and first-order derivatives) often smooth out weak fingerprint absorption peaks in the spectrum while removing noise, leading to the loss of effective information.
[0006] Second, there is significant spectral overlap among closely related species. Woods from different species within the same genus have extremely similar chemical compositions, which is reflected in their spectra as two curves that almost completely overlap. Traditional chemometric methods (such as principal component analysis (PCA) and partial least squares discriminant analysis (PLS-DA) are shallow linear models, making it difficult to uncover deep nonlinear differences in spectral data, thus hindering the improvement of accuracy in identifying closely related species.
[0007] Third, there is a lack of anti-counterfeiting (rejection) mechanisms. This is the biggest pain point currently faced by deep learning-based timber classification models. Existing convolutional neural networks (CNNs) are typically trained based on the "closed set" assumption, meaning that all samples encountered during the testing phase must belong to categories defined in the training set. However, in practical applications, customs often encounters unknown tree species or new types of counterfeit timber not included in the training set (i.e., "open set" scenarios). In this case, traditional Softmax classifiers will force these unknown samples to be classified as a certain known type of timber (usually the category with the highest probability value), thus producing "high-confidence misclassifications." Existing solutions often attempt to reconstruct the original spectrum using pixel-level autoencoders, but due to the high noise content of the original spectrum, pixel-level reconstruction errors often cannot distinguish between "noise" and "anomalies," resulting in poor anti-counterfeiting effects.
[0008] Therefore, there is an urgent need to develop an intelligent wood identification method that can effectively extract weak spectral features, suppress noise interference, and automatically reject unknown counterfeit samples. Summary of the Invention
[0009] The purpose of this invention is to overcome the shortcomings of existing technologies and provide a near-infrared spectral wood identification method based on wavelet convolutional networks. By combining wavelet transform theory in signal processing with cascaded convolutional neural networks and feature-level autoencoder technology in deep learning, an innovative architecture of "wavelet multi-scale feature input + deep semantic feature extraction + feature-level reconstruction rejection" is constructed, which realizes high-precision feature extraction and authenticity identification of wood spectral data.
[0010] To achieve the above objectives, the technical solution of the present invention is: a near-infrared spectroscopy method for wood identification based on wavelet convolutional networks, comprising:
[0011] Near-infrared spectral data of the wood samples to be tested were acquired, and a standard dataset containing wood samples of various known categories was constructed. Unified resampling and standardization preprocessing were performed on the spectral data to eliminate instrument differences and obtain original spectral sequences with uniform dimensions.
[0012] Discrete wavelet transform is performed on the preprocessed original spectral sequence to perform multi-level time-frequency decomposition, separating the low-frequency approximate component that characterizes the overall spectral contour and the high-frequency detail component that characterizes the fine texture. The decomposed components are then upsampled to restore the original sequence length.
[0013] A three-channel one-dimensional spectral feature tensor is constructed, and the original spectral sequence, the upsampled low-frequency approximation component, and the upsampled high-frequency detail component are stacked in the channel dimension to form the input data;
[0014] A two-stream deep learning model including a classification network and a rejection network is constructed. The classification network is used to extract deep high-dimensional semantic feature vectors from a three-channel one-dimensional spectral feature tensor and output classification probabilities. The rejection network is a feature-level autoencoder, whose input is configured to receive the deep high-dimensional semantic feature vectors extracted by the classification network.
[0015] A two-stage separation strategy is adopted to train the dual-stream deep learning model: In the first stage, the classification network is trained until convergence, and then its weight parameters are frozen; in the second stage, known wood samples are input into the frozen classification network to extract deep high-dimensional semantic feature vectors as the target, and the rejection network is trained to minimize the error between the input features and the reconstructed output features.
[0016] Based on the trained rejection network, the deep feature reconstruction error of all known samples in the standard dataset is calculated, and a rejection threshold T for identifying unknown or fake samples is set according to statistical distribution rules:
[0017] During the online identification phase, the sample to be tested is input into the model. First, the deep features are extracted using the frozen classification network, and these features are then fed into the rejection network to calculate the reconstruction error. If the reconstruction error exceeds the rejection threshold T, the sample is determined to be abnormal and is blocked. If the reconstruction error is within the threshold range, the prediction result of the classification network is output as the final wood category.
[0018] Furthermore, the unified resampling and standardization preprocessing of the spectral data specifically includes:
[0019] The wavelength range from 1000nm to 1600nm was selected as the effective analysis interval;
[0020] The original spectral data were uniformly resampled into a discrete sequence with a wavelength interval of 2 nm using a linear interpolation algorithm;
[0021] For the Spectral vector after resampling Perform a standard normal transformation, and the transformed values The calculation formula is as follows:
[0022]
[0023] in, L is the sequence length; This is the mean of the spectrum of this sample. ε is the standard deviation of the sample spectrum; ε is a minimal constant to prevent the denominator from being zero.
[0024] Furthermore, the process of constructing the discrete wavelet transform and the three-channel one-dimensional spectral feature tensor specifically includes:
[0025] The Daubechies4 wavelet was selected as the basis function for the standardized spectral sequence. conduct Layered discrete wavelet decomposition;
[0026] For the j-th level decomposition Approximation coefficient and detail coefficient Iterative calculations are performed based on the following formula:
[0027]
[0028]
[0029] in, That is, the input signal ; These are the coefficients of the low-pass filter. These are the coefficients of the high-pass filter. This reflects the double downsampling operation after filtering;
[0030] The approximation coefficient cA2 obtained from the second decomposition is extracted as the low-frequency approximation component; the combination of the detail coefficients cD1 obtained from the first decomposition and cD2 obtained from the second decomposition is extracted as the high-frequency detail component.
[0031] The low-frequency approximation components and high-frequency detail components are upsampled to the same length as the original spectrum using an interpolation algorithm;
[0032] The original spectral sequence is mapped to the first channel, the upsampled low-frequency approximate component is mapped to the second channel, and the upsampled high-frequency detail component is mapped to the third channel. The input tensor is then stacked to construct the input tensor.
[0033] Furthermore, the dimensions of the three-channel one-dimensional spectral feature tensor are (batch size, 3, 301).
[0034] Furthermore, the classification network is a VGG-style cascaded one-dimensional convolutional neural network, comprising:
[0035] The first convolutional block consists of two cascaded one-dimensional convolutional layers, each with 128 convolutional kernels of size 3 and padding of size 1. Each convolutional layer is followed by a ReLU activation function. The end of the block is connected to a max pooling layer with a kernel size of 2, which is used to downsample the feature map by a factor of 2.
[0036] The second convolutional block, connected after the first convolutional block, consists of two cascaded one-dimensional convolutional layers. The number of input and output channels is kept at 128, the kernel size is 3, the padding is 1, followed by a ReLU activation function and a max pooling layer with a kernel size of 2.
[0037] The third convolutional block, connected after the second convolutional block, consists of two cascaded 128-channel convolutional layers and a max pooling layer, used to further extract deep abstract features.
[0038] The flattening layer is used to flatten the multi-channel two-dimensional feature map output by the third convolutional block into a one-dimensional high-dimensional feature vector with a dimension of 4736.
[0039] The fully connected classification layer receives a high-dimensional feature vector of 4736 dimensions, which is then passed through a dimensionality-reducing fully connected layer, a ReLU activation function, and a Dropout layer before finally being mapped to the class probability output layer.
[0040] Furthermore, the rejection network is a fully connected autoencoder, in which the encoder part compresses the high-dimensional feature vector output by the flattening layer of the classification network into a low-dimensional latent space, and the decoder part reconstructs the latent variables into feature vectors of the same dimension as the input; the loss function of the rejection network is the mean square error between the high-dimensional feature vector and its reconstructed vector.
[0041] Furthermore, in the two-stage separation strategy, the loss function used in the first stage of training the classification network... Let be the cross-entropy loss function, and its calculation formula is as follows:
[0042]
[0043] in, For batch size, For the number of categories, For real labels, To predict probabilities.
[0044] Furthermore, the process of setting the rejection threshold is as follows: calculate the feature reconstruction error value of all known samples in the standard dataset, and take the 95th percentile of the distribution of the error value as the rejection threshold.
[0045] The present invention also provides a near-infrared spectroscopy wood identification system based on wavelet convolutional networks, for implementing the above-described method, comprising:
[0046] The spectral data acquisition module is equipped with a near-infrared spectral acquisition interface, which is used to receive digital spectral signals of the wood sample to be tested in the 1000nm to 1600nm band.
[0047] The preprocessing and computation module has a built-in processor and a deep learning inference engine. The processor is configured to perform wavelet transform, tensor construction, and forward inference operations of the two-stream deep learning model.
[0048] The storage module is used to store the pre-trained classification network model weights, rejection network model weights, and preset rejection thresholds.
[0049] The interaction and display module is configured to display the wood identification results in real time and issue an anti-counterfeiting alarm signal when the reconstruction error exceeds the limit.
[0050] The present invention also provides a computer-readable storage medium having a computer program stored thereon that, when executed by a processor, implements the method described above.
[0051] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the near-infrared spectroscopy wood identification and anti-counterfeiting method based on wavelet convolutional networks as described above.
[0052] Compared with the prior art, the present invention has the following beneficial effects:
[0053] 1. Multi-view feature fusion enhances recognition accuracy. This invention innovatively introduces wavelet transform to construct a three-channel tensor input, essentially giving the neural network "multifocal glasses," enabling it to simultaneously learn the macroscopic contours (low frequency) and microscopic textures (high frequency) of the spectrum. This multi-scale feature fusion strategy significantly improves the model's ability to distinguish closely related tree species (such as different species of Guibourtia spp.).
[0054] 2. Feature-level reconstruction significantly improves anti-counterfeiting performance. This invention abandons traditional pixel-level reconstruction, i.e., directly reconstructing the original spectrum, and instead adopts a "feature-level reconstruction" scheme. Since the deep features extracted by the classification network have filtered out most random noise and baseline drift, and highly condensed the semantic information of the categories, the autoencoder reconstruction based on this is more sensitive to "anomalies." Compared to directly reconstructing the original spectrum, feature-level reconstruction can more accurately identify counterfeit wood that has similar main components but inconsistent subtle features.
[0055] 3. The two-stage training strategy ensures model stability. This invention employs a strategy of first training the classification network and then freezing the parameters to train the rejection network, avoiding gradient interference between different loss functions in multi-task learning. This decoupled design allows the classifier to focus on distinguishing fine-grained categories, while the rejection network can focus on learning the manifold boundaries of normal samples. The two do not hinder each other, achieving optimal overall system performance.
[0056] 4. The model structure is efficient and easy to deploy. The VGG-style concatenated convolution structure adopted in this invention has clear logic and strong operator versatility. Compared with complex multi-branch Inception or Transformer structures, it is easier to quantize and deploy on the embedded chip of a handheld spectrometer with limited computing resources. Attached Figure Description
[0057] Figure 1 The above is an overall flowchart of the method provided in the embodiments of the present invention.
[0058] Figure 2 This is a schematic diagram illustrating the principle of wavelet multi-scale decomposition and three-channel tensor construction in an embodiment of the present invention.
[0059] Figure 3 This is a block diagram illustrating the coupled structure of the classification network (Wavelet-CS-CNN) and the rejection network (Feature-AE) in an embodiment of the present invention.
[0060] Figure 4 This is a statistical distribution histogram of the rejection threshold setting in this embodiment of the invention. Detailed Implementation
[0061] The technical solution of the present invention will now be described in detail with reference to the accompanying drawings.
[0062] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.
[0063] It should be understood that the step numbers used in the text (if any) are for ease of description only and are not intended to limit the order in which the steps are performed.
[0064] It should be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the invention. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0065] The terms “comprising” and “including” indicate the presence of the described feature, whole, step, operation, element and / or component, but do not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or collections thereof.
[0066] The term “and / or” refers to any combination of one or more of the associated listed items, as well as all possible combinations, and includes these combinations.
[0067] This invention provides a near-infrared spectroscopy method for wood identification based on wavelet convolutional networks, comprising:
[0068] Near-infrared spectral data of the wood samples to be tested were acquired, and a standard dataset containing wood samples of various known categories was constructed. Unified resampling and standardization preprocessing were performed on the spectral data to eliminate instrument differences and obtain original spectral sequences with uniform dimensions.
[0069] Discrete wavelet transform is performed on the preprocessed original spectral sequence to perform multi-level time-frequency decomposition, separating the low-frequency approximate component that characterizes the overall spectral contour and the high-frequency detail component that characterizes the fine texture. The decomposed components are then upsampled to restore the original sequence length.
[0070] A three-channel one-dimensional spectral feature tensor is constructed, and the original spectral sequence, the upsampled low-frequency approximation component, and the upsampled high-frequency detail component are stacked in the channel dimension to form the input data;
[0071] A two-stream deep learning model including a classification network and a rejection network is constructed. The classification network is used to extract deep high-dimensional semantic feature vectors from a three-channel one-dimensional spectral feature tensor and output classification probabilities. The rejection network is a feature-level autoencoder, whose input is configured to receive the deep high-dimensional semantic feature vectors extracted by the classification network.
[0072] A two-stage separation strategy is adopted to train the dual-stream deep learning model: In the first stage, the classification network is trained until convergence, and then its weight parameters are frozen; in the second stage, known wood samples are input into the frozen classification network to extract deep high-dimensional semantic feature vectors as the target, and the rejection network is trained to minimize the error between the input features and the reconstructed output features.
[0073] Based on the trained rejection network, the deep feature reconstruction error of all known samples in the standard dataset is calculated, and a rejection threshold T for identifying unknown or fake samples is set according to statistical distribution rules:
[0074] During the online identification phase, the sample to be tested is input into the model. First, the deep features are extracted using the frozen classification network, and these features are then fed into the rejection network to calculate the reconstruction error. If the reconstruction error exceeds the rejection threshold T, the sample is determined to be abnormal and is blocked. If the reconstruction error is within the threshold range, the prediction result of the classification network is output as the final wood category.
[0075] The following are specific implementation examples of the present invention.
[0076] Example 1:
[0077] This embodiment proposes a near-infrared spectroscopy method for wood identification and anti-counterfeiting based on wavelet convolutional networks. Addressing the shortcomings of existing technologies, such as low signal-to-noise ratio, weak features, and lack of ability to reject unknown counterfeit samples in near-infrared spectroscopy for wood, this embodiment constructs an intelligent identification architecture that combines wavelet transform and deep feature reconstruction.
[0078] See Figure 1 , Figure 1 This document presents an overall flowchart of the method provided in this embodiment of the invention. From a macroscopic perspective, the method mainly covers the entire process from data acquisition and standardization preprocessing, wavelet multi-scale feature decomposition, multi-channel tensor stereo coding, to two-stream network model construction, two-stage separate training, and finally online identification and anti-counterfeiting interception. The various technical aspects are described in detail below.
[0079] See Figure 1Regarding data preprocessing, in practical applications, near-infrared spectral data is often acquired from spectrometers of different brands and models (such as Fourier transform spectrometers (FT-NIR) or grating dispersive spectrometers), leading to significant differences in the sampling interval, wavelength range, and resolution of the original data. To construct a high-quality standard dataset suitable for deep learning training, the data must first be standardized. This embodiment preferably selects the short-wave near-infrared band from 1000nm to 1600nm as the effective analysis range. The physical basis for choosing this band is that it concentrates the second-order overtone and combination absorption information of CH, OH, and NH groups in the main chemical components of wood (cellulose, hemicellulose, lignin), and compared to long-wave near-infrared, this band has stronger penetration and is more suitable for deep acquisition by fiber optic probes. For the original data with different resolutions, a linear interpolation algorithm is used for resampling, uniformly adjusting all spectra to a discrete sequence with a wavelength interval of 2nm. Each resampled spectrum is then processed by... Composed of consecutive absorbance values, represented as a vector. .
[0080] See also Figure 1 and Figure 2 To further eliminate physical interference during spectral acquisition, this embodiment introduces a standard normal transformation. As a natural heterogeneous material, wood's surface roughness, color intensity, and even minute variations in the distance between the probe and the sample can all lead to baseline shifts or tilts (additive noise) and changes in optical path length (multiplicative noise). To eliminate the interference of these physical factors, this embodiment performs a standard normal transformation, or Z-score normalization, on each spectral vector. For the ... spectral vector of each sample Its standardized value The calculation formula is as follows:
[0081]
[0082] in, ; The mean of the spectrum of this sample is calculated using the following formula: ; The standard deviation of the sample spectrum is calculated using the following formula: ; To prevent the minimum value where the denominator is zero (in this embodiment, we take...) After the above processing, the messy baseline drift in the original spectrum was corrected to near zero, and the characteristic absorption peaks of different tree species (especially the cellulose second harmonic peak near 1200nm and the lignin / moisture absorption peak near 1450nm) became more significant and consistent, thus greatly reducing the difficulty of subsequent deep learning model training.
[0083] See Figure 2 , Figure 2 This paper details the principles of wavelet multi-scale decomposition and three-channel tensor construction. Existing spectral preprocessing typically uses Savitzky-Golay smoothing or first-order differentiation. These methods often lose subtle fingerprint information or introduce additional high-frequency noise while denoising. This embodiment introduces discrete wavelet transform, utilizing its "multi-resolution analysis" characteristics to decouple the one-dimensional spectral signal into sub-bands of different frequencies. In this embodiment, the Daubechies4 (db4) wavelet is preferred as the basis function. The db4 wavelet possesses compact support, orthogonality, and asymmetry, and its waveform characteristics have a high degree of matching with the asymmetric absorption peak morphology commonly found in near-infrared spectroscopy, which can maximize the preservation of signal energy. According to the Mallat pyramid algorithm, the standardized spectral sequence is... conduct Layer decomposition. The decomposition process is essentially the process of passing the signal through a series of high-pass and low-pass filters. For the first layer... Layer decomposition ( Approximation coefficient and detail coefficient The calculation formula is as follows:
[0084]
[0085]
[0086] in, That is, the input signal ; These are the coefficients of the low-pass filter. These are the coefficients of the high-pass filter; This demonstrates the double downsampling operation after filtering. This embodiment extracts the second-layer approximation coefficients. As a low-frequency approximation component, this component mainly contains the low-frequency part of the spectral signal, smooths out the high-frequency thermal noise generated by the instrument's electronic components, and preserves the overall contour trend of chemical bond vibrations in macromolecules such as cellulose and lignin; at the same time, it extracts the first-layer detail coefficients. and the second layer of detail coefficient The combination of these components serves as a high-frequency detail component, which implies subtle textural differences (fingerprint features) between closely related tree species.
[0087] See further Figure 2 On the right, to enable the deep learning model to process the aforementioned multi-scale features simultaneously, this embodiment constructs a three-channel feature tensor with complementary information of "original-trend-detail". Due to the downsampling operation, the first... The length of the layer wavelet coefficients is approximately the original length. To meet the dimensionality consistency requirement of tensor stacking, this embodiment first employs an interpolation algorithm (such as spline interpolation or linear interpolation) to... , and Upsampling restores the spectrum to the same length as the original spectrum. Subsequently, the construction dimension is... Input tensor ,in For batch size, For the number of channels, The sequence length is given. The specific mapping relationship and definitions of the three channels are as follows: Channel 1 is mapped to the original normalized spectral sequence. This channel provides unprocessed full-spectrum information as a reference; channel two is mapped to upsampled low-frequency approximation coefficients. This channel provides the denoised spectral trend; the channel 3 mapping is the sum of the high-frequency detail coefficients after upsampling (i.e., This channel highlights subtle variations in the spectrum.
[0088] See Figure 3 , Figure 3 The detailed architecture of the two-stream deep neural network proposed in this embodiment is shown. The model includes parallel "classification branches" and "rejection branches", but exhibits serial coupling characteristics in the data flow direction.
[0089] Combination Figure 3First, the structure of the classification network (Wavelet-CS-CNN) is described in detail. This network aims to extract discriminative deep features for accurate classification of wood types. This embodiment adopts the classic VGG-style cascaded convolutional architecture, specifically containing three consecutive convolutional blocks. The first convolutional block contains two cascaded one-dimensional convolutional layers, each with 128 kernels, a kernel size of 3, and padding of 1. Each convolutional layer is followed by a ReLU activation function. The end of this block is connected to a max-pooling layer with a kernel size of 2 and a stride of 2, used to downsample the feature map by a factor of 2. The second convolutional block is connected after the first convolutional block, also containing two cascaded one-dimensional convolutional layers, with both input and output channels maintained at 128, a kernel size of 3, padding of 1, followed by a ReLU activation function and a max-pooling layer with a kernel size of 2. The third convolutional block, connected after the second, has the same structure as the previous convolutional blocks, containing two cascaded 128-channel convolutional layers and a max-pooling layer for further extraction of deep abstract features. After processing by these three convolutional blocks, the original spectral data is mapped into a multi-channel deep feature map. For classification, the model includes a flattening layer that flattens the multi-channel feature map output by the third convolutional block into a one-dimensional high-dimensional feature vector. In this embodiment, the high-dimensional feature vector has a dimension of 4736. Finally, this 4736-dimensional feature vector is input into a fully connected classification layer, passing sequentially through a linear transformation layer (4736->256), a ReLU activation function, and a Dropout layer (with a dropout rate set to 0.5 to prevent overfitting). Finally, it is mapped to the probability distribution of each known wood category through the output layer (256->number of categories).
[0090] See also Figure 3The innovation of this embodiment lies in the introduction of a feature-level rejection network. Unlike traditional methods of reconstructing the original image, this embodiment employs a "feature reconstruction" scheme. This network is a fully connected autoencoder whose input does not directly receive spectral data, but is instead configured to receive a 4736-dimensional deep feature vector output from the flattening layer of the classification network. The encoder consists of multiple fully connected layers, designed to compress the 4736-dimensional high-dimensional features into a low-dimensional latent space. Specifically, the structure is: a first fully connected layer (4736->128), followed by ReLU activation; a second fully connected layer (128->64), followed by ReLU activation. Through this process, the high-dimensional features are compressed into 64-dimensional latent variables, forcing the model to discard noise and anomalous features, retaining only the principal components of normal wood. The decoder structure is mirror-symmetric to the encoder, aiming to restore the latent variables to a 4736-dimensional reconstructed feature vector. Specifically, the structure is: a first fully connected layer (64->128), followed by ReLU activation; a second fully connected layer (128->4736), directly outputting the reconstructed features. The underlying logic of this design is that the deep features extracted by the classification network have filtered out most of the noise and highly condensed the semantic information of the categories. If the input is known wood, its deep features conform to the distribution of the training data, and the autoencoder can reconstruct it well; if the input is counterfeit wood, its deep feature distribution is abnormal, and the autoencoder will not be able to reconstruct it effectively, resulting in a huge reconstruction error.
[0091] Regarding the model training strategy, this embodiment adopts a two-stage separate training strategy of "classification first, anti-spoofing later," effectively avoiding gradient interference in multi-task learning. The first stage: Classification network training. Using a labeled known timber dataset (including training and validation sets), a cross-entropy loss function is defined, and the Adam optimizer is used (learning rate set to 0.001). A three-channel tensor is input into the classification network, and the weights of the convolutional and fully connected layers are updated through backpropagation until the classification accuracy converges. After training, the weights of the model with the highest classification accuracy are saved, and all parameters of the classification network are fixed, so that it is used only as a feature extractor in the second stage. Cross-entropy loss function. The calculation is as follows:
[0092]
[0093] In the formula, For batch size, For the number of categories, For real labels, To predict probabilities. Second stage: Rejection network training. Only known class positive samples from the training set are used. In each training batch, data is first input into the frozen classification network, and the 4736-dimensional feature vector of the flattened layer is extracted as the "target ground truth"; then this feature vector is input into the autoencoder, and the mean squared error (MSE Loss) between the output reconstructed feature vector and the input feature vector is calculated. The Adam optimizer is also used for optimization. This process forces the autoencoder to learn "what are the normal deep features of wood". MSE loss function The calculation is as follows:
[0094]
[0095] In the formula, The deep feature vectors extracted by the classification network. This is the reconstructed feature vector output by the autoencoder.
[0096] See Figure 4 , Figure 4 This demonstrates the principle behind setting the rejection threshold. After the rejection network is trained, a quantitative standard for judging anomalies needs to be determined. This embodiment uses the statistical quantile method. All known samples from the training or validation set are input into the model, and the reconstruction error between the features extracted by the classification network and the features reconstructed by the autoencoder is recorded. The error value distribution of all samples is statistically analyzed; typically, this error follows a long-tailed distribution. In this embodiment, the 95th percentile of this error distribution is used as the rejection threshold. .Right now:
[0097]
[0098] This means that the model accepts 95% of its own samples, while considering outliers with extremely large errors as potential anomalies.
[0099] Finally, combining Figure 1 The process describes the specific logic of online authentication and anti-counterfeiting interception. In the actual inference phase, for any input sample to be tested, the following logic is executed:
[0100] The test samples are subjected to the same resampling, SNV normalization, wavelet decomposition, and three-channel tensor construction as the training set.
[0101] The tensor was input into the frozen classification network to extract a 4736-dimensional deep feature vector.
[0102] The feature vector is input into the autoencoder to obtain the reconstructed feature vector, and the mean square error (MSE) between the two is calculated.
[0103] The calculated reconstruction error is compared with a preset threshold. The system compares the samples. If the error is greater than the threshold, the system determines that the sample deviates from the characteristic manifold of known wood and belongs to "unknown tree species" or "fake wood", and directly triggers an interception alarm. If the error is less than or equal to the threshold, the system determines that the sample is real wood and further reads the Softmax output of the classification network, returning the tree species name with the highest probability as the final identification result.
[0104] Example 2:
[0105] This embodiment provides a near-infrared spectroscopy wood identification system and electronic device for implementing the above method. The electronic device mainly includes a spectral data acquisition module, a preprocessing and calculation module, a storage module, and an interactive display module in its hardware architecture.
[0106] The spectral data acquisition module is equipped with a near-infrared spectral acquisition interface (such as USB, Bluetooth, or fiber optic interface) to receive digital spectral signals from the wood sample in the 1000nm to 1600nm wavelength range. This module is compatible with various handheld miniature spectrometers (such as MEMS-based DLP spectrometers) or benchtop Fourier transform spectrometers.
[0107] The preprocessing and computation module incorporates a high-performance processor, which can be a general-purpose central processing unit (CPU), graphics processing unit (GPU), digital signal processor (DSP), or a dedicated neural processing unit (NPU) for accelerating neural networks. The processor is configured to execute instructions stored in memory, performing wavelet transform, tensor construction, and forward inference operations of the two-stream deep learning model as described in Embodiment 1. To adapt to mobile deployments, this embodiment can export the trained PyTorch model to the ONNX (Open Neural Network Exchange) general format and utilize inference engines such as TensorRT or NCNN for quantization acceleration, achieving millisecond-level inference on low-power embedded devices.
[0108] The storage module stores pre-trained classification network model weights, rejection network model weights, preset rejection thresholds, and a standard wood spectral database. The storage medium can be high-speed random access memory (RAM) or non-volatile flash memory.
[0109] The interaction and display module is configured to display the wood identification results in real time. When the feature reconstruction error of a sample exceeds the threshold, the module will issue an anti-counterfeiting alarm signal (such as displaying a red warning on the screen and sounding a buzzer alarm); when the sample passes the anti-counterfeiting detection, the module will display the specific tree species name and confidence level.
[0110] Example 3:
[0111] This embodiment provides a computer-readable storage medium on which a computer program is stored. When executed by a processor, the computer program implements the near-infrared spectroscopy wood identification and anti-counterfeiting method based on wavelet convolutional networks as described in Embodiment 1.
[0112] The computer-readable storage medium can be any medium capable of storing code, including but not limited to: random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other storage technologies, optical disc read-only memory (CD-ROM), digital multifunction disc (DVD) or other optical disc storage, magnetic cartridges, magnetic tapes, disk storage or other magnetic storage devices.
[0113] In summary, this invention successfully solves the three major problems in near-infrared spectroscopy wood identification: "unclear visibility" (noise interference), "indistinguishable" (closely related species), and "unavoidable" (counterfeit and substandard products) by constructing an architecture that combines physically interpretable wavelet features with data-driven deep networks, and in particular by introducing an autoencoder rejection mechanism based on deep semantic features. It has extremely high practical application value.
[0114] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
Claims
1. A near-infrared spectroscopy method for wood identification based on wavelet convolutional networks, characterized in that, include: Near-infrared spectral data of the wood samples to be tested were acquired, and a standard dataset containing wood samples of various known categories was constructed. Unified resampling and standardization preprocessing were performed on the spectral data to eliminate instrument differences and obtain original spectral sequences with uniform dimensions. Discrete wavelet transform is performed on the preprocessed original spectral sequence to perform multi-level time-frequency decomposition, separating the low-frequency approximate component that characterizes the overall spectral contour and the high-frequency detail component that characterizes the fine texture. The decomposed components are then upsampled to restore the original sequence length. A three-channel one-dimensional spectral feature tensor is constructed, which stacks the original spectral sequence, the upsampled low-frequency approximation component, and the upsampled high-frequency detail component in the channel dimension to form the input data; A two-stream deep learning model including a classification network and a rejection network is constructed. The classification network is used to extract deep high-dimensional semantic feature vectors from a three-channel one-dimensional spectral feature tensor and output classification probabilities. The rejection network is a feature-level autoencoder, whose input is configured to receive the deep high-dimensional semantic feature vectors extracted by the classification network. A two-stage separation strategy is adopted to train the dual-stream deep learning model: In the first stage, the classification network is trained until convergence, and then its weight parameters are frozen; in the second stage, known wood samples are input into the frozen classification network to extract deep high-dimensional semantic feature vectors as the target, and the rejection network is trained to minimize the error between the input features and the reconstructed output features. Based on the trained rejection network, the deep feature reconstruction error of all known samples in the standard dataset is calculated, and a rejection threshold T for identifying unknown or fake samples is set according to statistical distribution rules: During the online identification phase, the sample to be tested is input into the model. First, the deep features are extracted using the frozen classification network, and these features are then fed into the rejection network to calculate the reconstruction error. If the reconstruction error exceeds the rejection threshold T, the sample is determined to be abnormal and is blocked. If the reconstruction error is within the threshold range, the prediction result of the classification network is output as the final wood category.
2. The near-infrared spectroscopy method for wood identification based on wavelet convolutional networks according to claim 1, characterized in that, The unified resampling and standardization preprocessing of the spectral data specifically includes: The wavelength range from 1000nm to 1600nm was selected as the effective analysis interval; The original spectral data were uniformly resampled into a discrete sequence with a wavelength interval of 2 nm using a linear interpolation algorithm; For the first Spectral vector after resampling Perform a standard normal transformation, and the transformed values The calculation formula is as follows: in, L is the sequence length; This is the mean of the spectrum of this sample. ε is the standard deviation of the sample spectrum; ε is a minimal constant to prevent the denominator from being zero.
3. The near-infrared spectroscopy method for wood identification based on wavelet convolutional networks according to claim 1, characterized in that, The process of constructing the discrete wavelet transform and the three-channel one-dimensional spectral feature tensor specifically includes: The Daubechies4 wavelet was selected as the basis function for the standardized spectral sequence. conduct Layered discrete wavelet decomposition; For the j-th level decomposition Approximation coefficient and detail coefficient Iterative calculations are performed based on the following formula: in, That is, the input signal ; These are the coefficients of the low-pass filter. These are the coefficients of the high-pass filter. This reflects the double downsampling operation after filtering; The approximation coefficient cA2 obtained from the second decomposition is extracted as the low-frequency approximation component; the combination of the detail coefficients cD1 obtained from the first decomposition and the detail coefficients cD2 obtained from the second decomposition is extracted as the high-frequency detail component. The low-frequency approximation components and high-frequency detail components are upsampled to the same length as the original spectrum using an interpolation algorithm; The original spectral sequence is mapped to the first channel, the upsampled low-frequency approximate component is mapped to the second channel, and the upsampled high-frequency detail component is mapped to the third channel. The input tensor is then stacked to construct the input tensor.
4. The near-infrared spectroscopy method for wood identification based on wavelet convolutional networks according to claim 3, characterized in that, The dimensions of the three-channel one-dimensional spectral feature tensor are (batch size, 3, 301).
5. The near-infrared spectroscopy method for wood identification based on wavelet convolutional networks according to claim 1, characterized in that, The classification network is a VGG-style cascaded one-dimensional convolutional neural network, comprising, in sequence: The first convolutional block consists of two cascaded one-dimensional convolutional layers, each with 128 convolutional kernels of size 3 and padding of size 1. Each convolutional layer is followed by a ReLU activation function. The end of the block is connected to a max pooling layer with a kernel size of 2, which is used to downsample the feature map by a factor of 2. The second convolutional block, connected after the first convolutional block, consists of two cascaded one-dimensional convolutional layers. The number of input and output channels is kept at 128, the kernel size is 3, the padding is 1, followed by a ReLU activation function and a max pooling layer with a kernel size of 2. The third convolutional block, connected after the second convolutional block, consists of two cascaded 128-channel convolutional layers and a max pooling layer, used to further extract deep abstract features. The flattening layer is used to flatten the multi-channel two-dimensional feature map output by the third convolutional block into a one-dimensional high-dimensional feature vector with a dimension of 4736. The fully connected classification layer receives a high-dimensional feature vector of 4736 dimensions, which is then passed through a dimensionality-reducing fully connected layer, a ReLU activation function, and a Dropout layer before finally being mapped to the class probability output layer.
6. The near-infrared spectroscopy method for wood identification based on wavelet convolutional networks according to claim 5, characterized in that, The rejection network is a fully connected autoencoder. Its encoder part compresses the high-dimensional feature vector output by the flattening layer of the classification network into a low-dimensional latent space, and its decoder part reconstructs the latent variables into feature vectors of the same dimension as the input. The loss function of the rejection network is the mean square error between the high-dimensional feature vector and its reconstructed vector.
7. The near-infrared spectroscopy method for wood identification based on wavelet convolutional networks according to claim 1, characterized in that, In the two-stage separation strategy, the loss function used in the first stage of training the classification network is... Let be the cross-entropy loss function, and its calculation formula is as follows: in, For batch size, For the number of categories, For real labels, To predict probabilities.
8. The near-infrared spectroscopy method for wood identification based on wavelet convolutional networks according to claim 1, characterized in that, The process of setting the rejection threshold is as follows: calculate the feature reconstruction error value of all known samples in the standard dataset, and take the 95th percentile of the error value distribution as the rejection threshold.
9. A near-infrared spectroscopy wood identification system based on wavelet convolutional networks, used to implement the method according to any one of claims 1-8, characterized in that, include: The spectral data acquisition module is equipped with a near-infrared spectral acquisition interface, which is used to receive digital spectral signals of the wood sample to be tested in the 1000nm to 1600nm band. The preprocessing and computation module has a built-in processor and a deep learning inference engine. The processor is configured to perform wavelet transform, tensor construction, and forward inference operations of the two-stream deep learning model. The storage module is used to store the pre-trained classification network model weights, rejection network model weights, and preset rejection thresholds. The interaction and display module is configured to display the wood identification results in real time and issue an anti-counterfeiting alarm signal when the reconstruction error exceeds the limit.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the method as described in any one of claims 1 to 8.