Tea moisture content detection method based on spectrum fusion and convolutional neural network
Through the methods of spectral fusion and convolutional neural network, the accuracy and real-time problems in tea moisture content detection are solved, and fast and accurate tea moisture content detection is achieved, which is suitable for real-time monitoring of tea processing processes.
Patent Information
- Application Number
- CN202510103071.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-22
- Publication Date
- 2025-04-11
- Estimated Expiration
- 2045-01-22
AI Technical Summary
The prior art has problems in the detection of tea moisture content, which are not very accurate, have a long measurement cycle and may damage the internal nutrients of tea, and it is particularly difficult to achieve real-time detection.
The detection method based on spectral fusion and convolutional neural network is adopted to construct tea map fusion data sets to perform low- and intermediate fusion of spectral and texture characteristics, and use convolutional neural networks to predict, to achieve rapid and accurate detection of tea moisture content.
It improves the accuracy and speed of tea moisture content detection, and can achieve real-time detection without destroying tea, providing a favorable detection basis for the tea processing process.
Smart Images

Figure CN119810669A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of tea processing, and in particular to a method for detecting the moisture content of tea based on spectral fusion and convolutional neural network. Background Art
[0002] The moisture content of tea leaves is an important parameter for evaluating tea quality. Appropriate moisture content can maintain the aroma, taste and color of tea leaves. Too high or too low moisture content will affect the quality and taste of tea leaves. By studying the moisture content of tea leaves, the optimal moisture range can be determined, thereby improving the quality and taste of tea leaves.
[0003] The traditional method of measuring the moisture content of tea is to use the constant temperature oven method. The results of the constant temperature oven method are accurate, stable, and have small errors, but the measurement cycle is long, requiring at least half an hour or even more time. In addition, the internal nutrients of the tea will be destroyed during the high-temperature drying process, and the need for on-site real-time testing in tea processing, trade, storage, etc. cannot be met.
[0004] Although there have been studies using spectral technology to predict the moisture content of tea, most of them use a single spectrum to predict, and do not fully utilize the spectral information, which may lead to low prediction accuracy. In addition, the resources required to predict the moisture content using the full-band spectrum are large, and it is impossible to port it to hardware to achieve real-time tea moisture content detection. Summary of the invention
[0005] The present invention aims to solve the deficiencies of the above-mentioned prior art and proposes a tea moisture content detection method based on spectral fusion and convolutional neural network, in order to achieve rapid and accurate prediction of the moisture content of tea, thereby improving the accuracy of tea moisture content prediction and laying a favorable foundation for real-time detection of tea moisture content during the processing process.
[0006] In order to achieve the above-mentioned purpose, the present invention adopts the following technical scheme:
[0007] The tea moisture content detection method based on spectral fusion and convolutional neural network of the present invention is characterized in that it is carried out according to the following steps:
[0008] Step 1: Construct a tea atlas fusion dataset ,in, represents the tea spectral feature dataset; represents the tea texture feature dataset; the atlas fusion data of any tea sample is recorded as , where t represents the spectral feature vector of the tea sample, where: Indicates Spectral response of each band; Indicates the number of bands; represents the texture feature vector of the tea sample, where: Indicates Texture feature values; Represents the number of texture features; let the actual moisture content of the tea sample be ;
[0009] Step 2: Calculate the standardized Texture Features , thus obtaining the standardized texture feature vector ,in, is the mean value of the texture characteristics of the tea sample, is the standard deviation of the texture characteristics of the tea sample;
[0010] Step 3: and Perform fusion of different feature levels to obtain low-level fused tea feature vectors and the intermediate fusion tea feature vector ;
[0011] Step 4: Right Correction is performed to obtain the corrected low-level fusion feature vector ,in, Indicates A corrected low-grade fusion characteristic of tea leaves;
[0012] Step 5: Follow the process from step 4.1 to step 4.3 to Processing is performed to obtain the corrected intermediate fusion feature vector ,in, Indicates A corrected mid-level blend of tea characteristics;
[0013] Step 6: Construct a tea moisture content prediction network, including Conv module, attention module and prediction module, and and Processing, corresponding Predicted moisture content and Predicted moisture content ;
[0014] Step 7: Right and Take the weighted average to get the predicted moisture content mean ;in, The corresponding weight, express The corresponding weights;
[0015] Step 8: Based on and Constructing the mean square error loss function ;
[0016] Step 9: Fusion dataset based on tea atlas , use the sgdm optimizer to train the tea moisture content prediction network and calculate the mean square error loss function To update the network parameters until the mean square error loss function The training process continues until convergence, thus obtaining a trained tea moisture content regression model and using it on the ZYNQ development board for regression prediction of tea moisture content.
[0017] The tea moisture content detection method based on spectral fusion and convolutional neural network described in the present invention is also characterized in that step 3 is performed according to the following steps:
[0018] Step 3.1: and After splicing, we get the low-level fused tea feature vector ;in, Indicates A low-grade blend of tea characteristics; represents the number of features after low-level fusion; and ;
[0019] Step 3.2: Use SPA algorithm to and Perform feature screening to obtain the filtered spectral feature vector And the filtered texture feature vector ,in, After filtering Spectral characteristics of each band; Indicates the number of spectral features after screening; After filtering Texture values; Indicates the number of texture features after screening;
[0020] Step 3.3: and After splicing, we get the intermediate fusion tea feature vector ,in, Indicates A mid-level blend of tea characteristics; represents the number of features after low-level fusion; and .
[0021] Further, step 4 is performed as follows:
[0022] Step 4.1: Calculate the feature mean of low-level fusion ;
[0023] Step 4.2: Build Linear regression equation ,in, For the The baseline offset, For the Baseline shift amount;
[0024] Step 4.3: Calculate the corrected Low-level fusion features .
[0025] Further, step 6 is performed as follows:
[0026] Step 6.1: Input into the Conv module and pass through After processing by parallel convolution units, the spectral feature vector is obtained. ,in, Representative The spectral features output by parallel convolution units;
[0027] Step 6.2: The attention module consists of fully connected layers, an element-wise addition layer, an adaptive compression layer, The excitation layer activation function SoftMax layer, element-wise multiplication layers, and Processing is performed to obtain the low-level fusion multiplication feature vector of tea leaves ;
[0028] Step 6.3: The prediction module consists of It consists of fully connected layers;
[0029] Will After the low-level fusion features of each tea are spliced, they are expanded into a one-dimensional feature vector according to the channel dimension and input We perform dimensionality reduction in the fully connected layers and obtain Predicted moisture content ;
[0030] Step 6.4: Follow the process from step 6.2 to step 6.3 to Processing to obtain Predicted moisture content .
[0031] Further, step 6.2 is performed as follows:
[0032] Step 6.2.1: Input into the attention module, Fully connected layer pairs After unified dimension processing, we get Low-grade fusion characteristics of tea ; thus obtaining The same dimensions of tea low-level fusion integration characteristics ;
[0033] Step 6.2.2: Input into the element-by-element addition layer for processing to obtain the low-level fusion addition features of tea leaves ;
[0034] Step 6.2.3: Input into the adaptive compression layer for processing to obtain the low-level fusion adaptive compression features of tea leaves ;
[0035] Step 6.2.4: Enter into In the parallel excitation layers, we get Tea low-level fusion excitation characteristics ;in, Indicates Each tea leaves low-grade fusion stimulates characteristics;
[0036] Step 6.2.5: Enter to The activation function SoftMax layer is processed to obtain the Low-level fusion normalized features of tea leaves ;
[0037] Step 6.2.6: and Enter to The processed element-by-element multiplication layer is used to obtain the processed The characteristics of low-grade fusion of tea leaves , thus obtaining the low-level fusion multiplication feature vector of tea leaves .
[0038] The electronic device of the present invention includes a memory and a processor, wherein the memory is used to store a program that supports the processor to execute the tea moisture content detection method, and the processor is configured to execute the program stored in the memory.
[0039] The present invention provides a computer-readable storage medium, wherein a computer program is stored on the computer-readable storage medium, and the computer program executes the steps of the tea moisture content detection method when the computer program is run by a processor.
[0040] Compared with the prior art, the beneficial effects of the present invention are:
[0041] 1. The present invention proposes a spectral fusion method, which takes a hyperspectral image in a dark room to obtain the spectral data and texture data of tea leaves. These data contain characteristic information of the moisture content of tea leaves. The two are fused at a low level and a mid-level, and then weighted averaged. On the one hand, it makes up for the limitations of a single spectrum, makes full use of the rich spectral resources of the hyperspectral spectrum, and enhances the reliability of using spectral technology to predict the moisture content of tea leaves; on the other hand, the use of feature screening reduces a large amount of redundant information, greatly reduces the parameters in the training process, and is easier to transplant to hardware, laying the foundation for the rapid detection of the moisture content of tea leaves.
[0042] 2. The present invention designs a tea moisture content prediction model, which extracts spectral features of different scales through multiple parallel Conv modules, and substitutes the output features into the prediction module through the fully connected layer, element-by-element addition layer, adaptive compression layer, excitation layer, activation function SoftMax layer, and element-by-element multiplication layer in the attention mechanism module. This method allows the model to reduce redundant features while retaining key information, improves the model's learning ability for tea spectral data and the accuracy of moisture content prediction. It can achieve non-invasive monitoring of tea moisture content and provide support for intelligent control of the production process. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 It is a specific embodiment diagram of the present invention;
[0044] Figure 2 is a flow chart of the spectrum fusion method of the present invention;
[0045] Figure 3 It is a structural diagram of the tea moisture content prediction model of the present invention;
[0046] Figure 4 A method diagram for transplanting hardware for the model of the present invention. DETAILED DESCRIPTION
[0047] In this embodiment, a method for detecting the moisture content of tea leaves based on spectral fusion and convolutional neural network is provided. Figure 1As shown, the extraction and fusion of tea spectral features and texture features are realized on the PC side, the fusion features are trained using the designed prediction model, the model is transplanted to the ZYNQ development board, and the visual distribution of tea moisture content is realized. The HDMI cable is used to communicate with the ZYNQ development board, and the visual distribution diagram of tea moisture content is displayed on the display screen;
[0048] The spectrum acquisition device includes: a hyperspectral camera, two halogen lamps, two lamp stands, a shooting platform, and a calibration white board; the tea moisture content detection method is performed according to the following steps:
[0049] Step 1: Construct a tea atlas fusion dataset ,in, represents the tea spectral feature dataset; represents the tea texture feature dataset; the atlas fusion data of any tea sample is recorded as , where t represents the spectral feature vector of the tea sample, where Indicates Spectral response of each band; Indicates the number of bands; Represents the texture feature vector of the tea sample, where Indicates Texture feature values; Represents the number of texture features; let the actual moisture content of the tea sample be ;
[0050] In this embodiment, the total sample size of the tea spectrum fusion data set is 600, and the dimension of the tea spectrum feature vector is , the dimension of the tea texture feature vector calculated using the gray level co-occurrence matrix is ,include Angular second moment, entropy, contrast, inverse difference matrix, and correlation in four directions.
[0051] Step 2: Calculate the standardized Texture Features , thus obtaining the standardized texture feature vector ,in, is the mean value of the texture features of tea samples, is the standard deviation of the texture characteristics of tea samples;
[0052] Step 3: and Perform fusion of different feature levels to obtain low-level fused tea feature vectors and the intermediate fusion tea feature vector ;
[0053] Step 3.1: and After splicing, we get the low-level fused tea feature vector ;in, Indicates A low-grade blend of tea characteristics; represents the number of features after low-level fusion; and c= + ;
[0054] Step 3.2: Use SPA algorithm to and Perform feature screening to obtain the filtered spectral feature vector And the filtered texture feature vector ,in, After filtering Spectral characteristics of each band; Indicates the number of spectral features after screening; After filtering Texture values; Indicates the number of texture features after filtering.
[0055] Step 3.3: and After splicing, we get the intermediate fusion tea feature vector ,in, Indicates A mid-level blend of tea characteristics; represents the number of features after low-level fusion; and d= + ;
[0056] In this embodiment, the low-level and intermediate fusion methods are as follows: Figure 2 As shown in Figure 2, the number of tea features after low-level fusion is 224; the dimension of the spectral feature vector after screening is The selected features are 397.3, 420.3, 533.8, 566.1, 684.6, 756.5, 801.7, 819.9, 826.1, 859.4, 908.2, 988.1, 1003.5 nm respectively; the dimension of the texture feature vector after screening is , which are the entropy in the 0° direction, the angular second-order moment in the 45° direction, the correlation in the 90° direction, and the entropy in the 135° direction; the number of tea features after intermediate fusion is 17.
[0057] Step 4: Right Correction is performed to obtain the corrected low-level fusion feature vector ,in, Indicates A corrected low-grade fusion characteristic of tea leaves;
[0058] Step 4.1: Calculate the feature mean of low-level fusion ;
[0059] Step 4.2: Build Linear regression equation ,in, For the The baseline offset, For the Baseline shift amount;
[0060] Step 4.3: Calculate the corrected Low-level fusion features .
[0061] Step 5: Follow the process from step 4.1 to step 4.3 to Processing is performed to obtain the corrected intermediate fusion feature vector ,in, Indicates A corrected mid-level blend of tea characteristics;
[0062] Step 6: Construct a tea moisture content prediction network, including: Conv module, attention module and prediction module;
[0063] In this embodiment, the model is designed as follows Figure 3 As shown in Figure 2, the Conv module consists of 3 parallel Convs. The first Conv consists of 8 convolution kernels with a size of , a one-dimensional convolutional layer with a stride of 1, a batch normalization layer, a ReLU activation function layer, and a kernel size of , an average pooling layer with a step size of 1; the second Conv consists of 16 convolution kernels with a size of , a one-dimensional convolutional layer with a stride of 1, a batch normalization layer, a ReLU activation function layer, and a kernel size of , an average pooling layer with a step size of 1; the third Conv consists of 32 convolution kernels with a size of , a one-dimensional convolutional layer with a stride of 1, a batch normalization layer, a ReLU activation function layer, and a kernel size of , an average pooling layer with a step size of 1;
[0064] Step 6.1: Input into the Conv module and pass through After processing by parallel convolution units, the spectral feature vector is obtained. ,in, Representative The spectral features output by parallel convolution units;
[0065] In this embodiment, Input into the Conv module, and after being processed by three parallel Conv modules, multi-scale spectral features are obtained. , where low-level fusion , , The dimensions are , , .
[0066] Step 6.2: The attention module consists of fully connected layers, an element-wise addition layer, an adaptive compression layer, The excitation layer activation function SoftMax layer, element-wise multiplication layers;
[0067] Step 6.2.1: In the input attention module, Fully connected layer pairs After unified dimension processing, we get Low-grade fusion characteristics of tea ; thus obtaining The same dimensions of tea low-level fusion integration characteristics ;
[0068] In this embodiment, the fully connected layer , , After unified dimension processing, the integrated features with the same three dimensions are obtained. , , .
[0069] Step 6.2.2: Input into the element-by-element addition layer for processing to obtain the low-level fusion addition features of tea leaves In this embodiment, the element-by-element addition layer is processed to obtain the added feature , the dimension is .
[0070] Step 6.2.3: Input into the adaptive compression layer for processing to obtain the low-level fusion adaptive compression features of tea leaves ;
[0071] In this embodiment, the adaptive compression layer is processed to obtain the adaptive compression feature , the dimension is ;
[0072] Step 6.2.4: Enter into In the parallel excitation layers, we get Tea low-level fusion excitation characteristics ;in, Indicates Each tea leaves low-grade fusion stimulates characteristics;
[0073] In this embodiment, after three parallel excitation layers, the convolution kernel sizes of the one-dimensional convolution layers in the three parallel excitation layers are all , the step size is 1, the number of convolution kernels is 1, and we get The dimension is .
[0074] Step 6.2.5: Enter to The activation function SoftMax layer is processed to obtain the Low-level fusion normalized features of tea leaves In this embodiment, , , Normalized features are obtained after processing with the SoftMax activation function , , .
[0075] Step 6.2.6: and Enter to The processed element-by-element multiplication layer is used to obtain the processed The characteristics of low-grade fusion of tea leaves , thus obtaining the low-level fusion multiplication feature vector of tea leaves ;
[0076] In this embodiment, , , and , , Perform element-by-element multiplication to obtain the result of the low-level fusion feature vector after passing through the attention module. , , , the dimensions are , , .
[0077] Step 6.3: The prediction module consists of fully connected layers; the input is sent to the prediction module. After the low-level fusion features of each tea are spliced, they are expanded into a one-dimensional feature vector according to the channel dimension and input into the fully connected layer for dimensionality reduction processing to obtain Predicted moisture content ;
[0078] Step 6.4: Follow the process of steps 6.2 to 6.3 to Processing to obtain Predicted moisture content ;
[0079] In this embodiment, the dimension of the intermediate fused spectral feature vector after passing through the Conv module is , , The dimension of the intermediate fusion multiplication feature vector of tea leaves after the attention module is , , .
[0080] Step 7: Right and Take the weighted average to get the predicted moisture content mean ;in express The corresponding weight, express Corresponding weights; in this embodiment, .
[0081] Step 8: Based on and Constructing the mean square error loss function ;
[0082] Step 9: Fusion dataset based on tea atlas , use the sgdm optimizer to train the tea moisture content prediction network and calculate the mean square error loss function To update the network parameters until the mean square error loss function The training process continues until convergence, thus obtaining a trained tea moisture content regression model and using it on the ZYNQ development board for regression prediction of tea moisture content.
[0083] In this embodiment, the mean square error loss function . Transplant this model to the ZYNQ development board. The specific implementation plan is as follows Figure 4As shown. First, the quantized weight file is stored in the ROM of the FPGA, and the spectral data is transmitted to the ZYNQ processing system module. The DDR storage module receives and stores the near-infrared spectral data, and the ARM processor completes the DDR read and write operations through a cyclic read and write state machine. The ARM processor module uses the Softmax operation to calculate the spectral features, obtain the moisture content of the tea, generate a distribution map and transmit it to the HDMI display for display.
[0084] In this embodiment, an electronic device includes a memory and a processor, wherein the memory is used to store a program that supports the processor to execute the above method, and the processor is configured to execute the program stored in the memory.
[0085] In this embodiment, a computer-readable storage medium stores a computer program on the computer-readable storage medium, and the computer program executes the steps of the above method when executed by a processor.
Claims
1. A method for detecting moisture content of tea leaves based on spectral fusion and convolutional neural network, characterized in that: The steps are as follows: Step 1: Construct a tea atlas fusion dataset ,in, represents the tea spectral feature dataset; represents the tea texture feature dataset; the atlas fusion data of any tea sample is recorded as , where t represents the spectral feature vector of the tea sample, where: Indicates Spectral response of each band; Indicates the number of bands; represents the texture feature vector of the tea sample, where: Indicates Texture feature values; Represents the number of texture features; let the actual moisture content of the tea sample be ; Step 2: Calculate the standardized Texture Features , thus obtaining the standardized texture feature vector ,in, is the mean value of the texture characteristics of the tea sample, is the standard deviation of the texture characteristics of the tea sample; Step 3: and Perform fusion of different feature levels to obtain low-level fused tea feature vectors and the intermediate fusion tea feature vector ; Step 4: Right Correction is performed to obtain the corrected low-level fusion feature vector ,in, Indicates A corrected low-grade fusion characteristic of tea leaves; Step 5: Follow the process from step 4.1 to step 4.3 to Processing is performed to obtain the corrected intermediate fusion feature vector ,in, Indicates A corrected mid-level blend of tea characteristics; Step 6: Construct a tea moisture content prediction network, including Conv module, attention module and prediction module, and and Processing, the corresponding Predicted moisture content and Predicted moisture content ; Step 7: Right and Take the weighted average to get the predicted moisture content mean ;in, The corresponding weights, express The corresponding weights; Step 8: Based on and Constructing the mean square error loss function ; Step 9: Fusion dataset based on tea atlas , use the sgdm optimizer to train the tea moisture content prediction network and calculate the mean square error loss function To update the network parameters until the mean square error loss function The training process continues until convergence, thus obtaining a trained tea moisture content regression model and using it on the ZYNQ development board for regression prediction of tea moisture content.
2. A method for detecting tea moisture content based on spectral fusion and convolutional neural network according to claim 1, characterized in that: Step 3 is performed as follows: Step 3.1: and After splicing, we get the low-level fused tea feature vector ;in, Indicates A low-grade blend of tea characteristics; represents the number of features after low-level fusion; and ; Step 3.2: Use SPA algorithm to and Perform feature screening to obtain the filtered spectral feature vector And the filtered texture feature vector ,in, After filtering Spectral characteristics of each band; Indicates the number of spectral features after screening; After filtering Texture values; Indicates the number of texture features after screening; Step 3.3: and After splicing, we get the intermediate fusion tea feature vector ,in, Indicates A mid-level blend of tea characteristics; represents the number of features after low-level fusion; and .
3. The method for detecting moisture content of tea leaves based on spectral fusion and convolutional neural network according to claim 1, characterized in that: Step 4 is performed as follows: Step 4.1: Calculate the feature mean of low-level fusion ; Step 4.2: Build Linear regression equation ,in, For the The baseline offset, For the Baseline shift amount; Step 4.3: Calculate the corrected Low-level fusion features .
4. The method for detecting moisture content of tea leaves based on spectral fusion and convolutional neural network according to claim 1, characterized in that: Step 6 is performed as follows: Step 6.1: Input into the Conv module and pass through After processing by parallel convolution units, the spectral feature vector is obtained. ,in, Representative The spectral features output by parallel convolution units; Step 6.2: The attention module consists of fully connected layers, an element-wise addition layer, an adaptive compression layer, The excitation layer activation function SoftMax layer, element-wise multiplication layers, and Processing is performed to obtain the low-level fusion multiplication feature vector of tea leaves ; Step 6.3: The prediction module consists of It consists of fully connected layers; Will After the low-level fusion features of each tea are spliced, they are expanded into a one-dimensional feature vector according to the channel dimension and input We perform dimensionality reduction in the fully connected layers and obtain Predicted moisture content ; Step 6.4: Follow the process from step 6.2 to step 6.3 to Processing to obtain Predicted moisture content .
5. A method for detecting tea moisture content based on spectral fusion and convolutional neural network according to claim 4, characterized in that: Step 6.2 is performed as follows: Step 6.2.1: Input into the attention module, Fully connected layer pairs After unified dimension processing, we get Low-grade fusion characteristics of tea ; thus obtaining The same low-level fusion and integration characteristics of tea leaves ; Step 6.2.2: Input into the element-by-element addition layer for processing to obtain the low-level fusion addition features of tea leaves ; Step 6.2.3: Input into the adaptive compression layer for processing to obtain the low-level fusion adaptive compression features of tea leaves ; Step 6.2.4: Enter into In the parallel excitation layers, we get Tea low-level fusion excitation characteristics ;in, Indicates Each tea leaves low-grade fusion stimulates characteristics; Step 6.2.5: Enter to The activation function SoftMax layer is processed to obtain the Low-level fusion normalized features of tea leaves ; Step 6.2.6: and Enter to The processed element-by-element multiplication layer is used to obtain the processed The characteristics of low-grade fusion of tea leaves , thus obtaining the low-level fusion multiplication feature vector of tea leaves .
6. An electronic device, comprising a memory and a processor, characterized in that: The memory is used to store a program that supports the processor to execute the tea moisture content detection method described in any one of claims 1-5, and the processor is configured to execute the program stored in the memory.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the tea moisture content detection method according to any one of claims 1 to 5 are executed.
Citation Information
Patent Citations
Online detection method for moisture content of tea leaves
CN117368121A
Black tea withering moisture content detection method based on spectrogram feature fusion
CN118212187A
Tea raw material moisture content detection model construction method, system, equipment and medium
CN118794920A
Coal rock carbon content detection method and system based on multi-feature image spectrum technology
CN119151936A
RGB-t multispectral pedestrian detection method based on target perception fusion policy
WO2024197762A1