An automatic identification method for edible fungi based on improved weight decay method

By improving the weight decay method, the edible fungi classification model is solved, the problem of inefficient classification of edible fungi varieties is realized, and the automatic identification and rapid classification of edible fungi are realized, which reduces the time cost and labor intensity of manual identification.

CN115272758BActive Publication Date: 2025-08-29XINJIANG AGRI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210876861.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-25
Publication Date
2025-08-29
Estimated Expiration
2042-07-25

AI Technical Summary

Technical Problem

The prior art is difficult to effectively use large convolutional neural networks to identify edible fungi, resulting in inefficient classification of edible fungi varieties. Traditional methods rely on manual identification to increase labor intensity and resource costs.

Method used

The improved weight decay method is used to build an edible fungus classification model. The EfficientNet network model is combined with the improvement of weight normalization and full connection layer to conduct model training and optimization, and automatic identification is performed using the Internet of Things intelligent traceability scale.

Benefits of technology

It improves the accuracy of automatic identification of edible fungi, reduces the cost of manual identification, improves work efficiency, reduces labor intensity, and realizes rapid classification of edible fungi.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115272758B_ABST
    Figure CN115272758B_ABST
Patent Text Reader

Abstract

The present invention provides an edible fungus automatic identification method based on an improved weight decay method, comprising: establishing an edible fungus variety list, collecting images of various varieties of edible fungi under different environments according to the edible fungus variety list, establishing an edible fungus data set, dividing the edible fungus data set to obtain a divided data set, constructing an edible fungus classification model, constraining the edible fungus classification model through an improved weight decay method to obtain a constrained edible fungus classification model, training the divided data and the constrained edible fungus classification model to obtain a trained edible fungus classification model, loading the model into an Internet of Things intelligent traceability scale, and performing automatic identification of edible fungi images. The edible fungus automatic identification method based on the improved weight decay method provided by the present invention can improve the accuracy of the model weight decay training, facilitate adjustment of the model parameters, realize automatic identification of edible fungi, reduce the time cost of manual identification, and reduce labor intensity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of edible fungus identification, and in particular to an edible fungus automatic identification method based on an improved weight decay method. Background Art

[0002] my country currently has over 60 species of edible fungi that can be cultivated artificially, and demand for their production continues to grow. Edible fungi are a key cultivated species in parts of the country. The industry has developed across the country, from mountainous areas to plains, playing a significant role in increasing farmers' productivity and income. By 2019, my country's total edible fungus production reached 39.6191 million tons, with shiitake mushrooms, oyster mushrooms, enoki mushrooms, straw mushrooms, black fungus, white fungus, and nameko ranking first in the world. Research conducted in conventional vegetable markets and large and medium-sized supermarkets revealed that the Chinese edible fungus market is primarily concentrated in household consumption and in food services such as restaurants and hotels. According to the market sales, overall prices and machine hand-held picking costs provided in the "2020-2026 China Edible Fungi Industry Market Monitoring and Development Prospects Outlook Report", the 28 most economically valuable common edible fungi varieties were selected (shiitake mushrooms, Agaricus bisporus, Pleurotus ostreatus, Flammulina velutipes, Black Fungus, Tremella fuciformis, Hericium erinaceus, Coprinus comatus, Agaricus blazei, Agaricus oleifera, Agaricus edulis, Grifola frondosa, Nameko, Pleurotus eryngii, Pleurotus eyrinus, Pleurotus eyrinus, Fungus fuciformis, Dictamnus dasyphylla, Pleurotus ostreatus, Cordyceps sinensis, Boletus edulis, Matsutake, Chicken mushroom, Morel, Hazel mushroom, Chanterelle, Russula, Cyclobalanopsis glauca, etc.).

[0003] Due to the complex variety of edible fungi, most weighing transactions are based on traditional manual weighing, which requires specialized staff to manually label and price. However, relying solely on manual identification of fungi species greatly reduces transaction efficiency. Therefore, it is necessary to study an algorithm for identifying edible fungi images to help humans quickly identify and classify edible fungi, reduce manpower consumption, and save resource costs. Currently, existing international and domestic technologies use traditional machine learning methods to optimize edible fungi models. Usually, edible fungi can only be identified through shallow networks, and only toxic and non-toxic edible fungi are classified. There is very little experimental data, which is not suitable for current large-scale convolutional neural network training. Therefore, it is very necessary to design an automatic edible fungus identification method based on an improved weight decay method. Summary of the Invention

