Research Article Can Deep Learning Identify Tomato Leaf Disease?

,


Introduction
Tomato is a widely cultivated crop throughout the world, which contains rich nutrition, unique taste, and health effects, so it plays an important role in the agricultural production and trade around the world.Given the importance of tomato in the economic context, it is necessary to maximize productivity and product quality by using techniques.Corynespora leaf spot disease, early blight, late blight, leaf mold disease, septoria leaf spot, two-spotted spider mite, virus disease, and yellow leaf curl disease are 8 common diseases in tomato [1][2][3][4][5][6][7][8]; thus, a real time and precise recognition technology is essential.
Training deep neural networks from scratch needs amounts of data and expensive computational resources.Meanwhile, we sometimes have a classification task in one domain, but we only have enough data in other domains.Fortunately, transfer learning can improve the performance of deep neural networks by avoiding complex data mining and data-labeling efforts [28].In practice, transfer learning consists of two ways [29].One option is to fine-tune the networks weights by using our data as input; it is worth nothing that the new data must be resized to the input size of the pretrained network.Another way is to obtain the learned weights from the pretrained network and apply the weights to the target network.
In this work, first, we compared the performance between SGD [30] and Adaptive Moment Estimation (Adam) [30,31] in identifying tomato leaf disease.These optimization methods are based on the pretrained networks AlexNet [21], GoogLeNet [22], and ResNet [26].Then, the network architecture with the highest performance was selected and experiments on effect of two hyperparameters (i.e., batch size and number of iterations) on accuracy were carried out.Next,

Hypothesis set H
Final assumption g ≈ f we utilized the network with the suitable hyperparameters, which was obtained from the previous experiments, to discuss the impact of different network structures on recognition tasks.We believe this makes sense for researchers who choose to fine-tune pretrained systems for other similar issues.The rest of this paper is organized as follows.Section 2 displays an overview of related works.Section 3 introduces the dataset and three deep convolutional neural networks, i.e., AlexNet, GoogLeNet, and ResNet.Section 4 presents the experiments and results in this work.Section 5 concludes the paper.

Related Work
The research of agricultural disease identification based on computer vision has been a hot topic.In the early years, the traditional machine learning methods and shallow networks were extensively adopted in the agricultural field.
Sannakki et al. [32] proposed to use k-means based clustering performed on each image pixel to isolate the infected spot.They obtained the result that the Grading System they built by machine vision and fuzzy logic is very useful for grading the plant disease.Samanta et al. [33] proposed a novel histogram based scab diseases detection of potato and applied color image segmentation technique to exact intensity pattern.They got the best classification accuracy of 97.5%.Pedro et al. [34] applied fuzzy decisionmaking to identify weed shape, with fuzzy multicriteria decision-making strategy; they achieved the best accuracy of 92.9%.Cheng and Matson [35] adopted Decision Tree, Support Vector Machine (SVM), and Neural Network to identify weed and rice; the best accuracy they achieved is 98.2% by using Decision Tree.Sankaran and Ehsani [36] used quadratic discriminant analysis (QDA) and k-nearest neighbour (kNN) to classify citrus leaves infected with canker and Huanglongbing (HLB) from healthy citrus leaves; they got the highest overall accuracy of 99.9% by kNN.
Recently, deep learning methods have been applied in identifying plant disease widely.Cheng et al. [37] used ResNet and AlexNet to identify agricultural pests.At the same time, they carried out comparative experiments with SVM and BP neural networks; finally, they got the best accuracy of 98.67% by ResNet-101.Ferreiraa et al. [38] utilized ConvNets to perform weed detection in soybean crop images and classify these weeds among grass and broadleaf.The best accuracy they achieved is 99.5%.Sladojevic et al. [39] built a deep convolutional neural network to automatically classify and detect 15 categories of plant leaf diseases.Meanwhile, their model was able to distinguish plants from their surroundings.They got an average accuracy of 96.3%.Mohanty et al. [40] trained a deep convolutional neural network based on the pretrained AlexNet and GoogLeNet to identify 14 crop species and 26 diseases.They achieved an accuracy of 99.35% on a held-out test set.Sa et al. [41] proposed a novel approach to fruit detection by using deep convolutional neural networks.They adapted Faster Region-based CNN (Faster R-CNN) model, through transfer learning.They got the F1 score with 0.83 in a field farm dataset.

