Citrus leaf disease identification method, system and equipment based on dual transfer learning
Through dual transfer learning and attention mechanism, combined with knowledge distillation technology, it solves the problem of low accuracy in citrus disease identification under small sample data, achieves high-accuracy disease identification, and facilitates mobile terminal deployment.
Patent Information
- Application Number
- CN202210579072.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-26
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2042-05-26
AI Technical Summary
Existing deep learning models have a large amount of calculations and many parameters in citrus disease identification, making it difficult to achieve high accuracy with small sample data. Moreover, ordinary transfer learning data sets are not close enough to the target features, resulting in low recognition accuracy and difficulty in deployment.
Using a method based on dual transfer learning, by constructing a transfer learning data set and adding an attention mechanism to the network model, combined with knowledge distillation technology, the model parameters are reduced, the accuracy of citrus disease identification is improved, and it is easy to deploy on mobile terminals.
It improves the accuracy of citrus disease identification, solves the identification problem under small sample training, and makes the identification system more convenient to deploy on the mobile terminal by reducing model parameters.
Smart Images

Figure CN115035405B
Abstract
Description
Technical Field
[0001] The invention relates to a citrus leaf disease recognition method, system and equipment based on dual transfer learning, belonging to the technical field of plant disease recognition. Background Art
[0002] Citrus is the world's largest fruit, and plays an important role in rural economic development and world trade. However, many citrus diseases are one of the important factors restricting the development of citrus production and the expansion of domestic and foreign markets. In recent years, non-destructive and rapid identification technology of plant diseases has become an important part of plant disease identification research. It is difficult to obtain a large number of samples of some citrus diseases, and it is difficult to achieve ideal results when applying deep learning methods to classify and identify them. Existing deep learning models generally have large computational complexity and too many parameters. When the training set data is small, it is easy to have overfitting problems. Therefore, a large number of data sets and good computing resources are required, and it takes a long time. Transfer learning can train a neural network on a large image data set, and complete the target recognition task after a small adjustment on a small target data set. It can effectively make up for the lack of data and shorten the calculation time. However, most of the data sets used in ordinary transfer learning are not close enough to the detection target features, and there are still large network parameters, which are difficult to improve the accuracy and are not conducive to deployment. Therefore, there is an urgent need for an image recognition method that can use a small data set to obtain a higher accuracy and fewer training parameters. Summary of the invention
[0003] In view of this, the present invention provides a citrus leaf disease identification method, system, computer device and storage medium based on dual transfer learning, which improves the accuracy of citrus disease identification in small sample conditions by constructing a transfer learning data set and adding an attention mechanism to the network model. At the same time, it uses knowledge distillation to effectively reduce model parameters, making it easier to deploy the model on a mobile terminal.
[0004] The first object of the present invention is to provide a citrus leaf disease identification method based on dual transfer learning.
[0005] The second object of the present invention is to provide a citrus leaf disease identification system based on dual transfer learning.
[0006] A third object of the present invention is to provide a computer device.
[0007] A fourth object of the present invention is to provide a storage medium.
[0008] The first object of the present invention can be achieved by adopting the following technical solutions:
[0009] A citrus leaf disease identification method based on dual transfer learning, the method comprising:
[0010] Acquire a transfer learning data set and a self-built data set, wherein the transfer learning data set includes a set of images of leaves with various plant diseases downloaded by a crawler and a set of images of healthy citrus leaves downloaded by a crawler, and the self-built data set includes a set of images of diseased citrus leaves collected by a self-collected computer and a set of images of healthy citrus leaves collected by a self-collected computer;
[0011] Construct the teacher network model and the first student network model;
[0012] Use self-built data sets to train the teacher network model;
[0013] Pre-training the first student network model using the transfer learning data set, and saving the weights of the pre-trained first student network model;
[0014] Construct a second student network model and load the pre-trained weights of the first student network model into the second student network model;
[0015] Use the trained teacher network model and the self-built data set to train the second student network model after weight loading in the way of knowledge distillation to obtain the third student network model;
[0016] Obtain the image of the citrus leaf to be identified;
[0017] The image of the citrus leaves to be identified is input into the third student network model to obtain the disease recognition result of the image of the citrus leaves to be identified.
[0018] Furthermore, the teacher network model includes an input layer, a pre-trained Xception network model, an ECABlock attention mechanism, and a first densely connected classifier;
[0019] The construction of the teacher network model specifically includes:
[0020] The input layer, the pre-trained Xception network model, the ECA Block attention mechanism, and the first densely connected classifier are sequentially connected to construct a teacher network model;
[0021] The pre-trained Xception network model is used as a feature extraction network. The pre-trained Xception network model only loads the convolution base part and does not load the second densely connected classifier.
[0022] Furthermore, the ECA Block attention mechanism includes a global pooling layer and a Multiply layer, wherein the global pooling layer to the Multiply layer are ECA Block functions;
[0023] The ECA Block attention mechanism generates channel weights through a one-dimensional convolution with a convolution kernel size of k; where k is adaptively determined by mapping the channel dimension C, as shown in the following formula:
[0024]
[0025] Among them, k represents the convolution kernel size, C represents the number of channels, odd represents an odd number, and γ and b are used to change the ratio between C, k, C and k.
[0026] Further, the first student network model and the second student network model are the same;
[0027] The first student network model adopts the classic MobileNet network model.
[0028] Furthermore, the step of loading the pre-trained weights of the first student network model into the second student network model specifically includes:
[0029] The weights of the pre-trained first student network model except the penultimate layer to the penultimate sixtieth layer are loaded into the second student network model.
[0030] Furthermore, the method of using the trained teacher network model and the self-built data set to train the second student network model after weight loading in a knowledge distillation manner to obtain the third student network model specifically includes:
[0031] The original output layer of the first densely connected classifier in the trained teacher network model is deleted, and after the original output layer is deleted, the last dense layer of the first densely connected classifier is used as the output layer;
[0032] Freeze all layers except the last to the last sixtieth layer in the second student network model after weight loading;
[0033] Add temperature T to the category probability of the non-activated output of the teacher network model whose output layer is a dense layer to obtain Soft-Labels;
[0034] The frozen second student network model is trained simultaneously using Soft-Labels and the original labels Hard-Labels of the self-built dataset to obtain the third student network model.
[0035] Furthermore, in the process of simultaneously training the frozen second student network model using Soft-Labels and the original labels Hard-Labels of the self-built data set, the objective function involved is as follows:
[0036] L=aL soft +bLhard
[0037] Where L represents the objective function, a and b represent L soft , L hard The weight, L soft represents the cross entropy of the softmax function and Soft-Labels generated by the frozen second student network model at temperature T, L hard It represents the cross entropy of the softmax function and Hard-Labels generated by the frozen second student network model at temperature T = 1;
[0038] The L soft , as follows:
[0039]
[0040] in, represents the value of the non-activated output of the teacher network model with a dense layer on the i-th class at temperature T, represents the value of the softmax function output of the frozen second student network model on the i-th category at temperature T, and n represents the total number of labels;
[0041] Said and They are as follows:
[0042]
[0043]
[0044] Among them, v i Represents the logits of the teacher network model whose output layer is a dense layer, z i represents the logits of the second student network model after freezing, and N represents the total number of labels;
[0045] The L hard , as follows:
[0046]
[0047] Among them, c i represents the value of the i-th category, c i Indicates the value range, the positive label is 1 and the negative label is 0;
[0048] Said As follows:
[0049]
[0050] Among them, N represents the total number of labels, zi Represents the logits of each category output.
[0051] Furthermore, the unified expression of the Softmax function is as follows:
[0052]
[0053] Among them, q i Represents the probability of each category output, z i represents the logits of each category output, and T represents temperature.
[0054] The second object of the present invention can be achieved by adopting the following technical solutions:
[0055] A citrus leaf disease recognition system based on dual transfer learning, the system comprising:
[0056] A first acquisition unit is used to acquire a transfer learning data set and a self-built data set, wherein the transfer learning data set includes a plurality of plant disease leaf picture sets downloaded by a crawler and a citrus healthy leaf picture set downloaded by a crawler, and the self-built data set includes a self-collected citrus disease leaf picture set and a self-collected citrus healthy leaf picture set;
[0057] A first construction unit, used to construct a teacher network model and a first student network model;
[0058] The first training unit is used to train the teacher network model using a self-built data set;
[0059] A second training unit is used to pre-train the first student network model using the transfer learning data set and save the weight of the pre-trained first student network model;
[0060] A second construction unit is used to construct a second student network model and load the pre-trained first student network model weights into the second student network model;
[0061] The third training unit is used to train the second student network model after weight loading by using the trained teacher network model and the self-built data set in a knowledge distillation manner to obtain a third student network model;
[0062] The second acquisition unit is used to acquire the image of the citrus leaf to be identified;
[0063] The disease identification unit is used to input the citrus leaf picture to be identified into the third student network model to obtain the disease identification result of the citrus leaf picture to be identified.
[0064] The third object of the present invention can be achieved by adopting the following technical solutions:
[0065] A computer device comprises a processor and a memory for storing a program executable by the processor. When the processor executes the program stored in the memory, the above-mentioned citrus leaf disease identification method is implemented.
[0066] The fourth object of the present invention can be achieved by adopting the following technical solutions:
[0067] A storage medium stores a program, and when the program is executed by a processor, the above-mentioned citrus leaf disease identification method is implemented.
[0068] The present invention has the following beneficial effects compared with the prior art:
[0069] (1) The present invention utilizes the similarity of the image features of the lesions of the same disease on different plants, uses a crawler program to accurately obtain disease images identical to the target to be detected, and then constructs a transfer learning dataset, which provides a new idea for constructing datasets in the field of plant disease recognition.
[0070] (2) Compared with the existing method of using only the ImageNet dataset for transfer learning, the transfer learning dataset constructed by the present invention can more accurately train the network's feature extractor, thereby improving the accuracy of transfer learning; in addition to solving the problem of low accuracy in small sample training, the present invention also adds an attention mechanism to the model to further improve the accuracy of citrus disease recognition. At the same time, the knowledge distillation method is used to reduce the model training parameters, which facilitates the deployment of the model on the mobile terminal. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. 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 the structures shown in these drawings without paying creative work.
[0072] Figure 1 This is a specific flow chart of the citrus leaf disease identification method based on dual transfer learning in Example 1 of the present invention.
[0073] Figure 2 This is a brief flow chart of the citrus leaf disease identification method based on dual transfer learning in Example 1 of the present invention.
[0074] Figure 3a to Figure 3c These are pictures of leaves with different plant canker diseases downloaded by the crawler program of Example 1 of the present invention.
[0075] Figure 4a to Figure 4c These are pictures of sooty leaf disease of different plants downloaded by the crawler program of Example 1 of the present invention.
[0076] Figure 5a to Figure 5c These are pictures of leaves with scab disease on different plants downloaded by the crawler program of Example 1 of the present invention.
[0077] Figure 6a to Figure 6c These are pictures of anthracnose leaves of different plants downloaded by the crawler program of Example 1 of the present invention.
[0078] Figure 7 This is a structural diagram of the teacher network model of Example 1 of the present invention.
[0079] Figure 8 This is a schematic diagram of the structure of the ECA Block attention mechanism of Example 1 of the present invention.
[0080] Fig. 9 This is a specific flow chart of knowledge distillation according to Example 1 of the present invention.
[0081] Fig.10 This is a structural block diagram of a citrus leaf disease identification system based on dual transfer learning according to Example 2 of the present invention.
[0082] Fig.11 This is a structural block diagram of a computer device according to Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0083] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0084] Embodiment 1:
[0085] like Figure 1 and Figure 2 As shown, this embodiment provides a citrus leaf disease identification method based on dual transfer learning, the method comprising the following steps:
[0086] S101. Obtain a transfer learning dataset and a self-built dataset.
[0087] In this step, a crawler program is used to randomly download pictures of canker leaves, sooty mold disease leaves, anthracnose leaves and scab disease leaves of various plants from Baidu pictures, and a crawler program is used to randomly download multiple pictures of healthy citrus leaves from Baidu pictures, wherein the pictures of canker leaves, sooty mold disease leaves, anthracnose leaves and scab disease leaves of various plants are collectively referred to as pictures of various plant diseased leaves; data cleaning is performed on the various plant diseased leaf pictures and multiple healthy citrus leaf pictures obtained by the above downloads, specifically: deleting pictures of poor quality and pictures that do not meet the target characteristics.
[0088] In this step, the images of various plant diseased leaves after data cleaning are used as the image set of various plant diseased leaves downloaded by the crawler, and the images of multiple healthy citrus leaves after data cleaning are used as the image set of healthy citrus leaves downloaded by the crawler; the image set of various plant diseased leaves downloaded by the crawler and the image set of healthy citrus leaves downloaded by the crawler are used together as the transfer learning data set, among which some images in the transfer learning data set, such as Figure 3a to Figure 3c , Figure 4a to Figure 4c , Figure 5a to Figure 5c , Figure 6a to Figure 6c shown; specifically, Figure 3a For citrus canker leaf pictures, Figure 3b Pictures of pitaya leaves with ulcer disease, Figure 3c This is a picture of kiwifruit leaves with canker; Figure 4a For the pictures of citrus sooty leaf disease, Figure 4b For the leaves of crape myrtle with sooty mold, Figure 4c Here is a picture of the leaves of litchi with sooty mold; Figure 5a Pictures of citrus scab leaves. Figure 5b For pepper scab disease leaf pictures, Figure 5c This is a picture of the leaves of pitaya with scab disease; Figure 6a Pictures of citrus anthracnose leaves. Figure 6b For pepper anthracnose leaf pictures, Figure 6c This is a picture of a leaf infected with blue anthracnose; it can be seen that the characteristics of the lesions of the same disease on different plants are very similar.
[0089] In this step, pictures are randomly downloaded according to the crawler program, including:
[0090] Step 1. In the crawler program, enter the category of the images to be crawled, such as: the keywords entered are ulcer disease leaves, sooty mold disease leaves, anthracnose disease leaves, scab disease leaves and healthy citrus leaves.
[0091] Step 2: In the crawler program, enter the number of images to be crawled.
[0092] After completing steps 1 and 2, the crawler program automatically creates a folder named after the category of the images to be crawled, and automatically names and formats each image. The format is to enter the category of the image to be crawled plus the image serial number, and then determine whether the number of images downloaded by the crawler program matches the number of images to be crawled. If so, the download is complete; if not, the download continues until the download is complete.
[0093] The above crawler program is written in Python language.
[0094] In this step, pictures of citrus canker leaf diseases, citrus sooty disease leaf diseases, citrus anthracnose leaf diseases, citrus scab leaf diseases and citrus healthy leaf diseases are collected in the orchard, among which the pictures of citrus canker leaf diseases, citrus sooty disease leaf diseases, citrus anthracnose leaf diseases and citrus scab leaf diseases are collectively referred to as citrus leaf disease pictures; the multiple citrus leaf disease pictures collected in the orchard are used as a self-collected citrus diseased leaf picture set, and the multiple citrus healthy leaf pictures collected in the orchard are used as a self-collected citrus healthy leaf picture set; the self-collected citrus diseased leaf picture set and the self-collected citrus healthy leaf picture set are used together as a self-built data set.
[0095] Furthermore, in this embodiment, the transfer learning dataset and the self-built dataset are divided into a training set, a test set, and a validation set in a ratio of 6:2:2, respectively.
[0096] This embodiment uses the ImageDataGenerator class under the keras framework to perform image enhancement and image preprocessing on the training set of the transfer learning dataset and the training set of the self-built dataset, respectively. The image preprocessing includes normalization, brightness adjustment, random translation, rotation, and shearing.
[0097] S102. Construct a teacher network model and a first student network model.
[0098] like Figure 7 As shown, the teacher network model in this embodiment includes an input layer, a pre-trained Xception network model, an ECA Block attention mechanism, and a first densely connected classifier.
[0099] The construction of the teacher network model in this step specifically includes: connecting the input layer, the pre-trained Xception network model, the ECA Block attention mechanism, and the first densely connected classifier in sequence to construct the teacher network model.
[0100] Specifically, an ECA Block attention mechanism is added after the features extracted by the pre-trained Xception network model; the above teacher network model is constructed through a functional API.
[0101] The method for obtaining the pre-trained Xception network model in this embodiment is specifically as follows: load the pre-trained Xception network model built into the keras framework, set the include_top parameter to False when loading, and only load the convolutional base part of the pre-trained Xception network model, and do not load the densely connected classifier of the pre-trained Xception network model, that is, the second densely connected classifier.
[0102] The Xception network model in this embodiment is pre-trained on the ImageNet dataset.
[0103] Furthermore, if Figure 8 As shown in the figure, the ECA Block attention mechanism includes a global pooling layer and a Multiply layer, and the global pooling layer to the Multiply layer is an ECA Block function.
[0104] Furthermore, the role of the ECA Block attention mechanism in this embodiment is specifically as follows: the ECA Block attention mechanism generates channel weights through a one-dimensional convolution with a convolution kernel size of k; wherein k is adaptively determined by mapping the channel dimension C, as shown in the following formula:
[0105]
[0106] Among them, k represents the convolution kernel size, C represents the number of channels, odd represents an odd number, and γ and b are used to change the ratio between C, k, C and k.
[0107] The first student network model in this step adopts the classic MobileNet network model.
[0108] S103. Use the self-built data set to train the teacher network model.
[0109] When compiling the teacher network model, the Adam optimization algorithm is used with a learning rate of 0.0001.
[0110] In this step, the compiled teacher network model is trained using the training set of the self-built data set. Before training, the convolutional base part of the pre-trained Xception network model is frozen and trained for 10 epochs. If overfitting occurs, the training is manually stopped in advance and the model is saved. Then the model is fine-tuned, and the penultimate to 32nd layers of the model are unfrozen. The learning rate is reduced to 0.0005 / 10, and 10 epochs are retrained. The model is saved to obtain a trained teacher network model.
[0111] S104. Pre-train the first student network model using the transfer learning data set, and save the weights of the pre-trained first student network model.
[0112] In the process of pre-training the first student network model using the transfer learning dataset, in order to facilitate freezing the specified layer, each layer structure of the first student network model is named; when saving the weights of the pre-trained first student network model in the Keras framework, by_name is set to TRUE.
[0113] S105. Construct a second student network model, and load the pre-trained weights of the first student network model into the second student network model.
[0114] The structure of the first student network model in this embodiment is the same as the structure of the second student network model.
[0115] In this step, when constructing the second student network model, a function (ordinary Python function) is defined to write, and the second student network model is called through the function; the weights of the pre-trained first student network model are loaded into the second student network model, specifically: the weights of the pre-trained first student network model except the last layer to the sixtieth-last layer are loaded into the second student network model.
[0116] S106. Use the trained teacher network model and the self-built data set to train the second student network model after weight loading in a knowledge distillation manner to obtain a third student network model.
[0117] like Fig. 9 As shown, step S106 specifically includes:
[0118] S1061. Delete the original output layer of the first densely connected classifier in the trained teacher network model. After the original output layer is deleted, use the last dense layer of the first densely connected classifier as the output layer.
[0119] This step uses load_model to load the trained teacher network model, and then recreates the model. Specifically, the original output layer of the first densely connected classifier in the trained teacher network model is deleted. After the original output layer is deleted, the last dense layer of the first densely connected classifier is used as the output layer, thereby obtaining the teacher network model whose output layer is a dense layer.
[0120] S1062. Freeze all layers except the last layer to the sixtieth layer in the second student network model after weight loading.
[0121] S1063. Add temperature T to the category probability of the non-activated output of the teacher network model whose output layer is a dense layer to obtain Soft-Labels.
[0122] S1064. Use Soft-Labels and the original labels Hard-Labels of the self-built data set to simultaneously train the frozen second student network model to obtain a third student network model.
[0123] This embodiment labels the self-built data set to obtain the original labels Hard-Labels.
[0124] It is worth mentioning that, unlike the separate training model, in the knowledge distillation process, the objective function of this embodiment should be obtained by weighting the loss function corresponding to Soft-Labels and the loss function corresponding to Hard-Labels. Therefore, in the process of simultaneously training the frozen second student network model using Soft-Labels and the original label Hard-Labels of the self-built dataset, the objective function involved is as follows:
[0125] L=aL soft +bL hard
[0126] Where L represents the objective function, a and b represent L soft , L hard The weight, L soft represents the cross entropy of the softmax function and Soft-Labels generated by the frozen second student network model at temperature T, L hard Represents the cross entropy of the softmax function and Hard-Labels generated by the frozen second student network model at temperature T=1.
[0127] The L soft , as follows:
[0128]
[0129] in, represents the value of the non-activated output of the teacher network model with a dense layer on the i-th class at temperature T, It represents the value of the softmax function output of the frozen second student network model on the i-th category at temperature T, and n represents the total number of labels.
[0130] Said and They are as follows:
[0131]
[0132]
[0133] Among them, v i Represents the logits of the teacher network model whose output layer is a dense layer, z i represents the logits of the second student network model after freezing, and N represents the total number of labels.
[0134] The L hard , as follows:
[0135]
[0136] Among them, c i represents the value of the i-th category, c i Indicates the value range, the positive label is 1 and the negative label is 0.
[0137] Said As follows:
[0138]
[0139] Among them, N represents the total number of labels, z i Represents the logits of each category output.
[0140] The unified expression of the Softmax function is as follows:
[0141]
[0142] Among them, q i Represents the probability of each category output, z i represents the logits of each category output, and T represents temperature.
[0143] During step S1064, during model.fit, the training data (training set of the self-built data set) and the soft labels produced by the teacher network model whose output layer is a dense layer are simultaneously fed into the frozen second student network model; an if loop is used to judge: the Loss and accuracy on the training set, the Loss and accuracy on the validation set are output, and the training is stopped when the accuracy reaches the specified requirement, and the trained second student network model is retained to obtain the third student network model.
[0144] S107, obtaining a picture of a citrus leaf to be identified.
[0145] S108. Input the image of the citrus leaves to be identified into the third student network model to obtain the disease identification result of the image of the citrus leaves to be identified.
[0146] Those skilled in the art will appreciate that all or part of the steps in the method for implementing the above embodiments may be completed by instructing related hardware through a program, and the corresponding program may be stored in a computer-readable storage medium.
[0147] It should be noted that although the method operations of the above embodiments are described in a specific order in the accompanying drawings, this does not require or imply that these operations must be performed in this specific order, or that all the operations shown must be performed to achieve the desired results. On the contrary, the steps depicted can be performed in a different order. Additionally or alternatively, some steps can be omitted, multiple steps can be combined into one step, and / or one step can be decomposed into multiple steps.
[0148] Embodiment 2:
[0149] like Fig.10 As shown, this embodiment provides a citrus leaf disease recognition system based on dual transfer learning, which includes a first acquisition unit 1001, a first construction unit 1002, a first training unit 1003, a second training unit 1004, a second construction unit 1005, a third training unit 1006, a second acquisition unit 1007 and a disease recognition unit 1008. The specific functions of each unit are as follows:
[0150] The first acquisition unit 1001 is used to acquire a transfer learning data set and a self-built data set, wherein the transfer learning data set includes a plurality of plant disease leaf picture sets downloaded by a crawler and a citrus healthy leaf picture set downloaded by a crawler, and the self-built data set includes a self-collected citrus disease leaf picture set and a self-collected citrus healthy leaf picture set;
[0151] A first construction unit 1002 is used to construct a teacher network model and a first student network model;
[0152] The first training unit 1003 is used to train the teacher network model using a self-built data set;
[0153] The second training unit 1004 is used to pre-train the first student network model using the transfer learning data set and save the weight of the pre-trained first student network model;
[0154] The second construction unit 1005 is used to construct a second student network model and load the pre-trained first student network model weights into the second student network model;
[0155] The third training unit 1006 is used to train the second student network model after weight loading by using the trained teacher network model and the self-built data set in a knowledge distillation manner to obtain a third student network model;
[0156] The second acquisition unit 1007 is used to acquire the citrus leaf image to be identified;
[0157] The disease identification unit 1008 is used to input the citrus leaf image to be identified into the third student network model to obtain the disease identification result of the citrus leaf image to be identified.
[0158] Embodiment 3:
[0159] like Fig.11 As shown, this embodiment provides a computer device, which includes a processor 1102, a memory, an input device 1103, a display device 1104 and a network interface 1105 connected through a system bus 1101. Among them, the processor 1102 is used to provide computing and control capabilities, the memory includes a non-volatile storage medium 1106 and an internal memory 1107, the non-volatile storage medium 1106 stores an operating system, a computer program and a database, and the internal memory 1107 provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium 1106. When the computer program is executed by the processor 1102, the citrus leaf disease identification method of the above-mentioned embodiment 1 is implemented as follows:
[0160] Acquire a transfer learning data set and a self-built data set, wherein the transfer learning data set includes a plant disease leaf picture set downloaded by a crawler and a citrus healthy leaf picture set downloaded by a crawler, and the self-built data set includes a self-collected citrus disease leaf picture set and a self-collected citrus healthy leaf picture set;
[0161] Construct the teacher network model and the first student network model;
[0162] Use self-built data sets to train the teacher network model;
[0163] Pre-training the first student network model using the transfer learning data set, and saving the weights of the pre-trained first student network model;
[0164] Construct a second student network model and load the pre-trained weights of the first student network model into the second student network model;
[0165] Use the trained teacher network model and the self-built data set to train the second student network model after weight loading in the way of knowledge distillation to obtain the third student network model;
[0166] Obtain the image of the citrus leaf to be identified;
[0167] The image of the citrus leaves to be identified is input into the third student network model to obtain the disease recognition result of the image of the citrus leaves to be identified.
[0168] Embodiment 4:
[0169] This embodiment provides a storage medium, which is a computer-readable storage medium, storing a computer program. When the computer program is executed by a processor, the citrus leaf disease identification method of the above embodiment 1 is implemented as follows:
[0170] Acquire a transfer learning data set and a self-built data set, wherein the transfer learning data set includes a plant disease leaf picture set downloaded by a crawler and a citrus healthy leaf picture set downloaded by a crawler, and the self-built data set includes a self-collected citrus disease leaf picture set and a self-collected citrus healthy leaf picture set;
[0171] Construct the teacher network model and the first student network model;
[0172] Use self-built data sets to train the teacher network model;
[0173] Pre-training the first student network model using the transfer learning data set, and saving the weights of the pre-trained first student network model;
[0174] Construct a second student network model and load the pre-trained weights of the first student network model into the second student network model;
[0175] Use the trained teacher network model and the self-built data set to train the second student network model after weight loading in the way of knowledge distillation to obtain the third student network model;
[0176] Obtain the image of the citrus leaf to be identified;
[0177] The image of the citrus leaves to be identified is input into the third student network model to obtain the disease recognition result of the image of the citrus leaves to be identified.
[0178] It should be noted that the computer-readable storage medium of the present embodiment may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above.
[0179] In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in combination with an instruction execution system, device, or device. In this embodiment, the computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, which carries a computer-readable program. This propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The computer-readable signal medium may also be any computer-readable storage medium other than a computer-readable storage medium, which may send, propagate, or transmit a program used by or in combination with an instruction execution system, device, or device. The computer program contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (radio frequency), etc., or any suitable combination of the above.
[0180] The computer readable storage medium can be written in one or more programming languages or a combination thereof to execute the computer program of the present embodiment, and the programming language includes an object-oriented programming language, such as Java, Python, C++, and also includes a conventional procedural programming language, such as C language or a similar programming language. The program can be executed entirely on the user's computer, partially on the user's computer, as an independent software package, partially on the user's computer and partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computer (e.g., using an Internet service provider to connect through the Internet).
[0181] In summary, compared with the existing method of using only the ImageNet dataset for transfer learning, the transfer learning dataset constructed by the present invention can more accurately train the feature extractor of the network, thereby improving the accuracy of transfer learning; in addition to solving the problem of low accuracy in small sample training, the present invention also adds an attention mechanism to the model to further improve the accuracy of citrus disease recognition. At the same time, the knowledge distillation method is adopted to reduce the model training parameters, which is convenient for the deployment of the model on the mobile terminal.
[0182] The above is only a preferred embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical solution and inventive concept of the present invention within the scope disclosed by the present invention, which shall fall within the protection scope of the present invention.
Claims
1. A citrus leaf disease identification method based on dual transfer learning, characterized in that: The method comprises: Acquire a transfer learning data set and a self-built data set, wherein the transfer learning data set includes a set of images of leaves with various plant diseases downloaded by a crawler and a set of images of healthy citrus leaves downloaded by a crawler, and the self-built data set includes a set of images of diseased citrus leaves collected by a self-collected computer and a set of images of healthy citrus leaves collected by a self-collected computer; Construct the teacher network model and the first student network model; Use self-built data sets to train the teacher network model; Pre-training the first student network model using the transfer learning data set, and saving the weights of the pre-trained first student network model; Construct a second student network model and load the pre-trained weights of the first student network model into the second student network model; Use the trained teacher network model and the self-built data set to train the second student network model after weight loading in the way of knowledge distillation to obtain the third student network model; Obtain the image of the citrus leaf to be identified; Inputting the citrus leaf image to be identified into the third student network model to obtain the disease identification result of the citrus leaf image to be identified; The method uses the trained teacher network model and the self-built data set to train the second student network model after weight loading in a knowledge distillation manner to obtain the third student network model, specifically including: The original output layer of the first densely connected classifier in the trained teacher network model is deleted, and after the original output layer is deleted, the last dense layer of the first densely connected classifier is used as the output layer; Freeze all layers except the last to the last sixtieth layer in the second student network model after weight loading; Add temperature T to the category probability of the non-activated output of the teacher network model whose output layer is a dense layer to obtain Soft-Labels; The frozen second student network model is trained simultaneously using Soft-Labels and the original labels Hard-Labels of the self-built dataset to obtain the third student network model; In the process of simultaneously training the frozen second student network model using Soft-Labels and the original labels Hard-Labels of the self-built data set, the objective function involved is as follows: <h2 style=";text-align:left;direction:ltr">L=aL<h2 style=";text-align:left;direction:ltr"> soft <h2 style=";text-align:left;direction:ltr"> +bL<h2 style=";text-align:left;direction:ltr"> hard Where L represents the objective function, a and b represent L soft , L hard The weight, L soft represents the cross entropy of the softmax function and Soft-Labels generated by the frozen second student network model at temperature T, L hard It represents the cross entropy of the softmax function and Hard-Labels generated by the frozen second student network model at temperature T = 1; The L soft , as follows: in, represents the value of the non-activated output of the teacher network model with a dense layer on the i-th class at temperature T, represents the value of the softmax function output of the frozen second student network model on the i-th category at temperature T, and n represents the total number of labels; Said and They are as follows: Among them, v i Represents the logits of the teacher network model whose output layer is a dense layer, z i represents the logits of the second student network model after freezing, and N represents the total number of labels; The L hard , as follows: Among them, c i represents the value of the i-th category, c i Indicates the value range, the positive label is 1 and the negative label is 0; Said As follows: Among them, N represents the total number of labels, z i Represents the logits of each category output.
2. The method for identifying citrus leaf diseases according to claim 1, characterized in that: The teacher network model includes an input layer, a pre-trained Xception network model, an ECA Block attention mechanism, and a first densely connected classifier; The construction of the teacher network model specifically includes: The input layer, the pre-trained Xception network model, the ECA Block attention mechanism, and the first densely connected classifier are sequentially connected to construct a teacher network model; The pre-trained Xception network model is used as a feature extraction network. The pre-trained Xception network model only loads the convolution base part and does not load the second densely connected classifier.
3. The method for identifying citrus leaf diseases according to claim 2, characterized in that: The ECA Block attention mechanism includes a global pooling layer and a Multiply layer, wherein the global pooling layer to the Multiply layer are ECA Block functions; The ECA Block attention mechanism generates channel weights through a one-dimensional convolution with a convolution kernel size of k; where k is adaptively determined by mapping the channel dimension C, as shown in the following formula: Among them, k represents the convolution kernel size, C represents the number of channels, odd represents an odd number, and γ and b are used to change the ratio between C, k, C and k.
4. The method for identifying citrus leaf diseases according to claim 1, characterized in that: The first student network model and the second student network model are the same; The first student network model adopts the classic MobileNet network model.
5. The method for identifying citrus leaf diseases according to claim 4, characterized in that: The loading of the pre-trained first student network model weights into the second student network model specifically includes: The weights of the pre-trained first student network model except the penultimate layer to the penultimate sixtieth layer are loaded into the second student network model.
6. A citrus leaf disease recognition system based on dual transfer learning, characterized in that: The system comprises: A first acquisition unit is used to acquire a transfer learning data set and a self-built data set, wherein the transfer learning data set includes a plurality of plant disease leaf picture sets downloaded by a crawler and a citrus healthy leaf picture set downloaded by a crawler, and the self-built data set includes a self-collected citrus disease leaf picture set and a self-collected citrus healthy leaf picture set; A first construction unit, used to construct a teacher network model and a first student network model; The first training unit is used to train the teacher network model using a self-built data set; A second training unit is used to pre-train the first student network model using the transfer learning data set and save the weight of the pre-trained first student network model; A second construction unit is used to construct a second student network model and load the pre-trained first student network model weights into the second student network model; The third training unit is used to train the second student network model after weight loading by using the trained teacher network model and the self-built data set in a knowledge distillation manner to obtain a third student network model; The second acquisition unit is used to acquire the image of the citrus leaf to be identified; A disease identification unit is used to input the citrus leaf picture to be identified into the third student network model to obtain a disease identification result of the citrus leaf picture to be identified; The method uses the trained teacher network model and the self-built data set to train the second student network model after weight loading in a knowledge distillation manner to obtain the third student network model, specifically including: The original output layer of the first densely connected classifier in the trained teacher network model is deleted, and after the original output layer is deleted, the last dense layer of the first densely connected classifier is used as the output layer; Freeze all layers except the last to the last sixtieth layer in the second student network model after weight loading; Add temperature T to the category probability of the non-activated output of the teacher network model whose output layer is a dense layer to obtain Soft-Labels; The frozen second student network model is trained simultaneously using Soft-Labels and the original labels Hard-Labels of the self-built dataset to obtain the third student network model; In the process of simultaneously training the frozen second student network model using Soft-Labels and the original labels Hard-Labels of the self-built data set, the objective function involved is as follows: <h2 style=";text-align:left;direction:ltr">L=aL<h2 style=";text-align:left;direction:ltr"> soft <h2 style=";text-align:left;direction:ltr"> +bL<h2 style=";text-align:left;direction:ltr"> hard Where L represents the objective function, a and b represent L soft , L hard The weight, L soft represents the cross entropy of the softmax function and Soft-Labels generated by the frozen second student network model at temperature T, L hard It represents the cross entropy of the softmax function and Hard-Labels generated by the frozen second student network model at temperature T = 1; The L soft , as follows: in, represents the value of the non-activated output of the teacher network model with a dense layer on the i-th class at temperature T, represents the value of the softmax function output of the frozen second student network model on the i-th category at temperature T, and n represents the total number of labels; Said and They are as follows: Among them, v i Represents the logits of the teacher network model whose output layer is a dense layer, z i represents the logits of the second student network model after freezing, and N represents the total number of labels; The L hard , as follows: Among them, c i represents the value of the i-th category, c i Indicates the value range, the positive label is 1 and the negative label is 0; Said As follows: Among them, N represents the total number of labels, z i Represents the logits of each category output.
7. A computer device comprising a processor and a memory for storing a program executable by the processor, characterized in that: When the processor executes the program stored in the memory, the citrus leaf disease identification method described in any one of claims 1 to 5 is implemented.
8. A storage medium storing a program, characterized in that: When the program is executed by a processor, the citrus leaf disease identification method according to any one of claims 1 to 5 is implemented.