[0004] The purpose of the present invention is to provide an automatic identification method for edible fungi based on an improved weight decay method, which can improve the accuracy of model weight decay training, facilitate adjustment of model parameters, realize automatic identification of edible fungi, reduce the time cost of manual identification, improve work efficiency and reduce labor intensity.

[0005] To achieve the above object, the present invention provides the following solutions:

[0006] An automatic identification method for edible fungi based on an improved weight decay method comprises the following steps:

[0007] Step 1: Create a list of edible fungi varieties, collect images of various edible fungi varieties in different environments based on the list, and create an edible fungi dataset;

[0008] Step 2: Divide the edible fungus dataset to obtain the divided dataset;

[0009] Step 3: Construct an edible fungus classification model, constrain the edible fungus classification model by improving the weight decay method, and obtain the constrained edible fungus classification model;

[0010] Step 4: Train the divided data and the constrained edible fungus classification model to obtain the trained edible fungus classification model, load the model into the IoT smart traceability scale, and perform automatic recognition of edible fungus images.

[0011] Optionally, in step 1, a list of edible fungi varieties is established, and images of various edible fungi varieties under different environments are collected based on the list to establish an edible fungi dataset, specifically:

[0012] Market research was conducted to select the total number of edible fungi varieties and establish a list of edible fungi varieties. Images of various edible fungi varieties under different environments were collected based on the list of edible fungi varieties. The number of images of each edible fungi variety was 2,000. Each edible fungi variety was divided into dry edible fungi and fresh edible fungi. The image collection ratio of dry edible fungi to fresh edible fungi was 4:6. Based on the collected images of various edible fungi varieties under different environments, an edible fungi dataset was established.

[0013] Optionally, in step 2, the edible fungus dataset is divided, and the divided dataset is specifically:

[0014] Image enhancement is performed on the images in the edible fungi dataset, and the enhanced edible fungi dataset is divided according to the ratio of 8:1:1, among which 80% of the edible fungi dataset is randomly assigned as the training set, 10% of the edible fungi dataset is randomly assigned as the validation set, and 10% of the edible fungi dataset is randomly assigned as the test set. The image files of the training set, validation set and test set and the corresponding label files are converted into HDF5 format and stored in a fixed folder.

[0015] Optionally, in step 3, an edible fungus classification model is constructed, and the edible fungus classification model is constrained by an improved weight decay method, specifically:

[0016] Construct an edible fungus classification model using the EfficientNet network model. Constraints are imposed on the model, including effective learning rate constraints and weight norm constraints. The effective learning rate constraint normalizes all layers of the model, maintains the step size in the weight direction unchanged, and controls the effective learning rate.

[0017] The weight norm constraint is: replace the initial fully connected layer of the model with a fully connected layer with normalized weights. In the convolutional layer of the model, the weight norm is fixed to a constant λ. The initialization rate V0 is defined as 0 by the YWeight method. The total number of training steps is represented by t, the initial value is 0, the training sample is represented by x, and the corresponding label is represented by y. The rate of the t+1 step is calculated as:

[0018]

[0019] Where μ is the momentum, τ is the cross entropy loss function, λ is 0, and a random initialization weight vector W0 is defined. The initial learning rate is represented by lr, and the weight vector at step t+1 is:

[0020] W t+1 =W t -lr×η t ×V t+1 (2)

[0021] The formula for calculating the next convolutional layer weight adjustment is:

[0022]

[0023] Among them, the fully connected layer structure with normalized weights is:

[0024]

[0025] Define the τ function as:

[0026]

[0027] In the formula, represents p i The probability of the i-th class, k represents the label class, j represents other classes, g is the weight of Normal-FC, s i The log value of the i-th category is:

[0028]

[0029] The partial derivative of the τ function is transformed to obtain:

[0030]

