A method, equipment and medium for rapid non-destructive testing of amylose in rice
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-07
- Publication Date
- 2026-08-14
AI Technical Summary
[0005]针对现有技术的不足,本发明的目的在于提供一种快速无损检测大米直链淀粉的方法、设备及介质,解决传统化学检测法耗时、高污染及光谱设备昂贵的问题,建立外观图像与内部成分的非线性映射模型,从而实现快速、低成本、绿色的同步检测
1.低成本无损检测:利用低成本的计算机视觉传感器采集大米RGB图像,无需进行研磨、消解等前处理,不破坏样本也无需消耗化学试剂,实现了绿色环保和低成本检测。
Smart Images

Figure CN122567653A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to computer vision and chemical composition analysis technology, and in particular to a method, equipment and medium for rapid and non-destructive detection of amylose in rice. Background Technology
[0002] Rice is one of the world's most important food crops, and its nutritional quality and cooking taste determine its market price and consumer acceptance. The content of amylose is one of the important biochemical indicators for measuring rice quality. Currently, chemical methods such as the iodine colorimetric method are commonly used to detect amylose.
[0003] However, the aforementioned traditional chemical detection methods have many drawbacks: First, the process is cumbersome and time-consuming, requiring complex pretreatment steps such as grinding and digestion; second, it damages the sample, making it non-recoverable after testing; third, it consumes large amounts of chemical reagents, resulting in high costs and environmental pollution; and finally, it requires specialized technical personnel. In recent years, near-infrared spectroscopy (NIRS) has been applied to rice component detection, achieving non-destructive testing, but its expensive and bulky equipment, along with its sensitivity to environmental temperature and humidity, limits its widespread application. Traditional methods cannot meet the demands for on-site, large-scale, low-cost, and non-destructive high-throughput detection.
[0004] Therefore, there is an urgent need for a rapid detection method for amylose in rice based on computer vision and artificial intelligence to solve the problems of time-consuming, highly polluting, and expensive spectroscopic equipment in traditional chemical detection methods, and to achieve low-cost, rapid, green, and high-precision simultaneous non-destructive detection. Summary of the Invention
[0005] To address the shortcomings of existing technologies, the present invention aims to provide a method, equipment, and medium for rapid and non-destructive detection of amylose in rice, solving the problems of time-consuming, highly polluting, and expensive spectroscopic equipment in traditional chemical detection methods. It establishes a non-linear mapping model between appearance images and internal components, thereby achieving rapid, low-cost, and green simultaneous detection.
[0006] In a first aspect, the present invention provides a method for rapid and non-destructive detection of amylose in rice. A multi-task learning model is constructed using a deep convolutional neural network, and the internal amylose content of rice is inferred by analyzing its external optical characteristics. The method includes the following steps: S1: Acquire high-resolution RGB images of rice samples under standard lighting conditions, preprocess the original images including background removal, color correction and region of interest cropping, adjust the image to the model fit size, and obtain the standard rice image tensor. S2: Collect rice samples from different origins and varieties, determine the actual amylose content as a label, and combine it with the collected and preprocessed standard rice image tensor to form a rice image-amylose content database. S3: Construct a multi-task deep learning prediction model, which includes a FasterNet-T2 backbone network, a hierarchical dual-path attention module, and a multi-task regression head; wherein, the hierarchical dual-path attention module is connected to the tail of the backbone network, and is used to receive the basic feature map output by the backbone network and perform high-frequency texture detail compensation extraction to output a refined feature map; the multi-task regression head receives the refined feature map to output the initial prediction value of amylose. S4: Construct a pre-trained, large-capacity FasterNet-L model as the teacher model, and use a knowledge distillation strategy to train the multi-task deep learning prediction model using the rice image-amylose content database to obtain a well-trained target prediction model. S5: Perform structural reparameterization on the hierarchical dual-path attention module in the target prediction model, and then input the tensor of the unknown rice standard image to be tested into the reparameterized target prediction model. Output the predicted value of the amylose content of the rice to be tested through multi-task regression head-to-end.
[0007] As an optional implementation of the first aspect of this application, in step S1, rice is laid flat on a black background board, ensuring that the rice grains do not obscure each other, and an image is acquired using a stereomicroscope; in step S2, the standard rice image tensor and its corresponding real amylose content label data in the constructed rice image-amylose content database are divided into a training set, a validation set, and a test set, with a ratio of 8:1:1; data augmentation techniques such as flipping, brightness adjustment, noise addition, and hue conversion are applied to the training set images to expand the samples, and the enhanced standard rice image tensor is output.
[0008] As an optional implementation of the first aspect of this application, in step S3, the backbone network uses a partial convolution mechanism to extract multi-scale visual features while preserving spatial dimensional information and outputs a basic feature map.
[0009] As an optional implementation of the first aspect of this application, in step S3, the specific data flow processed by the hierarchical dual-path attention module includes: Global context path: receiving the basic feature map output by the backbone network, applying global average pooling to compress the spatial dimension, extracting the macroscopic semi-transparent features of rice and suppressing background noise, and generating global feature weights; Local texture path: receiving the same basic feature map, using max pooling to avoid feature smoothing effects, retaining high-frequency edges and chalky microscopic details, and generating local feature weights; Feature fusion: fusing the global feature weights and local feature weights through broadcast multiplication to obtain fused weights, and applying the fused weights to the original basic feature map to output a refined feature map.
[0010] As an optional implementation of the first aspect of this application, in step S4, a knowledge distillation strategy is used for joint training, the parameters of the teacher model are frozen, and only the parameters of the multi-task deep learning prediction model, which serves as the student model, are updated. The optimization process is carried out through backpropagation iterative calculation using a joint loss function.
[0011] As an optional implementation of the first aspect of this application, in step S4, the joint loss function is obtained by weighted calculation of hard loss term and soft loss term; the hard loss term represents the mean square error between the initial predicted value output by the multi-task deep learning prediction model and the real amylose content label in the database; the soft loss term represents the Kullback-Leibler divergence between the teacher model and the output distribution of the multi-task deep learning prediction model after introducing the softening probability distribution of the temperature parameter; the relative weights of the soft loss term and the hard loss term are balanced using hyperparameters.
[0012] As an optional implementation of the first aspect of this application, in step S4, the Adam optimization algorithm is used as the optimizer for iterative updating of model parameters; the maximum number of training rounds is set to 500 rounds, and the validation set error is monitored through an early stopping mechanism. The tolerance parameter is set to 20 rounds. When the validation set loss no longer decreases within 20 consecutive rounds, the training is terminated early, and the model weights are saved.
[0013] As an optional implementation of the first aspect of this application, in step S5, the process of structural reparameterization specifically includes: during the model training stage, the hierarchical dual-path attention module is internally configured with multi-branch reparameterized convolutions, including 1×1 convolution branches and their corresponding batch normalization layers; during the prediction deployment stage, using the mathematical principle of linear additivity of convolution operations, the 1×1 convolution weights in the parallel convolution branches and the parameters of the batch normalization layers are offline folded and equivalently fused, merging into a single independent convolution layer, and outputting the reparameterized target prediction model, thereby achieving single forward propagation prediction without increasing the amount of additional inference computation.
[0014] In a second aspect, embodiments of this application provide an electronic device, which includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor. When the program or instructions are executed by the processor, they implement the steps of the method described in the first aspect.
[0015] Thirdly, embodiments of this application provide a readable storage medium on which a program or instructions are stored, which, when executed by a processor, implement the steps of the method described in the first aspect.
[0016] Compared with the prior art, the present invention has the following beneficial effects: 1. Low-cost non-destructive testing: Using low-cost computer vision sensors to acquire RGB images of rice, no pre-processing such as grinding or digestion is required. It does not damage the sample and does not consume chemical reagents, achieving green, environmentally friendly and low-cost testing.
[0017] 2. High-precision feature extraction: By introducing a hierarchical dual-path attention module (HDPA), which combines global context and local texture features, the model effectively integrates and compensates for the extraction of micro-textures (such as chalk size and transparency) and macro-features of rice at the tail of the backbone network, significantly improving the model's feature attention.
[0018] 3. Lightweight and efficient deployment: The knowledge distillation strategy is combined to improve the accuracy of the lightweight model, and redundant branches are merged during the deployment phase through structural reparameterization technology. It can achieve efficient real-time prediction from end to end without increasing any inference computation burden, making it extremely suitable for practical applications on portable devices. Attached Figure Description
[0019] Figure 1 This is an overall flowchart of a method for rapid and non-destructive testing of amylose in rice according to an embodiment of the present invention; Figure 2 This is a schematic diagram of the network model architecture of "HDPAFasterNet-T2" and "HDPA Student Model" in an embodiment of the present invention; Figure 3 Scatter plot of training and validation loss of amylose compared with the addition of KD (knowledge distillation) in the embodiments of the present invention; Figure 4 The scatter plot shows the correlation coefficient and root mean square error between the true and predicted values of amylose regression prediction after introducing the hierarchical dual-path attention (HDPA) module in this embodiment of the invention. Figure 5 This is a thermal diagram illustrating the final model after combining HDPA and knowledge distillation (KD) strategies in this embodiment of the invention, comparing it with the base model (FasterNet-Tiny) and the location of interest for truly relevant morphological / texture features in rice trait regression after adding KD (knowledge distillation). Detailed Implementation
[0020] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0021] The terms "first," "second," etc., used in the specification and claims of this application are used to distinguish similar objects and not to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of this application can be implemented in orders other than those illustrated or described herein. Furthermore, in the specification and claims, "and / or" indicates at least one of the connected objects, and the character " / " generally indicates that the preceding and following objects are in an "or" relationship. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified. Example
[0022] Please see Figure 1 This is a flowchart illustrating a rapid, non-destructive method for detecting amylose content in rice, provided by an embodiment of the present invention. A multi-task learning model is constructed using a deep convolutional neural network to infer the internal amylose content of rice by analyzing its external optical characteristics. The method includes the following steps: S1: Acquire high-resolution RGB images of rice samples under standard lighting conditions, preprocess the original images including background removal, color correction and region of interest cropping, adjust the image to the model fit size, and obtain the standard rice image tensor. Image Acquisition and Preprocessing. Rice grains were laid flat on a black background, ensuring no overlap. High-resolution RGB images of the rice samples were acquired using a stereomicroscope under constant light. During acquisition, 30 images were taken for each sample, rotating the sample during each acquisition. The raw images underwent preprocessing, including background removal, color correction, and region of interest (ROI) cropping. The images were resized to fit the model, and a standard rice image tensor was output.
[0023] S2: Collect rice samples from different origins and varieties, determine the actual amylose content as a label, and combine it with the collected and preprocessed standard rice image tensor to form a rice image-amylose content database. Sample library construction and chemical value determination. Sixty rice samples from different origins and varieties (e.g., indica rice, japonica rice, glutinous rice, etc.) were collected. The actual amylose content was determined using chemical methods such as the iodine colorimetric method as label data. The standard rice image tensor and its corresponding actual amylose content label data in the constructed rice image-amylose content database were divided into training, validation, and test sets in a ratio of 8:1:1. The training set was used for optimizing the weight parameters of the deep learning model, the validation set was used to monitor overfitting, and the test set was used to evaluate the model's performance metrics. To reduce the risk of overfitting and improve generalization ability and robustness, data augmentation techniques such as flipping, brightness adjustment, noise addition, and hue conversion were applied to the training set images to augment the standard rice image tensor, outputting the enhanced standard rice image tensor.
[0024] S3: Construct a multi-task deep learning prediction model, which includes a FasterNet-T2 backbone network, a hierarchical dual-path attention module, and a multi-task regression head; wherein, the hierarchical dual-path attention module is connected to the tail of the backbone network, and is used to receive the basic feature map output by the backbone network and perform high-frequency texture detail compensation extraction to output a refined feature map; the multi-task regression head receives the refined feature map to output the initial prediction value of amylose. Model building. Constructing multi-task deep learning prediction models (such as...) Figure 2 As shown in the figure, this model uses the FasterNet-T2 network as the backbone network and utilizes its partial convolution (PConv) mechanism to extract multi-scale visual features while preserving spatial dimensionality information, outputting a basic feature map. To address the problem that traditional lightweight models cannot accurately capture micro-textures and are easily affected by background interference, a hierarchical dual-path attention (HDPA) module is introduced at the end of the backbone network. The specific data flow processed by the hierarchical dual-path attention (HDPA) module includes: (1) Global Context Path: Receives the basic feature maps output by the backbone network. Global average pooling is applied to compress the spatial dimension, extract the macroscopic semi-transparent features of rice and suppress background noise, and generate global feature weights. .
[0025] (2) Local texture path: receives the same base feature map Max pooling is applied to avoid feature smoothing effects, preserve microscopic details such as high-frequency edges and chalkiness, and generate local feature weights. .
[0026] (3) Feature fusion: combining global feature weights and local feature weights Feature fusion is performed using broadcast multiplication to obtain fusion weights, which are then applied to the original base feature map. Output refined feature map The calculation formula is as follows: ,in This indicates broadcast multiplication.
[0027] Finally, the refined feature map is fed into the multi-task regression head to output the initial prediction value.
[0028] S4: Construct a pre-trained, large-capacity FasterNet-L model as the teacher model, and use a knowledge distillation strategy to train the multi-task deep learning prediction model using the rice image-amylose content database to obtain a well-trained target prediction model. Model training. For example... Figures 3 to 5As shown, to overcome the accuracy bottleneck of lightweight models, a knowledge distillation (KD) strategy is adopted for joint training. A pre-trained, high-capacity FasterNet-L model is configured as the teacher model, its parameters are frozen, and only the parameters of the multi-task deep learning prediction model, which serves as the student model, are updated. The optimization process is carried out through backpropagation iterative calculation using the joint loss function.
[0029] Joint loss function From hard loss term and soft loss items Composition, its joint loss function The calculation formula is as follows: Among them, hard loss item This represents the mean squared error between the initial predicted value output by the multi-task deep learning prediction model and the actual amylose content labels in the database; the soft loss term. Indicates the introduction of temperature parameters (set up After softening the probability distribution, the Kullback-Leibler divergence between the output distribution of the teacher model and the multi-task deep learning prediction model is calculated; this is achieved through hyperparameter balancing. The relative weights of the soft loss term and the hard loss term.
[0030] The Adam optimization algorithm is used as the iterative optimizer. The maximum number of training rounds is set to 500. An early stopping mechanism is introduced to monitor the validation set error. The tolerance parameter is set to 20 rounds. If the error does not decrease for 20 consecutive rounds, the model is terminated early and the model weights are saved.
[0031] In addition, indicators such as the coefficient of determination (R²), root mean square error (RMSE), mean absolute error (MAE), and residual prediction bias (RPD) can be used to comprehensively evaluate the model.
[0032] S5: Perform structural reparameterization on the hierarchical dual-path attention module in the target prediction model, and then input the tensor of the unknown rice standard image to be tested into the reparameterized target prediction model. Output the predicted value of the amylose content of the rice to be tested through multi-task regression head-to-end.
[0033] Reparameterization and Prediction Deployment. To achieve fast, non-destructive detection on computationally limited devices, the trained model undergoes structural reparameterization, specifically: During model training, the hierarchical dual-path attention (HDPA) module incorporates multi-branch reparameterized convolution (MBRConv), which includes 1×1 convolution branches and their corresponding batch normalization layers. The calculation formula for its parallel convolution branches is as follows: ,in For 1×1 convolution weights, For bias, For batch normalization processing; During the prediction deployment phase, the linear additivity of convolution operations is utilized to offline fold and equivalently fuse the 1×1 convolution weights in the parallel convolution branch with the batch normalized layer parameters, merging them into a single independent convolutional layer, and outputting the reparameterized target prediction model.
[0034] In practical applications, a brand-new sample of rice is acquired, and after undergoing the same preprocessing steps to generate a standard image tensor, it is directly input into the reparameterized target prediction model. Because the model has already incorporated redundant computational branches at the mathematical level, this standard image tensor completes a single forward propagation extremely quickly without adding any extra inference computation. Through a multi-task regression head, the predicted amylose content of the rice sample is directly output end-to-end.
[0035] For example, we selected six types of rice for verification. The rice samples were laid flat on a background board, and RGB images of the rice samples were acquired using a mobile device camera or an external microscope lens. The captured rice images were then imported into the detection system. The system automatically removed the background and resampled the size of the input RGB images, converting them into a standard rice image tensor adapted to the model. The system then input the standard rice image tensor into a locally deployed, reparameterized target prediction model. The model used a simplified single-layer fusion convolution and regression head for rapid forward inference calculations. This process did not require network connectivity or cloud computing power support. Finally, the predicted values were obtained, and the detection was completed. Specific data are shown in Table 1.
[0036] Table 1. Comparison of Actual and Predicted Values of Amylose in Various Standard Rice Samples
[0037] Optionally, embodiments of this application also provide an electronic device, including a processor, a memory, and a program or instructions stored in the memory and executable on the processor. When the program or instructions are executed by the processor, they implement the various processes of the above-described method embodiment for rapid and non-destructive detection of amylose in rice and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0038] This application also provides a readable storage medium storing a program or instructions. When the program or instructions are executed by a processor, they implement the various processes of the above-described method for rapid and non-destructive detection of amylose in rice and achieve the same technical effect. To avoid repetition, they will not be described again here.
[0039] The processor is the processor in the electronic device described in the above embodiments. The readable storage medium includes computer-readable storage media, such as computer read-only memory (ROM), random access memory (RAM), magnetic disk, or optical disk.
[0040] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element. Furthermore, it should be noted that the scope of the methods and apparatuses in the embodiments of this application is not limited to performing functions in the order shown or discussed, but may also include performing functions substantially simultaneously or in the reverse order, depending on the functions involved. For example, the described methods may be performed in a different order than described, and various steps may be added, omitted, or combined. Additionally, features described with reference to certain examples may be combined in other examples.
[0041] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of this application.
[0042] The embodiments of this application have been described above with reference to the accompanying drawings. However, this application is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of this application without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of this application.
Claims
1. A rapid and non-destructive method for detecting amylose in rice, characterized in that, A multi-task learning model is constructed using a deep convolutional neural network. This model infers the internal amylose content of rice by analyzing its external optical characteristics. The method includes the following steps: S1: Acquire high-resolution RGB images of rice samples under standard lighting conditions, preprocess the original images including background removal, color correction and region of interest cropping, adjust the image to the model fit size, and obtain the standard rice image tensor. S2: Collect rice samples from different origins and varieties, determine the actual amylose content as a label, and combine it with the collected and preprocessed standard rice image tensor to form a rice image-amylose content database. S3: Construct a multi-task deep learning prediction model, which includes a FasterNet-T2 backbone network, a hierarchical dual-path attention module, and a multi-task regression head; wherein, the hierarchical dual-path attention module is connected to the tail of the backbone network, and is used to receive the basic feature map output by the backbone network and perform high-frequency texture detail compensation extraction to output a refined feature map; the multi-task regression head receives the refined feature map to output the initial prediction value of amylose. S4: Construct a pre-trained, large-capacity FasterNet-L model as the teacher model, and use a knowledge distillation strategy to train the multi-task deep learning prediction model using the rice image-amylose content database to obtain a well-trained target prediction model. S5: Perform structural reparameterization on the hierarchical dual-path attention module in the target prediction model, and then input the tensor of the unknown rice standard image to be tested into the reparameterized target prediction model. Output the predicted value of the amylose content of the rice to be tested through multi-task regression head-to-end.
2. The method according to claim 1, characterized in that, In step S1, rice is laid flat on a black background board, ensuring that the rice grains do not obscure each other, and images are captured using a stereomicroscope. In step S2, the standard rice image tensor and its corresponding real amylose content label data in the constructed rice image-amylose content database are divided into a training set, a validation set, and a test set, with a ratio of 8:1:
1. Data augmentation techniques such as flipping, brightness adjustment, noise addition, and hue conversion are applied to the training set images to expand the samples, and the enhanced standard rice image tensor is output.
3. The method according to claim 1, characterized in that, In step S3, the backbone network uses a partial convolution mechanism to extract multi-scale visual features while preserving spatial dimensional information, and outputs a basic feature map.
4. The method according to claim 3, characterized in that, In step S3, the specific data stream processed by the hierarchical dual-path attention module includes: Global Context Path: Receives the basic feature map output by the backbone network, applies global average pooling to compress the spatial dimension, extracts the macroscopic semi-transparent features of rice and suppresses background noise, and generates global feature weights. Local texture path: Receives the same basic feature map, uses max pooling to avoid feature smoothing effect, preserves high-frequency edge and chalky micro-detail information, and generates local feature weights; Feature fusion: The global feature weights and local feature weights are fused through broadcast multiplication to obtain fusion weights, and the fusion weights are applied to the original base feature map to output a refined feature map.
5. The method according to claim 4, characterized in that, In step S4, a knowledge distillation strategy is used for joint training, the parameters of the teacher model are frozen, and only the parameters of the multi-task deep learning prediction model, which serves as the student model, are updated. The optimization process is carried out through backpropagation iterative calculation using a joint loss function.
6. The method according to claim 5, characterized in that, In step S4, the joint loss function is calculated by weighting hard loss terms and soft loss terms; the hard loss term represents the mean square error between the initial predicted value output by the multi-task deep learning prediction model and the actual amylose content label in the database; the soft loss term represents the Kullback-Leibler divergence between the output distribution of the teacher model and the multi-task deep learning prediction model after introducing the softening probability distribution of the temperature parameter; the relative weights of the soft loss term and the hard loss term are balanced using hyperparameters.
7. The method according to claim 6, characterized in that, In step S4, the Adam optimization algorithm is used as the optimizer for iterative updating of model parameters; The maximum number of training epochs is set to 500, and the validation set error is monitored through an early stopping mechanism. The tolerance parameter is set to 20 epochs. When the validation set loss no longer decreases within 20 consecutive epochs, the training is terminated early, and the model weights are saved.
8. The method according to claim 6, characterized in that, In step S5, the structural reparameterization process specifically includes: During the model training phase, the hierarchical dual-path attention module is internally configured with multi-branch reparameterized convolutions, including 1×1 convolution branches and their corresponding batch normalization layers. During the prediction deployment phase, the linear additivity of convolution operations is utilized to offline fold and equivalently fuse the 1×1 convolution weights in the parallel convolution branch with the batch normalization layer parameters, merging them into a single independent convolutional layer. This outputs the reparameterized target prediction model, enabling single forward propagation prediction without increasing additional inference computation.
9. An electronic device, characterized in that, The method includes a processor, a memory, and a program or instructions stored in the memory and executable on the processor, wherein when the program or instructions are executed by the processor, the steps of a method for rapid non-destructive testing of amylose in rice as described in any one of claims 1-8 are implemented.
10. A readable storage medium, characterized in that, The readable storage medium stores a program or instructions, which, when executed by a processor, implement the steps of a method for rapid non-destructive testing of amylose in rice as described in any one of claims 1-8.