Materials and Methods
This paper concentrates on identifying tomato leaf disease by deep learning.In this section, the abstract mathematical model about identifying tomato leaf disease is displayed at first.Meanwhile, the process of typical CNN is described with formulas.Then, the dataset and data augmentation are presented.Finally, we introduced three powerful deep neural networks adopted in this paper, i.e., AlexNet, GoogLeNet, and ResNet.
The main process of tomato leaf disease identification in this work can be abstracted as a mathematical model (see Figure 1).First, we assume the mapping function from tomato leaves to diseases is  :  →  and then send the training samples to the optimization method.The hypothesis set  means possible objective functions with different parameters; through a series of parameters update, we can get the final assumption  ≈ .The typical CNN process can be represented with following formulas.Firstly, send the training samples (i.e., training tomato leaf images) to the classifier (i.e., AlexNet, GoogLeNet, and ResNet).Then, convolution operation is carried out; that is, a number of filters slide over the feature map of the previous layer, and the weight matrices do dot product.
where (⋅) is activation function, typically a Rectifier Linear Unit (ReLU) [42] function: is the number of kernels of the certain layer,  −1  represents the feature map of the previous layer,     is the weight matrix, and    is the bias term.Max-pooling or average pooling is conducted after the convolution operation.Furthermore, the learned features are sent to the fully connected layer.The softmax regression always follows the final fully connected layer, an input  will get the probability of belonging to class .