[0031] In the feature space, the gradient of the weight vector W is x, W j Represents other category vectors, W k Represents the label class vector, the direction is from W j To W k , the deflection angle is determined by p j and g determine, and p j It also depends on g through the softmax function, setting an upper limit a to limit the size of g, using Normalizing the upper limit of different number of categories, the improved weight-normalized fully connected layer structure is:

[0032]

[0033] Optionally, in step 4, the divided data and the constrained edible fungus classification model are trained to obtain a trained edible fungus classification model, and the model is loaded into the IoT smart traceability scale to automatically recognize edible fungus images, specifically:

[0034] The edible fungus classification model was trained on the dataset using Python, Tensorflow, and Keras software. The batch size was set to 16, and a one-cycle cosine annealing strategy was used to make the learning rate change according to the cycle. Linear warm-up was used to optimize the learning rate in the first four rounds of training. A regularization strategy with a label smoothing of 0.1 was used, and noise was added through soft one-hot to reduce the weight of the real sample label category when calculating the loss function. The learning rate hyperparameters were adjusted for training to obtain the trained edible fungus classification model. The model was loaded into the IoT smart traceability scale, and the edible fungi were automatically identified through the camera set on the IoT smart traceability scale.

[0035] According to the specific embodiments provided by the present invention, the present invention discloses the following technical effects: the method for automatic identification of edible fungi based on the improved weight attenuation method provided by the present invention includes establishing a list of edible fungi varieties, collecting images of edible fungi varieties under different environments according to the list of edible fungi varieties, establishing an edible fungi data set, dividing the edible fungi data set to obtain a divided data set, constructing an edible fungi classification model, constraining the edible fungi classification model through the improved weight attenuation method to obtain a constrained edible fungi classification model, training the divided data and the constrained edible fungi classification model to obtain a trained edible fungi classification model, loading the model into an Internet of Things smart traceability scale to automatically identify edible fungi images; the method establishes an edible fungi data set to facilitate model training, and the method can optimize model parameters, while balancing accuracy and running rate, improving the model convergence speed. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0037] Figure 1 This is a flowchart of a method for automatically identifying edible fungi based on an improved weight decay method according to an embodiment of the present invention;

[0038] Figure 2 Flowchart for partitioning the edible fungi dataset;

[0039] Figure 3 This is a schematic diagram of the distribution of some data sets;

[0040] Figure 4 Schematic diagram of top-1 accuracy after grid search for Conv layers and Weight decay;

[0041] Figure 5 Schematic diagram of the offset between training and testing in feature space;

[0042] Figure 6 Schematic diagram of the loss function change curve of the validation set. DETAILED DESCRIPTION

[0043] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0044] The purpose of the present invention is to provide an automatic identification method for edible fungi based on an improved weight decay method, which can improve the accuracy of model weight decay training, facilitate adjustment of model parameters, realize automatic identification of edible fungi, reduce the time cost of manual identification, improve work efficiency and reduce labor intensity.

[0045] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0046] like Figure 1 As shown, the automatic identification method of edible fungi based on the improved weight decay method provided by the embodiment of the present invention includes the following steps:

[0047] Step 1: Create a list of edible fungi varieties, collect images of various edible fungi varieties in different environments based on the list, and create an edible fungi dataset;

[0048] Step 2: Divide the edible fungus dataset to obtain the divided dataset;

[0049] Step 3: Construct an edible fungus classification model, constrain the edible fungus classification model by improving the weight decay method, and obtain the constrained edible fungus classification model;

[0050] Step 4: Train the divided data and the constrained edible fungus classification model to obtain the trained edible fungus classification model, load the model into the IoT smart traceability scale, and perform automatic recognition of edible fungus images.

[0051] like Figure 2 As shown, in step 1, a list of edible fungi varieties is established, and images of various edible fungi varieties in different environments are collected according to the list of edible fungi varieties to establish an edible fungi dataset, specifically:

[0052] Based on the types of edible fungi sold in major vegetable markets, we determined the types of fungi to be collected, the image size, the ratio of dried to fresh fungi to be collected, and the specific collection equipment (mobile phone, digital camera, tablet computer, etc.). After observing the demand for edible fungi in conventional large vegetable markets and consumers' purchasing preferences for each type of edible fungi, we selected the total number of categories in the edible fungi dataset and determined the English names based on the scientific names of the fungi to create a list of edible fungi varieties, as shown in the following table:

