Intelligent judgment method for tea category and grade based on multi-feature selective interaction
By employing a multi-feature selective interaction method, combined with multi-color space preprocessing and a multi-feature selective interaction classification network, the subjectivity and accuracy issues in tea classification and quality grading were resolved. This enabled automated and standardized detection of tea categories and grades, improving the accuracy and stability of the detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ANHUI AGRICULTURAL UNIVERSITY
- Filing Date
- 2026-05-18
- Publication Date
- 2026-06-26
Smart Images

Figure CN122289818A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of artificial intelligence technology, specifically a method for intelligently judging tea category and grade based on multi-feature selective interaction. Background Technology
[0002] The appearance, color, and texture of tea leaves are core criteria for judging their category, quality grade, and commercial value. Therefore, research on non-destructive intelligent detection technology for tea appearance is of significant practical importance. Current technologies primarily rely on sensory evaluation by professionals for tea classification and quality grading, which suffers from high subjectivity, low efficiency, inconsistent standards, and susceptibility to environmental and experiential influences, making it difficult to meet the demands of large-scale, standardized production. While deep learning models often use a single image as input and extract high-level semantic features through a backbone network for classification, they perform well in broad category recognition but lack the ability to represent subtle differences in tea leaves and have limited accuracy in distinguishing similar categories or different grades of tea. Furthermore, some methods directly concatenate high-level semantic features with low-level texture features, easily leading to feature redundancy, information interference, and insufficient fusion, affecting the stability of the final classification. In addition, common classification models often rely on a single fully connected layer or a simple classifier, which has weak fitting ability for high-dimensional, heterogeneous fusion features, making it difficult to achieve accurate identification of tea appearance. Summary of the Invention
[0003] This invention addresses the shortcomings of existing technologies by proposing an intelligent method for judging tea category and grade based on multi-feature selective interaction. The aim is to achieve automated and standardized detection of tea category and grade, improve detection accuracy and robustness, and adapt to practical application scenarios such as tea production and processing, and quality assessment. This provides reliable technical support for tea quality grading and control, standardized trading, and the construction of an intelligent tea industry quality inspection system.
[0004] To achieve the above-mentioned objectives, the present invention adopts the following technical solution: The intelligent method for judging tea category and grade based on multi-feature selective interaction of the present invention is characterized by the following steps: Step 1: Collect a set of RGB images of tea leaves ,in, Let represent the i-th RGB image of tea leaves, and n represent the total number of RGB images of tea leaves; right After performing median filtering, region of interest cropping, and scaling sequentially, a preprocessed RGB image is obtained and mapped to the HSV and Lab color spaces respectively, resulting in the i-th tea leaf HSV image J. i And the i-th tea leaf Lab image K i ; to I i J i K i After normalization, the V-channel contrast of the normalized tea HSV image is enhanced, and the L-channel contrast of the normalized tea Lab image is enhanced. The normalized RGB image, the V-channel contrast-enhanced tea Lab image, and the L-channel contrast-enhanced tea Lab image are then combined to form the i-th image sample X. i ; make The true classification result is ,in, for The actual classification results of tea varieties for The true classification results of tea grades; Step 2: Construct a multi-feature selective interaction classification network, including: a deep image semantic feature extraction module CP-ResNet50, a color-texture low-level feature extraction module CTFEM, a feature alignment module FCM, a selective interaction module SIM, and a random forest ensemble learning classification module RF, and sequentially apply these to X. i Processing yields X i Predicted classification results ;in, for The predicted classification results of tea varieties for Tea grade prediction and classification results; Step 2.1: The deep image semantic feature extraction module CP-ResNet50 consists of ResNet50 backbone network units, CBAM attention units, PANet feature aggregation units, and feature fusion layers, and extracts features from X. i The i-th deep semantic feature F is obtained through processing. R,i ; Step 2.2: The Color-Texture Low-Level Feature Extraction Module (CTFEM) consists of a Color Feature Extraction Unit (CM) and a Texture Feature Extraction Unit (TM), and performs I... i J i K i The i-th color texture feature F is obtained through processing. T,i ; Step 2.3: The Feature Alignment Module (FCM) consists of a Track Dimension Alignment Unit (CDA), a Spatial Scale Alignment Unit (SSA), and a Feature Distribution Alignment Unit (FDA), and performs alignment on F... R,i and F T,i After processing, X is obtained. i Initial depth features FCR,i and initial color texture features F CT,i ; Step 2.4: The selective interaction module SIM consists of a layer normalization unit (LN), a dual-branch feature mapping unit (DFU), a bidirectional attention interaction unit (BAU), a residual fusion unit (RFU), and a feature aggregation unit (FAU), and performs F... CR,i and F CT,i Processing yields X i Fusion feature F SIM,i ; Step 2.5: The Random Forest Ensemble Learning Classification Module (RF) applies the fused feature F to the i-th feature. SIM,i Processing yields X i Predicted classification results ; Step 3: Based on the predicted classification results and the actual classification results, construct the multi-task joint loss function using equation (1). This is used to iteratively train a multi-feature selective interactive classification network to obtain a trained multi-category tea detection model, and to classify tea images by category and grade. (1) In equation (1), Cross-entropy loss for tea category classification, Cross-entropy loss for tea grading These are the weighting coefficients.
[0005] The intelligent method for judging tea category and grade based on multi-feature selective interaction described in this invention is also characterized in that step 2.1 includes: Step 2.1.1: The ResNet50 backbone network unit consists of a conv1 convolutional layer, a BN1 batch normalization layer, a ReLU activation layer, a MaxPool max pooling layer, and K residual stages (RS). The conv1 convolutional layer, BN1 batch normalization layer, ReLU activation layer, and MaxPool max pooling layer sequentially apply X... i After processing, X is obtained. i shallow features XF i ; XF i The data are input into K residual stages (RS) for processing, resulting in k preliminary depth features. ,in, This represents the initial depth feature of the RS output in the k-th residual stage; Step 2.1.2: The CBAM attention unit consists of channel attention (CAM) and spatial attention (SAM); When k=1, Directly used as the k-th spatial feature ; When k=2,3,…,K, The input is processed in the CBAM attention unit to obtain the k-th channel feature. Then, after processing by Spatial Attention (SAM), the k-th spatial feature is obtained. Thus, the i-th multi-scale depth feature MX is composed of K spatial features. i ; Step 2.1.3: The PANet feature aggregation unit consists of an FPN backbone, N upsampling layers (US), N downsampling layers (DS), and a feature fusion layer, and performs MX... i The process is performed to obtain the i-th fused feature set. ; Step 2.1.3.1, MX i The input is fed into the FPN backbone for processing to obtain... Multi-scale upsampling features ;in, express The upsampled feature at the nth scale; Step 2.1.3.2: When n=N, Directly used as the nth layer fusion feature from top to bottom ; When n = n-1, ..., 2, 1, the features of the (n+1)th layer are fused. The input is amplified in the nth upsampling layer US, so that... and After the dimensions are consistent, then... By adding elements one by one, we obtain the nth layer of fused features from top to bottom. Thus, the i-th fusion feature set is obtained from top to bottom. ; Step 2.1.3.3: When n=1, fuse the lowest level features. Directly used as the nth layer fusion feature from the bottom up ; When n=2,3,…,n-1, the features of the (n-1)th layer will be fused. The size is reduced in the input of the nth downsampling layer DS, so that and After the dimensions are consistent, then... By adding elements one by one, we obtain the nth layer of fused features from the bottom up. Thus, the i-th fusion feature set is obtained from the bottom up. ; Step 2.1.4, Feature fusion layer Processing is performed to obtain the i-th deep feature vector F. R,i .
[0006] Furthermore, step 2.2 includes: Step 2.2.1, the color feature extraction unit CM extracts from I... i Extract the mean values of the red channel, green channel, blue channel, hue, saturation, brightness, lightness channel, red-green difference, and yellow-blue difference, and construct the i-th color feature XF. C,i ; Step 2.2.2: The texture feature extraction unit TM extracts I... i J i K i Gradient normalization and grayscale normalization are performed, resulting in three gradient images and three grayscale images. These are used to calculate small gradient dominance, large gradient dominance, grayscale distribution non-uniformity, gradient distribution non-uniformity, energy, grayscale mean, gradient mean, grayscale standard deviation, gradient standard deviation, correlation, grayscale entropy, gradient entropy, mixing entropy, difference moment, and inverse difference moment, which together form the i-th texture feature XF. T,i .
[0007] Step 2.2.3, XF C,i With XF T,i The i-th color texture feature vector F is formed by concatenating the vectors along the channel dimension. T,i ; Furthermore, step 2.3 includes: Step 2.3.1: The Channel Dimension Alignment Unit (CDA) uses a 1×1 convolutional layer and a fully connected layer to align the F... R,i and F T,i Mapped to the same hidden dimension, corresponding to the channel-aligned depth channel features. and color texture channel features ; Step 2.3.2, Spatial Scale Alignment Unit (SSA) Pair and Perform global average pooling operations separately to obtain spatially aligned depth-scale features. and color texture scale features ; Step 2.3.3, Feature Distribution Alignment Unit FDA respectively for and After normalizing the mean and variance distributions, the initial depth feature vector F is obtained. CR,i and the initial color texture feature vector F CT,i .
[0008] Furthermore, step 2.4 includes: Step 2.4.1, the layer normalization unit LN respectively applies F CR,i and F CT,i After performing distribution normalization, the corresponding normalized depth feature vector F is obtained. R,i−LN and color texture feature vector F T,i−LN ; Step 2.4.2: The Dual-Branch Feature Mapping Unit (DFU) consists of three parallel sets of 1×1 convolutional layers, 3×3 depthwise separable convolutional layers, and reshape dimension-reconstructing layers, and respectively applies F... R,i−LN After processing, the deep semantic query vector R is obtained. Q Deep semantic key vector R K With the deep semantic value vector R V ; Dual-branch feature mapping unit (DFU) for F T,i−LN After processing, the color texture query vector T is obtained. Q Color texture key vector T K With color texture value vector T V ; Step 2.4.3: The Bidirectional Attention Interaction Unit (BAU) will... Q With T K After performing the dot product operation, the relevance matrix is obtained. Then, it undergoes masking, Top-k sparsification, dimension mapping, and Softmax normalization to obtain the attention weights. These attention weights are then compared with T... V After weighted summation, the interaction features F of the depth-guided texture are obtained. RT,i ; Bidirectional attention interaction unit (BAU) for R K With T Q R V After performing the same processing, the interactive feature F of texture-guided depth is obtained. TR,i ; Step 2.4.4: The Residual Fusion Unit (RFU) consists of a Reshape dimension reshaping layer, a 1×1 convolutional layer, and a residual addition structure. The F... RT,i After processing by the Reshape dimension reshaping layer and the 1×1 convolutional layer, and F CT,i The residuals are summed to obtain the color texture enhancement feature F. T′,i ; F TR,i After processing by the Reshape dimension reshaping layer and the 1×1 convolutional layer, and F CR,i The depth enhancement feature F is obtained by summing the residuals. R′,i ; Step 2.4.5, F T′,i and F R′,i The input feature aggregation layer FAU performs channel merging processing to obtain the fused feature F output by the SIM module. SIM,i .
[0009] The present invention provides an electronic device, including a memory and a processor, characterized in that the memory is used to store a program supporting the processor in performing the method described therein, and the processor is configured to execute the program stored in the memory.
[0010] The present invention discloses a computer-readable storage medium storing a computer program, characterized in that the computer program is executed by a processor to perform the steps of the method described thereon.
[0011] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This invention adopts a parallel preprocessing architecture of RGB, HSV, and Lab multi-color spaces, which overcomes the shortcomings of existing technologies that rely on single-channel image input, are susceptible to uneven lighting, and are affected by changes in shooting angle and color deviation. It provides multi-dimensional information input that takes into account global shape, hue saturation, and brightness details for subsequent multi-feature extraction, effectively improving the comprehensiveness and anti-interference ability of tea feature representation, and laying the foundation for subsequent high-precision detection.
[0012] 2. This invention constructs a complementary dual-feature system by using a deep semantic extraction module and a low-level color and texture feature extraction module. The former captures high-level semantic information such as the overall shape of the tea leaves, while the latter depicts detailed quality features such as color differences and texture roughness. This solves the shortcomings of traditional single-feature methods in distinguishing between similar-looking categories and subtle grade differences, and realizes the complete expression of the global structure and local details of tea quality features.
[0013] 3. This invention eliminates semantic and dimensional differences between two features through a feature alignment module, and then achieves selective interaction of key features through the bidirectional Top-k sparse attention mechanism of the selective interaction module. This not only solves the problems of weak information complementarity and high global attention computation overhead in traditional simple splicing fusion, but also actively shields background noise and invalid regions, focusing on the core quality feature regions of tea, thus achieving efficient complementary fusion of two features and significantly improving feature expression ability and detection efficiency.
[0014] 4. This invention adopts a random forest ensemble learning classification module and an end-to-end joint loss supervision mechanism to overcome the defects of single deep learning classifiers, such as easy overfitting and insufficient generalization ability. By setting weights for categories and grades through the joint loss function, the coordinated optimization of multi-task classification is achieved, thereby improving the stability and robustness of tea category identification and grade classification results. Attached Figure Description
[0015] Figure 1 This is a structural diagram of the network of the present invention; Figure 2 This is a diagram of the selective interaction module in the network of the present invention. Detailed Implementation
[0016] In this embodiment, to overcome the drawbacks of traditional manual evaluation, such as strong subjectivity, low efficiency, and difficulty in unifying evaluation standards, and to address the industry pain points of existing deep learning detection methods being easily affected by background redundancy and having difficulty accurately distinguishing between similar categories and subtle grade differences, an intelligent method for judging tea category and grade based on multi-feature selective interaction is proposed, which proceeds as follows: Step 1: Collect a set of RGB images of tea leaves ,in, Let represent the i-th RGB image of tea leaves, and n represent the total number of RGB images of tea leaves; right After performing median filtering, region of interest cropping, and scaling sequentially, a preprocessed RGB image is obtained and mapped to the HSV and Lab color spaces respectively, resulting in the i-th tea leaf HSV image J. i And the i-th tea leaf Lab image K i .
[0017] to I i J i K i After normalization, the V-channel contrast of the normalized tea HSV image is enhanced, and the L-channel contrast of the normalized tea Lab image is enhanced. The normalized RGB image, the V-channel contrast-enhanced tea Lab image, and the L-channel contrast-enhanced tea Lab image are then combined to form the i-th image sample X. i ; make The true classification result is ,in, for The actual classification results of tea varieties for The true classification results of tea grades.
[0018] By using complementary input in multiple color spaces, we can cover the multi-dimensional representation of tea appearance, color, and texture, enhance the anti-interference ability of input data, and lay the data foundation for subsequent high-precision feature extraction and fusion.
[0019] Step 2: Construct a multi-feature selective interactive classification network, such as... Figure 1The corresponding network structure diagram is shown, including: the deep image semantic feature extraction module CP-ResNet50, the color-texture low-level feature extraction module CTFEM, the feature alignment module FCM, the selective interaction module SIM, and the random forest ensemble learning classification module RF, and then sequentially applying X... i Processing yields X i Predicted classification results ;in, for The predicted classification results of tea varieties for The predicted classification results of tea grades.
[0020] Step 2.1: The deep image semantic feature extraction module CP-ResNet50 consists of ResNet50 backbone network units, CBAM attention units, PANet feature aggregation units, and feature fusion layers, and extracts features from X. i The i-th deep semantic feature F is obtained through processing. R,i .
[0021] Step 2.1.1: The ResNet50 backbone network unit consists of conv1 convolutional layers, BN1 batch normalization layers, ReLU activation layers, MaxPool max pooling layers, and K residual stages (RS). The conv1 convolutional layers, BN1 batch normalization layers, ReLU activation layers, and MaxPool max pooling layers sequentially apply X... i After processing, X is obtained. i shallow features XF i ; XF i The data are input into K residual stages (RS) for processing, resulting in k preliminary depth features. ,in, This represents the initial depth feature of the RS output in the k-th residual stage.
[0022] Step 2.1.2: The CBAM attention unit consists of channel attention (CAM) and spatial attention (SAM); When k=1, Directly used as the k-th spatial feature ; When k=2,3,…,K, The input is processed in the CBAM attention unit to obtain the k-th channel feature. Then, after processing by Spatial Attention (SAM), the k-th spatial feature is obtained. Thus, the i-th multi-scale depth feature MX is composed of K spatial features. iThe model incorporates the CBAM attention mechanism, which simultaneously enhances the key features of the tea leaves from both channel and spatial dimensions, suppresses background and useless channel noise, improves the model's resistance to interference from lighting and complex backgrounds, and enhances its ability to represent subtle differences.
[0023] Step 2.1.3: The PANet feature aggregation unit consists of an FPN backbone, N upsampling layers (US), N downsampling layers (DS), and a feature fusion layer, and performs MX... i The process is performed to obtain the i-th fused feature set. ; Step 2.1.3.1, MX i The input is fed into the FPN backbone for processing to obtain... Multi-scale upsampling features ;in, express The upsampled features at the nth scale.
[0024] Step 2.1.3.2: When n=N, Directly used as the nth layer fusion feature from top to bottom ; When n = n-1, ..., 2, 1, the features of the (n+1)th layer are fused. The input is amplified in the nth upsampling layer US, so that... and After the dimensions are consistent, then... By adding elements one by one, we obtain the nth layer of fused features from top to bottom. Thus, the i-th fusion feature set is obtained from top to bottom. .
[0025] Step 2.1.3.3: When n=1, fuse the lowest level features. Directly used as the nth layer fusion feature from the bottom up ; When n=2,3,…,n-1, the features of the (n-1)th layer will be fused. The size is reduced in the input of the nth downsampling layer DS, so that and After the dimensions are consistent, then... By adding elements one by one, we obtain the nth layer of fused features from the bottom up. Thus, the i-th fusion feature set is obtained from the bottom up. The introduction of PANet multi-scale pyramid fusion, which integrates multi-scale features from high and low layers of the network, can take into account both the small-scale local details of tea leaves and the overall morphological semantics of tea leaves at a large scale, thus making up for the lack of single-scale feature information.
[0026] Step 2.1.4, Feature fusion layer Processing is performed to obtain the i-th deep feature vector F. R,i .
[0027] Step 2.2: The Color-Texture Low-Level Feature Extraction Module (CTFEM) consists of a Color Feature Extraction Unit (CM) and a Texture Feature Extraction Unit (TM), and performs I... i J i K i The i-th color texture feature F is obtained through processing. T,i .
[0028] Step 2.2.1, Color Feature Extraction Unit CM from I i Extract the mean values of the red channel, green channel, blue channel, hue, saturation, brightness, lightness channel, red-green difference, and yellow-blue difference, and construct the i-th color feature XF. C,i .
[0029] Step 2.2.2: The texture feature extraction unit TM extracts I... i J i K i Gradient normalization and grayscale normalization are performed, resulting in three gradient images and three grayscale images. These are used to calculate small gradient dominance, large gradient dominance, grayscale distribution non-uniformity, gradient distribution non-uniformity, energy, grayscale mean, gradient mean, grayscale standard deviation, gradient standard deviation, correlation, grayscale entropy, gradient entropy, mixing entropy, difference moment, and inverse difference moment, which together form the i-th texture feature XF. T,i ; Step 2.2.3, XF C,i With XF T,i The i-th color texture feature vector F is formed by concatenating the vectors along the channel dimension. T,i .
[0030] Step 2.3: The Feature Alignment Module (FCM) consists of a Track Dimension Alignment Unit (CDA), a Spatial Scale Alignment Unit (SSA), and a Feature Distribution Alignment Unit (FDA), and performs alignment on F... R,i and F T,i After processing, the initial depth features F of Xi are obtained accordingly. CR,i and initial color texture features F CT,i .
[0031] Step 2.3.1: The Channel Dimension Alignment Unit (CDA) uses a 1×1 convolutional layer and a fully connected layer to align the F... R,i and F T,i Mapped to the same hidden dimension, corresponding to the channel-aligned depth channel features. and color texture channel features ; Step 2.3.2, Spatial Scale Alignment Unit (SSA) Pair and Perform global average pooling operations separately to obtain spatially aligned depth-scale features. and color texture scale features .
[0032] Step 2.3.3, Feature Distribution Alignment Unit FDA respectively for and After normalizing the mean and variance distributions, the initial depth feature vector F is obtained. CR,i and the initial color texture feature vector F CT,i .
[0033] Step 2.4: The Selective Interaction Module (SIM) consists of a Layer Normalization Unit (LN), a Two-Branch Feature Mapping Unit (DFU), a Bidirectional Attention Interaction Unit (BAU), a Residual Fusion Unit (RFU), and a Feature Aggregation Unit (FAU), as follows: Figure 2 The corresponding network structure diagram is shown, and F is discussed. CR,i and F CT,i Processing yields X i Fusion feature F SIM,i .
[0034] Step 2.4.1, the layer normalization unit LN respectively applies F CR,i and F CT,i After performing distribution normalization, the corresponding normalized depth feature vector F is obtained. R,i−LN and color texture feature vector F T,i−LN ; Step 2.4.2: The Dual-Branch Feature Mapping Unit (DFU) consists of three parallel sets of 1×1 convolutional layers, 3×3 depthwise separable convolutional layers, and reshape dimension-reconstructing layers, and respectively applies F... R,i−LN After processing, the deep semantic query vector R is obtained. Q Deep semantic key vector R K With the deep semantic value vector R V .
[0035] Dual-branch feature mapping unit (DFU) for F T,i−LN After processing, the color texture query vector T is obtained. Q Color texture key vector T K With color texture value vector T V ; Step 2.4.3: The Bidirectional Attention Interaction Unit (BAU) will... Q With T KAfter performing the dot product operation, the relevance matrix is obtained. Then, it undergoes masking, Top-k sparsification, dimension mapping, and Softmax normalization to obtain the attention weights. These attention weights are then compared with T... V After weighted summation, the interaction features F of the depth-guided texture are obtained. RT,i ; Bidirectional attention interaction unit (BAU) for R K With T Q R V After performing the same processing, the interactive feature F of texture-guided depth is obtained. TR,i .
[0036] Step 2.4.4: The Residual Fusion Unit (RFU) consists of a Reshape dimension reshaping layer, a 1×1 convolutional layer, and a residual addition structure. The F... RT,i After processing by the Reshape dimension reshaping layer and the 1×1 convolutional layer, and F CT,i The residuals are summed to obtain the color texture enhancement feature F. T′,i ; F TR,i After processing by the Reshape dimension reshaping layer and the 1×1 convolutional layer, and F CR,i The depth enhancement feature F is obtained by summing the residuals. R′,i .
[0037] Step 2.4.5, F T′,i and F R′,i The input feature aggregation layer FAU performs channel merging processing to obtain the fused feature F output by the SIM module. SIM,i .
[0038] Alignment before interaction eliminates semantic and dimensional gaps between multiple features; bidirectional sparse attention replaces global interaction, significantly reducing computation while achieving bidirectional complementary enhancement of deep semantic features and color and texture features, thus improving detection accuracy.
[0039] Step 2.5: Random Forest Ensemble Learning Classification Module RF applies the fusion feature F to the i-th feature. SIM,i Processing yields X i Predicted classification results .
[0040] Step 3: Based on the predicted classification results and the actual classification results, construct the multi-task joint loss function using equations (1), (2), and (3). This is used to iteratively train a multi-feature selective interactive classification network to obtain a trained multi-category tea detection model, and to classify tea images by category and grade. (1) (2) (3) In equations (1), (2), and (3), Cross-entropy loss for tea category classification, Cross-entropy loss for tea grading Here, N represents the weighting coefficients; N is the total number of samples in a training batch. This represents the number of tea categories. Here, k represents the number of tea grade categories, and k is the category index. , These are the actual category and grade labels for the i-th sample, respectively. , Let be the predicted probabilities of the i-th sample in the k-th category and grade, respectively. Cross-entropy loss is chosen as the loss function for category and grade classification. This loss function has stable gradient propagation and is not prone to gradient vanishing problems. It can effectively constrain the differences in the distribution of multi-class features and is also convenient for constructing a dual-task weighted joint loss.
[0041] By constructing a joint loss function, the entire process can be jointly optimized, enabling the parameters of each module to adapt to each other and work together. Appropriate weights can be set for tea category classification and grade grading to ensure the accuracy of category and grade classification, while constraining the rationality of feature distribution, effectively suppressing overfitting, and improving the training ability of the model and the stability and robustness of the results.
[0042] In this embodiment, an electronic device includes a memory and a processor. The memory stores a program that supports the processor in executing the above-described method, and the processor is configured to execute the program stored in the memory.
[0043] In this embodiment, a computer-readable storage medium stores a computer program, which is executed by a processor to perform the steps of the above method.
Claims
1. An intelligent method for determining tea category and grade based on multi-feature selective interaction, characterized in that, The procedure is as follows: Step 1: Collect a set of RGB images of tea leaves ,in, Let represent the i-th RGB image of tea leaves, and n represent the total number of RGB images of tea leaves. right After performing median filtering, region of interest cropping, and scaling in sequence, the preprocessed RGB image is obtained and mapped to the HSV and Lab color spaces respectively, thus obtaining the i-th tea leaf HSV image J. i And the i-th tea leaf Lab image K i ; I i , J i , K i After normalization, the normalized tea HSV image is subjected to V channel contrast enhancement, and the normalized tea Lab image is subjected to L channel contrast enhancement, so that the normalized RGB image, the tea Lab image subjected to V channel contrast enhancement, and the tea Lab image subjected to L channel contrast enhancement together constitute the i-th image sample X i ; make The true classification result is ,in, for The actual classification results of tea varieties for The true classification results of tea grades; Step 2: Construct a multi-feature selective interaction classification network, including: a deep image semantic feature extraction module CP-ResNet50, a color-texture low-level feature extraction module CTFEM, a feature alignment module FCM, a selective interaction module SIM, and a random forest ensemble learning classification module RF, and sequentially apply these to X. i Processing yields X i Predicted classification results ;in, for The predicted classification results of tea varieties for Tea grade prediction and classification results; Step 2.1: The deep image semantic feature extraction module CP-ResNet50 consists of ResNet50 backbone network units, CBAM attention units, PANet feature aggregation units, and feature fusion layers, and extracts features from X. i The i-th deep semantic feature F is obtained through processing. R,i ; Step 2.2: The Color-Texture Low-Level Feature Extraction Module (CTFEM) consists of a Color Feature Extraction Unit (CM) and a Texture Feature Extraction Unit (TM), and performs I... i J i K i The i-th color texture feature F is obtained through processing. T,i ; Step 2.3: The Feature Alignment Module (FCM) consists of a Track Dimension Alignment Unit (CDA), a Spatial Scale Alignment Unit (SSA), and a Feature Distribution Alignment Unit (FDA), and performs alignment on F... R,i and F T,i After processing, X is obtained. i Initial depth features F CR,i and initial color texture features F CT,i ; Step 2.4: The selective interaction module SIM consists of a layer normalization unit (LN), a dual-branch feature mapping unit (DFU), a bidirectional attention interaction unit (BAU), a residual fusion unit (RFU), and a feature aggregation unit (FAU), and performs F... CR,i and F CT,i Processing yields X i Fusion feature F SIM,i ; Step 2.5: The Random Forest Ensemble Learning Classification Module (RF) applies the fused feature F to the i-th feature. SIM,i Processing yields X i Predicted classification results ; Step 3: Based on the predicted classification results and the actual classification results, construct the multi-task joint loss function using equation (1). This is used to iteratively train a multi-feature selective interactive classification network to obtain a trained multi-category tea detection model, and to classify tea images by category and grade. (1) In equation (1), Cross-entropy loss for tea category classification, Cross-entropy loss for tea grading These are the weighting coefficients.
2. The intelligent method for determining tea category and grade based on multi-feature selective interaction according to claim 1, characterized in that, Step 2.1 includes: Step 2.1.1: The ResNet50 backbone network unit consists of a conv1 convolutional layer, a BN1 batch normalization layer, a ReLU activation layer, a MaxPool max pooling layer, and K residual stages (RS). The conv1 convolutional layer, BN1 batch normalization layer, ReLU activation layer, and MaxPool max pooling layer sequentially apply X... i After processing, X is obtained. i shallow features XF i ; XF i The data are input into K residual stages (RS) for processing, resulting in k preliminary depth features. ,in, This represents the initial depth feature of the RS output in the k-th residual stage; Step 2.1.2: The CBAM attention unit consists of channel attention (CAM) and spatial attention (SAM); When k=1, Directly used as the k-th spatial feature ; When k=2,3,…,K, The input is processed in the CBAM attention unit to obtain the k-th channel feature. Then, after processing by Spatial Attention (SAM), the k-th spatial feature is obtained. Thus, the i-th multi-scale depth feature MX is composed of K spatial features. i ; Step 2.1.3: The PANet feature aggregation unit consists of an FPN backbone, N upsampling layers (US), N downsampling layers (DS), and a feature fusion layer, and performs MX... i The process is performed to obtain the i-th fused feature set. ; Step 2.1.3.1, MX i The input is fed into the FPN backbone for processing to obtain... Multi-scale upsampling features ;in, express The upsampled feature at the nth scale; Step 2.1.3.2: When n=N, Directly used as the nth layer fusion feature from top to bottom ; When n = n-1, ..., 2, 1, the features of the (n+1)th layer are fused. The input is amplified in the nth upsampling layer US, so that... and After the dimensions are consistent, then... By adding elements one by one, we obtain the nth layer of fused features from top to bottom. Thus, the i-th fusion feature set is obtained from top to bottom. ; Step 2.1.3.3: When n=1, fuse the lowest level features. Directly used as the nth layer fusion feature from the bottom up ; When n=2,3,…,n-1, the features of the (n-1)th layer will be fused. The size is reduced in the input of the nth downsampling layer DS, so that and After the dimensions are consistent, then... By adding elements one by one, we obtain the nth layer of fused features from the bottom up. Thus, the i-th fusion feature set is obtained from the bottom up. ; Step 2.1.4, Feature fusion layer Processing is performed to obtain the i-th deep feature vector F. R,i .
3. The intelligent judgment method for tea category and grade based on multi-feature selective interaction according to claim 2, characterized in that, Step 2.2 includes: Step 2.2.1, the color feature extraction unit CM extracts from I i Extract the mean values of the red channel, green channel, blue channel, hue, saturation, brightness, lightness channel, red-green difference, and yellow-blue difference, and construct the i-th color feature XF. C,i ; Step 2.2.2: The texture feature extraction unit TM extracts I... i J i K i Gradient normalization and grayscale normalization are performed, resulting in three gradient images and three grayscale images. These are used to calculate small gradient dominance, large gradient dominance, grayscale distribution non-uniformity, gradient distribution non-uniformity, energy, grayscale mean, gradient mean, grayscale standard deviation, gradient standard deviation, correlation, grayscale entropy, gradient entropy, mixing entropy, difference moment, and inverse difference moment, which together form the i-th texture feature XF. T,i ; Step 2.2.3, XF C,i With XF T,i The i-th color texture feature vector F is formed by concatenating the vectors along the channel dimension. T,i .
4. The intelligent method for determining tea category and grade based on multi-feature selective interaction according to claim 3, characterized in that, Step 2.3 includes: Step 2.3.1: The Channel Dimension Alignment Unit (CDA) uses a 1×1 convolutional layer and a fully connected layer to align the F... R,i and F T,i Mapped to the same hidden dimension, corresponding to the channel-aligned depth channel features. and color texture channel features ; Step 2.3.2, Spatial Scale Alignment Unit (SSA) Pair and Perform global average pooling operations separately to obtain spatially aligned depth-scale features. and color texture scale features ; Step 2.3.3, Feature Distribution Alignment Unit FDA respectively for and After normalizing the mean and variance distributions, the initial depth feature vector F is obtained. CR,i and the initial color texture feature vector F CT,i .
5. The intelligent method for determining tea category and grade based on multi-feature selective interaction according to claim 4, characterized in that, Step 2.4 includes: Step 2.4.1, the layer normalization unit LN respectively applies F CR,i and F CT,i After performing distribution normalization, the corresponding normalized depth feature vector F is obtained. R,i−LN and color texture feature vector F T,i−LN ; Step 2.4.2: The Dual-Branch Feature Mapping Unit (DFU) consists of three parallel sets of 1×1 convolutional layers, 3×3 depthwise separable convolutional layers, and reshape dimension-reconstructing layers, and respectively applies F... R,i−LN After processing, the deep semantic query vector R is obtained. Q Deep semantic key vector R K With the deep semantic value vector R V ; Dual-branch feature mapping unit (DFU) for F T,i−LN After processing, the color texture query vector T is obtained. Q Color texture key vector T K With color texture value vector T V ; Step 2.4.3: The Bidirectional Attention Interaction Unit (BAU) will... Q With T K After performing the dot product operation, the relevance matrix is obtained. Then, it undergoes masking, Top-k sparsification, dimension mapping, and Softmax normalization to obtain the attention weights. These attention weights are then compared with T... V After weighted summation, the interaction features F of the depth-guided texture are obtained. RT,i ; Bidirectional attention interaction unit (BAU) for R K With T Q R V After performing the same processing, the interactive feature F of texture-guided depth is obtained. TR,i ; Step 2.4.4: The Residual Fusion Unit (RFU) consists of a Reshape dimension reshaping layer, a 1×1 convolutional layer, and a residual addition structure. The F... RT,i After processing by the Reshape dimension reshaping layer and the 1×1 convolutional layer, and F CT,i The residuals are summed to obtain the color texture enhancement feature F. T′,i ; F TR,i After processing by the Reshape dimension reshaping layer and the 1×1 convolutional layer, and F CR,i The depth enhancement feature F is obtained by summing the residuals. R′,i ; Step 2.4.5, F T′,i and F R′,i The input feature aggregation layer FAU performs channel merging processing to obtain the fused feature F output by the SIM module. SIM,i .
6. An electronic device, comprising a memory and a processor, characterized in that, The memory is used to store a program that supports a processor in executing the method of any one of claims 1-5, the processor being configured to execute the program stored in the memory.
7. A computer-readable storage medium storing a computer program thereon, characterized in that, The computer program is executed by the processor to perform the steps of the method according to any one of claims 1-5.