Image classification method for edible mushroom quality detection
By combining PID control strategy and stochastic gradient descent (SGD) optimization algorithm, a deep convolutional neural network model based on PID-SGD was constructed, which solved the classification accuracy and efficiency of edible fungi quality detection in the existing technology, and achieved high Accuracy and fast convergence of edible fungi quality image classification.
Patent Information
- Application Number
- CN202411613465.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-12
- Publication Date
- 2025-02-18
AI Technical Summary
The existing edible fungi quality detection methods have problems such as local minimum value traps, slow convergence speed, sensitive to learning rates and difficult to automatically adjust, resulting in low classification accuracy and efficiency.
采用基于PID-SGD优化学习的食用菌品质模型图像分类算法,通过深度卷积神经网络模型和PID-SGD模型学习算法结合,优化参数寻优过程,实现快速收敛和高准确率的分类。
It has achieved high accuracy and rapid convergence in edible fungi quality image classification, suitable for food processing, agricultural planting and supply chain management.
Smart Images

Figure CN119478936A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of edible fungus quality detection and classification, and in particular to an image classification method for edible fungus quality detection. Background Art
[0002] Image classification methods for edible fungi quality detection are mainly used to detect and classify the quality of edible fungi, such as freshness, maturity, pathological conditions, surface defects, etc. With the rapid development of the pre-prepared food market, automated detection on food production lines has become particularly critical. Image-based automated detection has the advantages of high efficiency, objectivity, and non-contact, which can make up for the shortcomings of traditional manual detection and make quality detection more standardized. Deep Neural Network (DNN) is an artificial intelligence model that simulates the human brain neural network and processes and learns data through a multi-layer neuron structure. Traditional SGD (stochastic gradient descent) has limitations in deep neural network training, mainly reflected in the fact that it is easy to fall into local minima, converges slowly, is sensitive to learning rate, and is difficult to adjust automatically. Summary of the invention
[0003] Therefore, in view of the defects and shortcomings of the prior art, the purpose of the present invention is to provide an image classification method for edible fungus quality detection. The method discloses an edible fungus quality model image classification algorithm based on PID-SGD optimization learning. The construction process of the scheme is first to collect and preprocess the hyperspectral spectrum of edible fungi; then build a deep convolutional neural network model; on this basis, a PID-SGD model learning algorithm is proposed; finally, the optimal PID optimization parameters are selected by comparison. The disclosed method aims to achieve high-accuracy and fast-convergence edible fungus quality image classification, has the advantages of high accuracy and block convergence, and has broad application prospects in food processing, agricultural planting, supply chain management and other fields.
[0004] The present invention specifically adopts the following technical solutions:
[0005] An image classification method for edible fungus quality detection: after hyperspectral acquisition and preprocessing of edible fungi, a deep convolutional neural network model is used to perform parameter optimization training using a PID-SGD model learning algorithm, and the deep convolutional neural network model is used to output a classification result of whether mycelium is degraded.
[0006] Furthermore, the process of collecting and preprocessing the hyperspectral image of edible fungi is as follows:
[0007] Firstly, a hyperspectral imager combined with an optical microscope was used to collect hyperspectral image data of edible fungi;
[0008] Next, standardized data preprocessing was used to make the processed data conform to the standard normal distribution;
[0009] Finally, principal component analysis was used to select wavelengths of the edible fungus hyperspectral image and screen out several characteristic wavelengths, each of which corresponds to a grayscale image of an edible fungus.
[0010] Furthermore, the deep convolutional neural network model includes six convolutional blocks and two fully connected layers, each convolutional block includes one convolutional layer, one activation function layer and one normalization layer;
[0011] First, the 980*980 pixel mycelium image selected by the principal component analysis method is scaled to 224*224 pixels, and the 224*224 pixel mycelium image is passed into the network model; then it enters the first convolution block with convolution layer parameters: kernel_size=3, stride=1, padding=1, and the output dimension is 224*224*32; then it enters the second convolution block with convolution layer parameters: kernel_size=3, stride=2, padding=1, and the output dimension is 112*112*64; further it enters the third convolution block with convolution layer parameters: kernel_size=3, stride=1, padd ing=1, the output dimension is 112*112*64; next, enter the fourth convolution block with convolution layer parameters: kernel_size=3, stride=2, padding=1, and the output dimension is 56*56*128; now enter the fifth convolution block with convolution layer parameters: kernel_size=3, stride=1, padding=1, and the output dimension is 56*56*128; then enter the sixth convolution block with convolution layer parameters: kernel_size=3, stride=2, padding=1, and the output dimension is 28*28*256; finally enter the fully connected layer and output the classification result of whether the hyphae are degraded.
[0012] Furthermore, the PID-SGD model learning algorithm introduces a PID control strategy based on stochastic gradient descent SGD:
[0013]
[0014] In the formula, θ t represents the model parameters of the tth iteration, α represents the learning rate, It represents the objective function f with respect to the parameter θ t The gradient of It represents the sum of the cumulative objective function gradients from the beginning of the iteration to the tth iteration, that is, It means that the objective function gradient is in θ tThe first derivative of the point, K p , K i , K d They are the P term coefficient, I term coefficient and D term coefficient respectively.
[0015] Furthermore, the best training result is obtained by screening the optimal combination of P-term coefficients, I-term coefficients and D-term coefficients.
[0016] And, an image classification system for edible fungus quality detection, comprising:
[0017] The acquisition and preprocessing module is used for the hyperspectral acquisition and preprocessing of edible fungi;
[0018] And, a deep convolutional neural network model and a PID-SGD model learning algorithm module are constructed. The deep convolutional neural network model uses the PID-SGD model learning algorithm module to perform parameter optimization, and after training, outputs a classification result of whether the mycelium is degraded.
[0019] Furthermore, the acquisition and preprocessing module includes:
[0020] Hyperspectral imager combined with optical microscope is used to collect hyperspectral image data of edible fungi;
[0021] Standardized data preprocessing was used to make the processed data conform to the standard normal distribution;
[0022] The principal component analysis method is used to select the wavelength of the edible fungus hyperspectral image and screen out several characteristic wavelengths, each of which corresponds to a grayscale image of the edible fungus.
[0023] Furthermore, the PID-SGD model learning algorithm module introduces a PID control strategy based on stochastic gradient descent SGD:
[0024]
[0025] In the formula, θ t represents the model parameters of the tth iteration, α represents the learning rate, It represents the objective function f with respect to the parameter θ t The gradient of It represents the sum of the cumulative objective function gradients from the beginning of the iteration to the tth iteration, that is, It means that the objective function gradient is in θ t The first derivative of the point, K p , K i , K d They are the P term coefficient, I term coefficient and D term coefficient respectively.
[0026] An electronic device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the image classification method for edible fungus quality detection as described above are implemented.
[0027] A non-transitory computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the image classification method for edible fungi quality detection as described above.
[0028] Compared with the prior art, the present invention and its preferred embodiment combine the automatic control algorithm PID used in industrial control with SGD for the first time, and apply it to the training of deep convolutional neural network model for edible fungus quality image classification, achieving unexpected outstanding results, and being able to realize edible fungus quality image classification with high accuracy and fast convergence. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments:
[0030] Figure 1 This is an overall framework diagram of the deep convolutional neural network model according to an embodiment of the present invention;
[0031] Figure 2 The figure is a schematic diagram of the construction process of the image classification method for edible fungi quality detection according to an embodiment of the present invention. DETAILED DESCRIPTION
[0032] In order to make the features and advantages of this patent more obvious and easy to understand, the following embodiments are specifically described in detail with the accompanying drawings as follows:
[0033] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present application belongs.
[0034] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0035] like Figure 2 As shown, the construction process of the image classification method for edible fungi quality detection provided by the embodiment of the present invention is implemented as follows:
[0036] 1) Collection and preprocessing of edible fungi hyperspectral
[0037] Firstly, a portable hyperspectral imager (model: GaiaField-Pro-V10E) was mounted on an optical microscope (model: BX41) to collect hyperspectral image data of edible fungi. Each hyperspectral image data contains 360 bands.
[0038] Next, the Standard Normal Variate (SNV) data preprocessing technique is used. The basic idea is to subtract the mean of each variable from its value and then divide it by its standard deviation so that the processed data conforms to the standard normal distribution, that is, the mean is 0 and the standard deviation is 1. This process can reduce the deviation between samples caused by physical factors.
[0039] Finally, principal component analysis (PCA) was used to select wavelengths for the hyperspectral image of Pleurotus geesteranus mycelium, and 13 characteristic wavelengths were selected from the original 360 wavelengths. Each wavelength corresponds to a grayscale image of Pleurotus geesteranus mycelium.
[0040] 2) Build a deep convolutional neural network model
[0041] Using CNN (Convolutional neural networks) deep model architecture, such as Figure 1 As shown in the figure, the model has six convolution blocks and two fully connected layers. Each convolution block contains one convolution layer, one activation function layer and one normalization layer.
[0042] First, the 980*980 pixel mycelium image selected by PCA is scaled to 224*224 pixels, and the 224*224 pixel mycelium image is passed into the network model; then it enters the first convolution block with convolution layer parameters: kernel_size=3, stride=1, padding=1, and the output dimension is 224*224*32; then it enters the second convolution block with convolution layer parameters: kernel_size=3, stride=2, padding=1, and the output dimension is 112*112*64; further it enters the third convolution block with convolution layer parameters: kernel_size=3, stride=1, padding=1, and the output dimension is 112*112*64. g=1, the output dimension is 112*112*64; next, enter the fourth convolution block with convolution layer parameters: kernel_size=3, stride=2, padding=1, and the output dimension is 56*56*128; now enter the fifth convolution block with convolution layer parameters: kernel_size=3, stride=1, padding=1, and the output dimension is 56*56*128; then enter the sixth convolution block with convolution layer parameters: kernel_size=3, stride=2, padding=1, and the output dimension is 28*28*256; finally enter the fully connected layer and output the classification result of whether the mycelium is degraded.
[0043] 3) Design PID-SGD model learning algorithm
[0044] First, we construct the SGD (stochastic gradient descent) learning algorithm. This algorithm is a commonly used optimization algorithm for deep learning models when optimizing parameters. Its core theory is to randomly select a small batch of samples in each training to calculate the gradient, and then update the model parameters according to the direction and size of the gradient. The calculation is shown in formula (1):
[0045]
[0046] Where θ t represents the model parameters of the tth iteration, α represents the learning rate, It represents the objective function f with respect to the parameter θ t However, since SGD only considers the current gradient to update the parameters of the deep convolutional neural network model, the deep convolutional neural network model converges slowly and is easily disturbed by noise, causing the gradient of the deep convolutional neural network model to disappear or overfit. To solve these problems, the present invention introduces a model learning method based on PID control theory to improve the convergence speed of the model and the accuracy of classification.
[0047] Next, we enter the PID (proportional-integral-derivative) control strategy, which is an automatic control algorithm currently used in industrial control. The basic principle of the PID controller is: the P term adjusts the control output according to the error size to improve the system response speed, the I term adjusts the control output according to the error integral to eliminate the static error, and the D term adjusts the control output according to the error change rate to respond in advance and reduce overshoot. The mathematical representation of the PID controller is shown in formula (2):
[0048]
[0049] Where u(t) represents the output, e(t) represents the error, and K p , K i , K d They represent the proportional coefficient, integral coefficient and differential coefficient respectively.
[0050] Finally, the PID control strategy is combined with the SGD learning algorithm to solve the problem of low classification accuracy caused by gradient disappearance or overfitting in the deep convolutional neural network model. Its mathematical expression is shown in formula (3):
[0051]
[0052] Where θ t represents the model parameters of the tth iteration, α represents the learning rate, It represents the objective function f with respect to the parameter θ t The gradient of It represents the sum of the cumulative objective function gradients from the beginning of the iteration to the tth iteration, that is, It means that the objective function gradient is in θ t The first derivative of the point, K p , K i , K d They are the P term coefficient, I term coefficient and D term coefficient respectively.
[0053] 4) Optimize the selection of PID parameters
[0054] Taking the typical edible mushroom, Pleurotus geesteranus, as an example, 13 characteristic wavelengths are selected from the 360 wavelengths of each hyperspectral image, and each wavelength corresponds to a grayscale image of Pleurotus geesteranus. Finally, the data set contains 1,300 grayscale images of Pleurotus geesteranus with high and low quality, and the resolution of each image is 980*980 pixels. The 1,300 Pleurotus geesteranus images are randomly divided into a training set: validation set: test set ratio of 7:1:2, and the ratio of the number of high-quality and low-quality Pleurotus geesteranus images in each set is guaranteed to be 1:1. Finally, the training set contains 910 images, with high-quality and low-quality Pleurotus geesteranus equally divided; the validation set contains 130 images, with high-quality and low-quality Pleurotus geesteranus equally divided; the test set contains 260 images, with high-quality and low-quality Pleurotus geesteranus equally divided.
[0055] Given different values of the P, I, and D coefficients in the PID-SGD model, the effect of PID-SGD in optimizing the classification of the deep convolutional neural network model is also different. Therefore, it is necessary to select the coefficient combination that makes the model classification effect the best. The P, I, and D coefficients are systematically adjusted to observe the classification accuracy of the model on the validation set and the test set, so as to obtain the best coefficient combination. Specifically, the I and D coefficients are fixed first, and 0.001 and 0.1 are selected respectively. Then the P coefficient is adjusted from 1 to 0.6, and it is reduced by 0.1 each time. The validation set accuracy under each set of coefficients is recorded, and the P coefficient value with the highest accuracy is selected. Using the same method, the I and D coefficients are adjusted respectively, and the coefficient value with the best effect under each single item is selected. Through multiple rounds of experiments, it is observed that the I coefficient should not be set too large. This is because the I term represents the term of accumulated errors, and its influence needs a certain amount of time to accumulate before it can appear. If the I coefficient is set too large, the model may be too dependent on historical errors, thereby reducing the model accuracy. The classification results of the deep convolutional neural network model when different values of the P-term, I-term, and D-term coefficients are selected are shown in Table 1.
[0056] Table 1 Results of classifying Pleurotus geesteranus quality images under different P-term coefficients
[0057]
[0058] According to Table 1, when the I-term coefficient is selected as 0.001, the D-term coefficient is selected as 0.1 and remains unchanged, and the P-term coefficient is selected as 0.8, the classification accuracy of the deep convolutional neural network model on the validation set and test set can reach 94.01% and 90.42% respectively, which is higher than the accuracy under other values of the P-term coefficient. When the P-term coefficient is selected as 0.9 and 0.8, the number of training times required to complete the training of the deep convolutional neural network model is 42 times, which is shorter than the training completion time under other P-term coefficient selections. Therefore, when the I-term and D-term coefficients are constant, the deep convolutional neural network model optimized by PID-SGD has the best effect when the P-term coefficient is 0.8.
[0059] Table 2 Results of classifying Pleurotus geesteranus quality images under different I-term coefficients
[0060]
[0061] According to Table 2, when the P coefficient is selected as 0.8, the D coefficient is selected as 0.1 and remains unchanged, and the I coefficient is selected as 0.003, the classification accuracy of the deep convolutional neural network model on the validation set and test set can reach 92.09% and 90.01% respectively, which is higher than the accuracy under other numerical selections of the I coefficient. Considering the classification accuracy and convergence speed of the model, the deep convolutional neural network model optimized by PID-SGD has the best effect when the I coefficient is 0.003.
[0062] Table 3 Results of classifying Pleurotus geesteranus quality images under different D coefficients
[0063]
[0064]
[0065] According to Table 3, when the P coefficient is selected as 0.8, the I coefficient is selected as 0.003 and remains unchanged, and the D coefficient is selected as 0.2, the classification accuracy of the deep convolutional neural network model on the validation set and test set reaches 92.01% and 90.23% respectively, which is higher than the accuracy of other D coefficient values. When the D coefficient is selected as 0.5, the number of training times required to complete the training of the deep convolutional neural network model is 11 times, which is shorter than the training completion time under other D coefficient selections, but the classification accuracy on the validation set and test set is 37.91% and 37.12% lower than when the D coefficient is selected as 0.2. Considering the classification accuracy and convergence speed of the model, the deep convolutional neural network model optimized by the PID-SGD algorithm has the best effect when the D coefficient is 0.2.
[0066] Based on the above experimental results, it can be concluded that the optimal PID-SGD optimization algorithm parameter combination is: K p =0.8, K i=0.003 and K d = 0.2. This coefficient combination makes the deep convolutional neural network model with PID-SGD optimization have the best optimization effect in the Pleurotus geesteranus quality classification task. The classification accuracy on the validation set and test set can reach 94.01% and 91.35% respectively. The model converges after 32 rounds of training. However, when the data sample selection is different, the PID parameters may be selected differently.
[0067] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented in one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that include computer-usable program code.
[0068] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0069] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0070] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process in the computer or other programmable device. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0071] This patent is not limited to the above-mentioned best implementation mode. Anyone can derive other forms of an image classification method for edible fungus quality detection under the inspiration of this patent. All equal changes and modifications made according to the scope of the patent application of the present invention should be covered by this patent.
Claims
1. An image classification method for edible fungus quality detection, characterized by: After the edible fungi are hyperspectrally collected and preprocessed, the deep convolutional neural network model is used to perform parameter optimization and complete training using the PID-SGD model learning algorithm, and the deep convolutional neural network model is used to output a classification result of whether the mycelium is degraded.
2. The image classification method for edible fungi quality detection according to claim 1, characterized in that: The specific process of collecting and preprocessing the hyperspectral image of edible fungi is as follows: Firstly, a hyperspectral imager combined with an optical microscope was used to collect hyperspectral image data of edible fungi; Next, standardized data preprocessing was used to make the processed data conform to the standard normal distribution; Finally, principal component analysis was used to select wavelengths of the edible fungus hyperspectral image and screen out several characteristic wavelengths, each of which corresponds to a grayscale image of an edible fungus.
3. The image classification method for edible fungi quality detection according to claim 2, characterized in that: The deep convolutional neural network model includes six convolution blocks and two fully connected layers, each convolution block includes one convolution layer, one activation function layer and one normalization layer; First, the 980*980 pixel mycelium image selected by the principal component analysis method is scaled to 224*224 pixels, and the 224*224 pixel mycelium image is passed into the network model; then it enters the first convolution block with convolution layer parameters: kernel_size=3, stride=1, padding=1, and the output dimension is 224*224*32; then it enters the second convolution block with convolution layer parameters: kernel_size=3, stride=2, padding=1, and the output dimension is 112*112*64; further it enters the third convolution block with convolution layer parameters: kernel_size=3, stride=1, padd ing=1, the output dimension is 112*112*64; next, enter the fourth convolution block with convolution layer parameters: kernel_size=3, stride=2, padding=1, and the output dimension is 56*56*128; now enter the fifth convolution block with convolution layer parameters: kernel_size=3, stride=1, padding=1, and the output dimension is 56*56*128; then enter the sixth convolution block with convolution layer parameters: kernel_size=3, stride=2, padding=1, and the output dimension is 28*28*256; finally enter the fully connected layer and output the classification result of whether the hyphae are degraded.
4. The image classification method for edible fungus quality detection according to claim 1, characterized in that: The PID-SGD model learning algorithm introduces the PID control strategy based on the stochastic gradient descent SGD: In the formula, θ t represents the model parameters of the tth iteration, α represents the learning rate, It represents the objective function f with respect to the parameter θ t The gradient of It represents the sum of the cumulative objective function gradients from the beginning of the iteration to the tth iteration, that is, It means that the objective function gradient is in θ t The first derivative of the point, K p , K i , K d They are the P term coefficient, I term coefficient and D term coefficient respectively.
5. The image classification method for edible fungi quality detection according to claim 4, characterized in that: The best training result is obtained by screening the optimal combination of P-term coefficients, I-term coefficients and D-term coefficients.
6. An image classification system for edible fungus quality detection, characterized in that: include: The acquisition and preprocessing module is used for the hyperspectral acquisition and preprocessing of edible fungi; A deep convolutional neural network model and a PID-SGD model learning algorithm module are constructed. The deep convolutional neural network model uses the PID-SGD model learning algorithm module to perform parameter optimization, and after training, outputs a classification result of whether the mycelium is degraded.
7. The image classification system for edible fungi quality detection according to claim 6, characterized in that: The acquisition and preprocessing module includes: Hyperspectral imager combined with optical microscope is used to collect hyperspectral image data of edible fungi; Standardized data preprocessing was used to make the processed data conform to the standard normal distribution; The principal component analysis method is used to select the wavelength of the edible fungus hyperspectral image and screen out several characteristic wavelengths, each of which corresponds to a grayscale image of the edible fungus.
8. The image classification system for edible fungi quality detection according to claim 6, characterized in that: The PID-SGD model learning algorithm module introduces the PID control strategy based on the stochastic gradient descent SGD: In the formula, θ t represents the model parameters of the tth iteration, α represents the learning rate, It represents the objective function f with respect to the parameter θ t The gradient of It represents the sum of the cumulative objective function gradients from the beginning of the iteration to the tth iteration, that is, It means that the objective function gradient is in θ t The first derivative of the point, K p , K i , K d They are the P term coefficient, I term coefficient and D term coefficient respectively.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the image classification method for edible fungi quality detection as described in any one of claims 1 to 5 are implemented.
10. A non-transitory 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 image classification method for edible fungi quality detection as described in any one of claims 1 to 5 are implemented.