[0053] Table 1 List of common edible fungi varieties (Chinese and English)

[0054]

[0055]

[0056]

[0057] With reference to the Fungi dataset, strict collection standards (image size, image background, dry-wet ratio, light intensity, different maturity, etc.) were formulated, and images of various varieties of edible fungi under different environments were collected according to the list of edible fungi varieties. The number of data sets for each variety was as balanced as possible, and the individual varieties were diverse. The number of images of each variety of edible fungi can be selected to be about 2,000, which can achieve better training effects. The number of images of each variety of edible fungi in the present invention is about 1,764, of which the sample size of the hairy-headed cap mushroom image is the least, and the sample size of the rough-skinned Pleurotus ostreatus image is the largest, which are 969 and 2,578 respectively. Each variety of edible fungi is divided into dry edible fungi and fresh edible fungi, wherein the image collection ratio of dry edible fungi and fresh edible fungi is 4:6. Based on the collected images of various varieties of edible fungi under different environments, an edible fungus dataset is established, as shown in the schematic diagram. Figure 3 shown.

[0058] In step 2, the edible fungus dataset is divided, and the divided dataset is as follows:

[0059] Image enhancement was performed on the images in the edible fungi dataset, and the enhanced edible fungi dataset was divided according to a ratio of 8:1:1, wherein 80% of the edible fungi dataset was randomly assigned as a training set (about 39,966 images in the present invention), 10% of the edible fungi dataset was randomly assigned as a validation set (about 4,996 images in the present invention), and 10% of the edible fungi dataset was randomly assigned as a test set (about 4,996 images in the present invention). The image files of the training set, validation set, and test set and the corresponding label files were converted into HDF5 format and stored in a fixed folder.

[0060] In step 3, an edible fungus classification model is constructed and constrained by an improved weight decay method, specifically:

[0061] A fungus classification model was constructed, using the EfficientNet network model. The input image size was 600*600. The width, height, and resolution of the image were scaled using a composite model expansion method. Seven MBConv modules were then stacked, and finally the output image was controlled using pooling and fully connected layers. The composite model expansion method used in the model maintains the dimension scaling by a fixed coefficient. By studying different dimensions and analyzing the impact of a single dimension on the model, the method was used to balance all dimensions of the network, which can improve the model performance by more than 10 times. First, a grid search method was used to find the relationship between different scaling dimensions in the baseline network. Then, the scaling coefficients between different dimensions were fixed. Finally, the depth, width, and resolution coefficients of the model were scaled to improve the model's accuracy and operating efficiency. The trade-offs between the different coefficients are as follows:

[0062] depth:d=α φ (1)

[0063] wipth:w=β φ (2)

[0064] resolution:r=γ φ (3)

[0065] Among them, α, β, and γ are constants obtained by grid search, α·β 2 γ 2 ≈2 and α≥1, β≥1, γ≥1. These parameters can be used to measure the depth, width, and resolution of the network. φ is a custom coefficient used to constrain and control the expansion of the model.

[0066] The edible fungus classification model is constrained by improving the weight decay method as follows:

[0067] (1) Control of effective learning rate

[0068] Because the learning rate has a direct impact on the convergence state of model training, it is necessary to consider how to choose the learning rate attenuation strategy at each training stage. First, after batch normalization is applied to the linear layer, the norm of the weight vector of the output channel remains unchanged, using ω and To represent the weight vector of the channel, x represents the channel input size, and the Euclidean norm is used for batch normalization as shown below:

[0069]

[0070] When the norm of the output channel weight vector of the linear layer remains unchanged, the gradient is calculated as Zoom, then:

[0071]

[0072] When the model scaling remains constant, the key feature of the weight vector is only its directionality. When the weights are updated using stochastic gradient descent with a step size of t and a learning rate of η, the channel weight vector for the next step is:

[0073]

[0074] The step size of the weight vector in the direction changes proportionally, as shown in the following formula:

[0075]