𝑝 (𝑦 = 𝑖 | 𝑥
where  is the response variable (i.e., predict label),  is the number of categories, and  is the parameters of our model.

Data Augmentation.
Deep convolutional neural networks contain millions of parameters; thus, massive amounts of data is required.Otherwise, the deep neural network may be overfitting or not robust.The most common method to reduce overfitting on image dataset is to enlarge the dataset manually and conduct label-preserving transformations [21,44].
In this work, at first, the raw image dataset was divided into 80% training samples and 20% testing samples, and then the data augmentation procedure was conducted: (1) flipping  [21].The architecture of AlexNet utilized in this paper is displayed in Figure 3.The AlexNet architecture consists of five convolutional layers (i.e., conv1, conv2, and so on), some of which are followed by maxpooling layers (i.e., pool1, pool2, and pool5), three fully connected layers (i.e., fc6, fc7, and fc8), and a liner layer with softmax activation in output.In order to reduce overfitting in the fully connected layers, a regularization method called "dropout" is used (i.e., drop6, drop7) [21].The ReLU activation function is applied to each of the first seven layers (i.e., relu1, relu2, and so on) [45].In Figure 3, the notation ×× in each convolutional layer represents the size of the feature map for each layer, 4096 represents the number of neurons of the first two fully connected layers.The number of neurons of the final fully connected layer was modified to 9, since the classification problem in this work has 9 categories.In addition, the size of input images must be shaped to 227×227, which meets the input pixel size requirement of AlexNet.

GoogLeNet.
GoogLeNet is an inception architecture [22], which is the winner of ILSVRC 2014 and owns roughly 6.8 million parameters.The architecture of GoogLeNet is presented in Figure 4.The inception module is inspired by the network in network [46] and uses a parallel combination of 1 × 1, 3 × 3, and 5 × 5 convolutional layer along with 3 × 3 max-pooling layer [45]; the 1 × 1 convolutional layer before 3 × 3 and 5 × 5 convolutional layer reduces the spatial dimension and limits the size of GoogLeNet.The whole architecture of GoogLeNet is stacked by inception module on top of each other (See Figure 4), which has nine inception modules, two convolutional layers, four max-pooling layers, one average pooling layer, one fully connected layer, and a linear layer with softmax function in the output.GoogLeNet uses dropout regularization in the fully connected layer and applies the ReLU activation function in all of the convolutional layers [29].In this work, the last three layers of GoogLeNet were replaced by a fully connected layer, a softmax layer, and a classification layer; the fully connected layer was modified to 9 neurons, which is equal to the categories in the tomato leaf disease identification problem.
The size requested of input image of GoogLeNet is 224 × 224.

ResNet.
The deep residual learning framework is proposed for addressing the degradation problem.ResNet consists of many stacked residual units, which won the first place in ILSVRC 2015 and COCO 2015 classification challenge with error rate of 3.57% [26].Each unit can be expressed in the following formulas [47]: where   and  +1 are input and output of the l-th unit, and  is a residual function.In [26]ℎ(  ) =   is an identity mapping and  is a ReLU function [42].A "bottleneck" building block is designed for ResNet (See Figure 5) and comprises two 1 × 1 convolutions with a 3 × 3 convolution in between and a direct skip connection bypassing input and output.

Experiments and Results
In this section, we reveal the experiments and discuss the experimental results.All the experiments were implemented in Matlab under Windows 10, using the GPU NVIDIA GTX1050 with 4G video memory or NVIDIA GTX1080Ti with 11G video memory.In this paper, overall accuracy was regarded as the evaluation metric in every experiment on tomato leaf disease detection, which means the percentage of samples that are correctly classified: accuracy = true positive + true negative positive + negative (6) where "true positive" is the number of instances that are positive and classified as positive, "true negative" is the number of instances that are negative and classified as negative, and the denominator represents the total number of samples.In addition, the training time was regarded as an additional performance metric of the network structure experiment.

Experiments on Optimization
Methods.The first experiment is designed for seeking the suitable optimization method between SGD [30] and Adam [30,31] in identifying tomato leaf diseases, combining with the pretrained network AlexNet, GoogLeNet, and ResNet, respectively.In this experiment, the hyperparameters were set as follows for each network: the batch size was set to 32, the initial learning rate was set to 0.001 and dropped by a factor of 0.5 every 2 epochs, and the max epoch was set to 5; i.e., the number of iterations is 6240.So far as SGD optimization method, the momentum was set to 0.9.For Adam, the gradient decay rate  1 was set to 0.9, the squared gradient decay rate  2 was set to 0.999, and the denominator offset  was set to 10 −8 [31].The accuracy of different networks is displayed in Table 3.In addition, we choose the better results in each deep neural network to show the training loss against number of iterations during the finetuning process (See Figure 6).The words inside parenthesis indicate the corresponding optimization method.In Table 3, the ResNet with SGD optimization method gets the highest test accuracy 96.51%.In identifying tomato leaf diseases, the performance of Adam optimization method is inferior to the SGD optimization method, especially in combining with AlexNet.In the following paper, AlexNet (SGD), GoogLeNet (SGD), and ResNet (SGD) are referred to as AlexNet, GoogLeNet, and ResNet, respectively.
As it can be seen in Figure 6, the training loss of ResNet drops rapidly in the earlier iterations and tends to stable after 3000 iterations.Consistent with Table 3, the performance of  AlexNet and GoogLeNet is similar and both inferior to the ResNet.

Experiments on Batch Size and Number of Iterations.
From the experiment on optimization methods, the ResNet obtains the highest classification accuracy.Next, we evaluated the effects of batch size and the number of iterations on the performance of the ResNet.The batch size was set to 16, 32, and 64, respectively.Meanwhile, the number of iterations was set to 2496, 4992, and 9984.The classification accuracy of different training scenarios is given in Table 4.At the same time, the classification accuracy of each label's representative leaf disease category (See Table 1) is given.In this experiment, the initial learning rate was set to 0.001 and dropped by a factor of 0.5 every 2496 iterations.In  iterations 4992.As shown in Table 4, whether increasing the number of iterations or batch size, the performance of corresponding models has not been improved significantly in identifying tomato leaf disease.A small batch size with a medium number of iterations is quite effective in this work.Moreover, a larger batch size and number of iterations increases the training duration.We have not tried higher or lower values for the attempted parameters, since different classification task may have various suitable parameters, and it is hard to give a certain rule in setting hyperparameters.

Experiments on Full Training and Fine-Tuning of ResNet.
This section is designed for exploring the performance of CNN by changing the structure of the models.In practical, a deep CNN always owns a large size which means a large number of parameters.Thus, full training of a deep CNN requires extensive computational resources and is timeconsuming.In addition, full training of a deep CNN may led to overfitting when the training data is limited.So we compared the performance of the pretrained CNN through full training and fine-tuning their structures.We changed the structure of ResNet, and combination of the best parameters from the front experiments was utilized.
"fc"), fine-tuning (37-"fc", 79-"fc", 111-"fc", 141-"fc", 163-"fc").The accuracy and training time of different network structure are presented in Table 5.At first, the batch size and 4992 iterations were combined, the initial learning rate was set to 0.001 and dropped by a factor of 0.1 every 2496 iterations.In order to get more convincing conclusions, ResNet (16,9984), which gets the second place in Table 4, was also used to execute the experiments.In Table 5, the accuracy and training time of different network structures are presented.In two cases, i.e., the 4992 iterations and 9984 iterations of ResNet, the accuracy of the model from the 37 layer fine-tuning structure are higher than that of the full training model.In the case where the number of iterations is 4992, the accuracy of the model from the 79 layer fine-tuning structure is equal to that of the full training model.The final column of the Table 5 represents the training time of the corresponding network, and it is clear that the training time of the fine-tuning models is greatly lowered than the full training model.Because the gradients of the frozen layers do not need to be computed, freezing the weights of initial layers can speed up network training.We observe that the moderate fine-tuning models (37-"fc", 79-"fc", 111-"fc") always led to a performance superior or approximately equal to the full training models.Thus, we suggest that, for practical application, the moderate finetuning models may be a good choice.Especially for the researcher who holds massive data, the fine-tuning models may achieve good performance while saving computational resources and time.
Moreover, the features of the final fully connected layer of ResNet (16, 4992, 37-"fc") were examined by utilizing the t-distributed Stochastic Neighbour Embedding (t-SNE) algorithm (see Figure 7) [48].1176 test images were used to extract the features.In Figure 7, different colors represent different labels; the corresponding disease categories of the labels were listed in Table 1.As shown in Figure 7, 9 different color points are clearly separated, which indicates that the features learned from the ResNet with the optimal structure can be used to classify the tomato leaf disease precisely.