[0076] Based on the above formula, we can conclude that when weight decay is applied to all layers and then normalized, the weight norm can be prevented from growing infinitely, thereby maintaining the step size in the weight direction unchanged, thereby improving the effective learning rate. Therefore, normalizing all layers of the model and maintaining the step size in the weight direction unchanged can control the effective learning rate.

[0077] (2) Control of weight norm

[0078] According to formula 7, the weight decay of the convolutional layer is mainly achieved by constraining the weight vector norm. In order to study the change of the weight vector norm during training, the weight decay of the convolutional layer is not considered. 100 rounds of training are performed on ImageNet using EfficientNet-B0. The weight norm in the convolutional layer is fixed to a constant λ = 0.0001, while the weight norm is not used in the weight decay. The optimal learning rate selection of the two is also different. The learning rate is determined by using grid search to ensure the best performance. Figure 4 As shown in the figure, both achieve the same top-1 accuracy. These results show that the convolutional layer after batch normalization can ignore the effect of weight decay;

[0079] To adjust the weight norm of the convolutional layer, we define the initialization rate to be 0 using the YWeight method, denoted by V0. The total number of training steps is denoted by t, with an initial value of 0. Let x represent the training sample, y represent the corresponding label, μ represent the momentum, and τ represent the cross entropy loss function, as shown in the following formula:

[0080]

[0081] Define a random initialization weight vector W0, and the initial learning rate is represented by lr, then:

[0082] W t+1 =W t -lr×η t ×V t+1 (9)

[0083] The next convolutional layer weight adjustment formula is:

[0084]

[0085] (3) The impact of weight decay in fully connected layers

[0086] In order to study the role of weight decay in the fully connected layer, it is necessary to improve the weight decay method of the convolutional layer. First, keep it scale-invariant and use a fully connected layer with weight normalization to replace the original fully connected layer. Secondly, set λ from 0.0001 to 0. Finally, use WConv+FC To replace the original W Conv , as shown below:

[0087]

[0088] The original fully connected layer is compared with the fully connected layer that maintains scale invariance after replacement. The structure is shown in Formulas 12 and 13.

[0089] FC(x;W FC )=x T W FC (12)

[0090]

[0091] Finally, the softmax cross entropy loss function and formula 3-10 are combined and expressed as τ, as shown in formula 14. Indicates the log value of the i-th category, using p i Represents the probability of the i-th class, k represents the label class, j represents other classes, and g is the weight of Normal-FC. After partial derivative deformation, it is shown in Formula 15.

[0092]

[0093]

[0094] In the feature space, the gradient of the weight vector W is x, W j Represents other category vectors, W k Represents the label class vector, the direction is from W j To W k , the deflection angle is determined by p j and g determine, and p j It also depends on g through the softmax function. When x is the correct classification, g will continue to grow, and p j It will decrease rapidly, causing the function value to approach 0, and the gradient will weaken, making x more likely to be biased towards W j and W k This unclear feature space is prone to shift between training and testing, resulting in poor generalization. Figure 5 shown.

[0095] Based on the above analysis, we need to give an upper limit value α to limit the size of g, expressed as YWeight-FC, using to normalize the upper bound of different number of categories, as shown in Formula 16.

[0096]

[0097] The Normal-FC layer is replaced by a YWeight-FC layer with restricted weights. Other hyperparameters remain unchanged, and the size of α is selected based on the weights. Overall, it can be seen that weight decay affects the cross-boundary risk by constraining the weight norm of the fully connected layer. Specifically, it affects the generalization performance of the model by reducing the risk of x deviating towards the cross-classification boundary. Using the YWeight-FC layer can restore the accuracy of conventional weight decay training.

[0098] In simple terms, the weight norm constraint that needs to be implemented in the present invention is: replace the initial fully connected layer of the model with a fully connected layer with normalized weights. In the convolutional layer of the model, the weight norm is fixed to a constant λ. The initialization rate V0 is defined as 0 by the YWeight method. The total number of training steps is represented by t, the initial value is 0, the training sample is represented by x, and the corresponding label is represented by y. The rate of calculating the t+1 step is:

[0099]

[0100] Where μ is the momentum, τ is the cross entropy loss function, λ is 0, and a random initialization weight vector W0 is defined. The initial learning rate is represented by lr, and the weight vector at step t+1 is:

[0101] W t+1 =W t -lr×η t ×V t+1 (18)

[0102] The formula for calculating the next convolutional layer weight adjustment is:

[0103]

[0104] Among them, the fully connected layer structure with normalized weights is:

[0105]

[0106] Define the τ function as:

[0107]

[0108] In the formula, represents p i The probability of the i-th class, k represents the label class, j represents other classes, g is the weight of Normal-FC, s i The log value of the i-th category is:

[0109]

[0110] The partial derivative of the τ function is transformed to obtain:

[0111]

[0112] In the feature space, the gradient of the weight vector W is x, W j Represents other category vectors, W k Represents the label class vector, the direction is from W j To W k , the deflection angle is determined by p j and g determine, and p j It also depends on g through the softmax function, setting an upper limit a to limit the size of g, using Normalizing the upper limit of different number of categories, the improved weight-normalized fully connected layer structure is:

[0113]

[0114] In step 4, the divided data and the constrained edible fungus classification model are trained to obtain a trained edible fungus classification model, which is then loaded into the IoT smart traceability scale for automatic edible fungus image recognition. Specifically,

[0115] The edible fungus classification model was trained on the dataset using Python, Tensorflow, and Keras software. The batch size was set to 16, and a one-cycle cosine annealing strategy was used to make the learning rate change according to the cycle. Linear warm-up was used to optimize the learning rate in the first four rounds of training. A regularization strategy with a label smoothing of 0.1 was used, and noise was added through soft one-hot to reduce the weight of the real sample label category when calculating the loss function. The learning rate hyperparameters were adjusted for training to obtain the trained edible fungus classification model. The model was loaded into the IoT smart traceability scale, and the edible fungi were automatically identified through the camera set on the IoT smart traceability scale.

[0116] The embodiment of the present invention is as follows: the model is trained on a dataset on a Windows 10 operating system with Python version 3.6.13, Tensorflow version 2.0, and Keras version 2.3.1. The batch size is set to 16, and a one-cycle cosine annealing strategy is used to change the learning rate according to the cycle. Since the learning rate is one of the most important hyperparameters in neural network training, and the initialization weights are random when the model is first trained, if a larger learning rate is selected, it may cause model oscillation. Therefore, linear preheating is used in the first 4 rounds to optimize the learning rate, and the model is gradually stabilized at a smaller preheating learning rate. In addition, a regularization strategy with a label smoothing of 0.1 is also used, and noise is added through soft one-hot to prevent overfitting and reduce the weight of the category of the real sample label when calculating the loss function. By adjusting hyperparameters such as the learning rate, the EfficientNet model based on improved weight decay was trained for 250 rounds. It was found that when the initial learning rate was 0.4 and the weight norm was 16, the model could achieve the best accuracy (79.82% top-1 accuracy and 78.49% F-value) on the edible fungi dataset. The loss function change curve is shown in the figure below. Figure 4 As shown;

[0117] The model is input into the IoT smart traceability scale, and the image recognition of the weighed edible fungi is performed through the carried sensor (camera), and the type and price of the edible fungi are automatically displayed on the display. The total amount is calculated based on the weighing, and a receipt is printed, so that merchants can accurately and quickly mark prices and automatically weigh. Among them, the IoT smart traceability scale can use a conventional IoT smart traceability scale in the existing technology, which can realize additional functions such as image acquisition, image processing and model loading.

[0118] There are many common edible fungi, and the dataset collection volume is large. First, because deep learning requires a large amount of data as support, there is no existing large-scale public dataset suitable for edible fungi image classification. It is necessary to collect 28 types of edible fungi images on your own, about 2,000 images of each type, divided into two types: dried edible fungi and fresh edible fungi. After the collection is completed, manual image label classification and image preprocessing are still required, which is a relatively large task. After the dataset of the present invention is made public, it will provide an experimental basis for subsequent scholars in this field, which can achieve the purpose of shortening researchers' collection time and reducing their workload.