Conclusion
This paper concentrates on identifying tomato leaf disease using deep convolutional neural networks by transfer learning.The utilized networks are based on the pretrained deep learning models of AlexNet, GoogLeNet, and ResNet.First we compared the relative performance of these networks by using SGD and Adam optimization method, revealing that the ResNet with SGD optimization method obtains the highest result with the best accuracy, 96.51%.Then, the performance evaluation of batch size and number of iterations affecting the transfer learning of the ResNet was conducted.A small batch size of 16 combining a moderate number of iterations of 4992 is the optimal choice in this work.Our findings suggest that, for a particular task, neither large batch size nor large number of iterations may improve the accuracy of the target model.The setting of batch size and number of iterations depends on your data set and the utilized network.Next, the best combined model was used to finetune the structure.Fine-tuning ResNet layers from 37 to "fc" obtained the highest accuracy 97.28% in identifying tomato leaf disease.Based on the amount of available data, layer-wise fine-tuning may provide a practical way to achieve the best performance of the application at hand.We believe that the results obtained in this work will bring some inspiration to other similar visual recognition problems, and the practical study of this work can be easily extended to other plant leaf disease identification problems.

Figure 6 :
Figure 6: The training loss during the fine-tuning process.

Figure 7 :
Figure 7: Two-dimensional scatter plot of high-dimensional features generated with t-SNE.

Table 1 :
The raw tomato leaf dataset.
(7) image from left to right; (2) flipping the image from top to bottom; (3) flipping the image diagonally; (4) adjusting the brightness of image, setting the max delta to 0.4; (5) adjusting the contrast of image, setting the ratio from 0.2 to 1.5; (6) adjusting the hue of image, setting the max delta to 0.5;(7)adjusting the saturation of image, setting the ratio from 0.2 to 1.5; (8) rotating the image by 90 ∘ and 270 ∘ , respectively.The final dataset is shown in Table2, and the label in the first row represents the disease categories which are given in Table1.

Table 2 :
The final tomato leaf dataset.

Table 4
, the best overall classification accuracy 97.19% is got by the ResNet combining with batch size 16 and

Table 4 :
Classification accuracies with different parameters during fine-tuning of the ResNet.The numbers inside parenthesis indicate batch size and number of iterations.In this experiment, the last three layers of ResNet were modified to a fully connected layer (denoted as "fc"), a softmax layer, and a classification layer, and the fully connected layer owns 9 neurons.The structure was changed by freezing the weights of a certain number of layers in the network by setting the learning rate in those layers to zero.During training, the parameters of the frozen layers are not updated.Full training and finetuning are defined by the number of training layers, i.e., full training (

Table 5 :
Accuracies and training time in different network structures.The values inside parenthesis denote batch size, number of iterations, and training layers.