[0119] The complexity of the experimental environment. The images required for model training are taken under different lighting conditions and different image backgrounds. There are cases where the camera is blocked or the edible fungi are wrapped in food bags or plastic wrap. The fungi may only be partially captured or the image may be a little blurry. The complex experimental environment also adds a lot of difficulty to the experiment. Therefore, when shooting, try to select images with backgrounds that meet the laboratory requirements for feature learning, and manually filter and delete images that do not meet the conditions to reduce noise interference. The data set filtered by the method of the present invention prevents overfitting of the model training and can achieve good accuracy.

[0120] Weigh computational efficiency and accuracy. The existing popular network model structures are diverse, and a single network model structure cannot be selected. It is necessary to consider both the computational efficiency and accuracy of the model operation, conduct experimental comparisons on multiple networks, and select the optimal model that best meets the experimental requirements. In addition, the training of large data sets and the deduction when the model is used require certain hardware support. Considering the factors of cost and embedded computing efficiency, it is necessary to balance computational efficiency and accuracy. The improved weight decay method proposed in the present invention can optimize the model parameters, improve the model convergence speed while balancing the accuracy and operation rate.

[0121] This paper constructs a YMushroom edible mushroom image classification dataset with 28 categories, totaling 49,958 images. There are approximately 2,000 images of each category, divided into two types: dried edible mushrooms and fresh edible mushrooms.

[0122] Compared with the Bayesian optimization method, this paper proposes an improved weight decay method, which affects the accuracy of the model by controlling the learning rate and weight norm;

[0123] The present invention experimentally compares multiple networks, selects the optimal model that best meets the experimental requirements, and constructs an EfficientNet model that meets the requirements for edible fungi image classification, thus achieving fine classification of edible fungi.

[0124] Currently, in the field of edible fungus identification, most people use traditional machine learning methods or shallow neural networks with fewer layers for image recognition, such as VGG16 and AlexNet. The MobileNet and EfficientNet used in this paper are both deeper convolutional neural networks. The improved weight decay mechanism improves the control of model parameters and model convergence speed compared to the original network, which has a relatively advanced significance in this field.

[0125] This paper proposes a YWeight weight decay method to study the mechanism of weight decay in fully connected layers, control the effective learning rate by constraining the weight norm, influence the generalization performance of the model by controlling the cross-boundary, and use grid search to determine the impact of learning rate and weight vector on top-1 accuracy.

[0126] The present invention solves the problem of low efficiency caused by the traditional method of edible fungus identification, which usually relies on visual judgment by vegetable farmers with experience in artificial cultivation, and can accurately distinguish the name and category of each fungus species;

[0127] The parameters in the original convolutional neural network are all processed through a single function such as regularization, and the impact of weight decay in the fully connected layer on the model is not taken into account. The function constructed in this invention studies each layer in the network model by controlling variables and compares and analyzes the results.

[0128] The present invention provides an automatic edible fungus identification method based on an improved weight decay method. The method includes establishing an edible fungus variety list, collecting images of various varieties of edible fungi under different environments according to the edible fungus variety list, establishing an edible fungus data set, dividing the edible fungus data set to obtain a divided data set, constructing an edible fungus classification model, constraining the edible fungus classification model through the improved weight decay method to obtain a constrained edible fungus classification model, training the divided data and the constrained edible fungus classification model to obtain a trained edible fungus classification model, loading the model into an Internet of Things intelligent traceability scale to automatically identify edible fungus images; the method establishes an edible fungus data set to facilitate model training, and the method can optimize model parameters, while balancing accuracy and running rate, improving the model convergence speed.

[0129] This document uses specific examples to illustrate the principles and implementation methods of the present invention. The above examples are only intended to help understand the method and core concept of the present invention. At the same time, those skilled in the art will find that the specific implementation methods and application scopes may vary based on the concept of the present invention. In summary, the contents of this specification should not be construed as limiting the present invention.

Claims

1. A method for automatic identification of edible fungi based on an improved weight decay method, characterized in that: The steps include: Step 1: Create a list of edible fungi varieties, collect images of various edible fungi varieties in different environments based on the list, and create an edible fungi dataset; Step 2: Divide the edible fungus dataset to obtain the divided dataset; Step 3: Construct an edible fungus classification model, constrain the edible fungus classification model by improving the weight decay method, and obtain the constrained edible fungus classification model; Step 4: Train the divided data and the constrained edible fungus classification model to obtain a trained edible fungus classification model. Load the model into the IoT smart traceability scale to automatically identify edible fungus images. In step 1, a list of edible fungi varieties is established. Images of various edible fungi varieties under different environments are collected based on the list to create an edible fungi dataset. Specifically: Conduct market research, select the total number of edible fungi varieties, and create a list of edible fungi varieties. Based on the list, collect images of each variety of edible fungi in different environments. Each variety of edible fungi is divided into dry edible fungi and fresh edible fungi. The ratio of dry edible fungi to fresh edible fungi collected is 4:

6. Based on the collected images of each variety of edible fungi in different environments, create an edible fungi dataset. In step 3, an edible fungus classification model is constructed and constrained by an improved weight decay method, specifically: Construct an edible fungus classification model using the EfficientNet network model. Constraints are imposed on the model, including effective learning rate constraints and weight norm constraints. The effective learning rate constraint normalizes all layers of the model, maintains the step size in the weight direction unchanged, and controls the effective learning rate. The weight norm constraint is: replace the initial fully connected layer of the model with a fully connected layer with normalized weights. In the convolutional layer of the model, the weight norm is fixed to a constant λ. The initialization rate V0 is defined as 0 by the YWeight method. The total number of training steps is represented by t, the initial value is 0, the training sample is represented by x, and the corresponding label is represented by y. The rate of the t+1 step is calculated as: Where μ is the momentum, τ is the cross entropy loss function, λ is 0, and a random initialization weight vector W0 is defined. The initial learning rate is represented by lr, and the weight vector at step t+1 is: IN t+1 =In t -lr×η t ×V t+1 (2) The formula for calculating the next convolutional layer weight adjustment is: Among them, the fully connected layer structure with normalized weights is: Define the τ function as: In the formula, represents p i The probability of the i-th class, k represents the label class, j represents other classes, g is the weight of Normal-FC, s i The log value of the i-th category is: The partial derivative of the τ function is transformed to obtain: In the feature space, the gradient of the weight vector W is x, W j Represents other category vectors, W k Represents the label class vector, the direction is from W j To W k , the deflection angle is determined by p j and g determine, and p j It also depends on g through the softmax function, setting an upper limit a to limit the size of g, using Normalizing the upper limit of different number of categories, the improved weight-normalized fully connected layer structure is:

2. The method for automatic identification of edible fungi based on the improved weight decay method according to claim 1, characterized in that: In step 2, the edible fungus dataset is divided, and the divided dataset is as follows: Image enhancement is performed on the images in the edible fungi dataset, and the enhanced edible fungi dataset is divided according to the ratio of 8:1:1, among which 80% of the edible fungi dataset is randomly assigned as the training set, 10% of the edible fungi dataset is randomly assigned as the validation set, and 10% of the edible fungi dataset is randomly assigned as the test set. The image files of the training set, validation set and test set and the corresponding label files are converted into HDF5 format and stored in a fixed folder.

3. The method for automatic identification of edible fungi based on the improved weight decay method according to claim 1, characterized in that: In step 4, the divided data and the constrained edible fungus classification model are trained to obtain a trained edible fungus classification model, which is then loaded into the IoT smart traceability scale for automatic edible fungus image recognition. Specifically, The edible fungus classification model was trained on the dataset using Python, Tensorflow, and Keras software. The batch size was set to 16, and a one-cycle cosine annealing strategy was used to make the learning rate change according to the cycle. Linear warm-up was used to optimize the learning rate in the first four rounds of training. A regularization strategy with a label smoothing of 0.1 was used, and noise was added through soft one-hot to reduce the weight of the real sample label category when calculating the loss function. The learning rate hyperparameters were adjusted for training to obtain the trained edible fungus classification model. The model was loaded into the IoT smart traceability scale, and the edible fungi were automatically identified through the camera set on the IoT smart traceability scale.

Citation Information

Patent Citations

  • An animal image search system based on convolutional neural network

    AU2019100354A4

  • Chinese food identification method based on convolutional neural network

    CN108256571A