Frontiers in Computing and Intelligent Systems ISSN: 2832-6024 | Vol. 2, No. 3, 2022 75 Identification of tea leaf diseases based on deep transfer learning Wei Wu Taishan University, Tai'an 271000, China Abstract: Tea trees are often vulnerable to diseases and insect pests in the process of growth, resulting in the decline of tea production and quality. It is of great significance to identify and prevent tea leaf diseases in time to ensure the steady increase of tea. This study proposes a tea leaf disease identification method based on deep transfer learning, which improves the recognition accuracy of the model through knowledge transfer. Besides, for the unbalanced distribution of the number of samples, the cross- entropy loss function is replaced with the focal loss function, which further improves the identification effect of the model. The experiment shows that the identification model of tea leaf disease proposed in this study can achieve the accuracy of more than 90.42%, which verifies the effectiveness of this research and has important theoretical and practical significance in promoting the development of intelligent agriculture. Keywords: Neural network; Deep learning; Transfer learning; Tea leaf disease. 1. Introduction Tea tree is an important economic crop, and tea leaf disease is one of the important factors affecting the normal growth of tea. It is one of the important measures to ensure the steady growth of tea production and quality, which has important economic value and practical significance. In the past years, the methods of identifying tea leaf disease were mainly through expert diagnosis or consulting experienced farmers. However, expert consultation may have the disadvantage of high cost and lack of timeliness. Due to individual limitations, the most experienced farmers cannot accurately identify all species of leaf pests and diseases. Therefore, in the context of smart agriculture, it has become an important trend to promote the identification of leaf diseases and pests to promote the tea production. In previous years, the traditional machine learning method was mainly used to identify tea leaf diseases. This method mainly manually extracts and handles the leaf shape, color, texture and other characteristics of different diseases and pests, and then adopts methods such as K-means, Support Vector Machines (SVM), and Bayesian to achieve classification. For example, Hossain et al. used a support vector machine to classify and identify the extracted image features of tea leaf disease. Shao et al. used the K-means algorithm for tea leaf bud recognition. The classification accuracy of traditional machine learning methods largely depends on the effect of manual design features. However, in some high noise environment with complex background, the image recognition accuracy will be greatly reduced. With the development of big data technology and the continuous improvement of the computing ability of hardware, deep learning technology has been quickly applied to the tea leaf disease identification. Although it belongs to the field of machine learning, deep learning emphasizes the use of deep network construction and convolution operation to improve the nonlinear expression ability of data. Compared with traditional machine learning methods, deep learning has better feature learning ability. It shows an efficient recognition effect even when dealing with the classification problem of complex images, including its successful application in the field of tea leaf disease recognition. For example, the identification network of tea leaf diseases can achieve high recognition accuracy by adjusting the network parameters and the addition of dropout. A CNNs model named LeafNet was developed to automatically extract the features of tea plant diseases from images, which was superior in the recognition of tea leaf diseases compared to the MLP and SVM algorithms. Deep learning requires a large number of labeled samples for model training to prevent overfitting. However, some samples of leaf disease types are not easy to obtain in practice, resulting in the training process can't effectively converge. It's important for the neural network model to be trained with high recognition accuracy even though the sample size is few, which is the key to ensure the further popularization of deep learning in agriculture. Inspired by the characteristics of human learning, transfer learning can effectively solve the problem of sample insufficiency, and attract increasing attention through the years. This method does not require a large number of training samples when encountering a new category, but rather summarizes them from the existing knowledge to achieve knowledge transfer, which is therefore very close to the human learning style. In this study, we proposed a neural network model based on transfer learning to identify tea leaf diseases. The Inception-V3 network is used to extract the features of tea leaf image, and the loss function is improved to realize the promotion of identification accuracy. 2. Related theory 2.1. Convolutional neural network Convolutional neural network (CNN) is an important foundation for deep learning to achieve breakthrough in image classification and recognition. Different from the traditional machine learning method, the neural network based on CNN can realize the end-to-end automatic feature extraction. Typical CNN architecture mainly includes convolutional layer, pooling layer and fully connected layer. (1) Convolutional layers The convolutional layer performs the convolution 76 operation by convolution kernel, adding an offset vector resulting the output. The model parameters of the convolutional layer include the convolution kernel part and the offset part. Convolutional networks of different complexity can be designed by the superposition of multiple convolutional layers. The characteristic output of the i-th layer convolutional network can be expressed as: β„Žπ‘– = 𝑓(β„Žπ‘–βˆ’1π‘Šπ‘– + 𝑏𝑖) Where π‘Šπ‘– is the weight of the convolution kernel in i-th layer, 𝑏𝑖 is the standard deviation, β„Žπ‘–βˆ’1 is the feature input of the convolutional layer (β„Ž0 denotes the input image), and f is the activation function. (2) Pooling layers The function of pooling layers is reducing the excessive sensitivity of the convolutional layer to the position, so that the model also has a good recognition ability of the same object in different positions. Commonly used pooling methods include maximum pooling and average pooling, which calculate the maximum and average values in the pooling window respectively. (3) Fully connected layer After feature extraction in the deep network, one or more layers are usually followed for the image classification task. The final output layer usually uses the softmax function to map the output values into a probability distribution in which all values are positive and the sum is 1. The j-th output result can be expressed as: 𝑂𝑗 = π‘ π‘œπ‘“π‘‘π‘šπ‘Žπ‘₯(𝑧𝑗) = 𝑒𝑧𝑗/βˆ‘ π‘’π‘§π‘˜ 𝐾 π‘˜=1 Where j∈ {1…, K}, K is the output numbers of the last connection layer, and z represents the output vector of the last connection layer. 2.2. Transfer learning Ordinary deep learning models are trained for specific data or tasks. When these data or tasks change, the learned models usually have poor generalization, and need to be trained again. However, the knowledge learned by the model can usually be reused by similar tasks. Transfer learning is a technique to study how to reuse the learned knowledge, so as to avoid training model from scratch, and improve the training efficiency and stability of the model. A typical transfer learning approach is knowledge transfer from the pre-trained model. This method first pre-trains the network model with a large amount of data related to the target task, and the learned model parameters, namely the knowledge, are preserved. Based on the learned knowledge, the target data set is trained with finetuning, so as to learn the knowledge information of the new data set. 3. Proposed approach This study proposes a tea leaf disease identification method based on deep transfer learning, which is then introduced from the aspects of image preprocessing, feature extraction, transfer learning and loss function respectively. 3.1. Image preprocessing The data sets of tea leaf disease selected in this study were all collected in the tea garden in Tai'an, Shandong province, with a total of 694 images, including 141 images of tea white star, 107 images of tea leaf blight, 186 images of tea wheel spot and 260 images of normal leaves, with the corresponding label of 0 to 3. The labels were converted into one-hot vector to correspond to the output of the last layer of the neural network. For the original label i, the length of the transformed one-hot vector is 4, the i-th element is 1, and the remaining values are 0. For example, the original label of tea wheel spot disease is 1, and the label after conversion to the one-hot form is [0,0,1,0]. Classes Number of original images Number of images after preprocessing Tea white star disease 141 1242 Leaf blight disease 107 819 Tea wheel spot disease 186 1228 Normal Leaves 260 1376 Figure 1. Sample data size before and after data augmentation Deep learning methods require large amounts of samples for training, while the actual amount of sample data collected in tea garden is obviously insufficient. In order to reduce the problem of overfitting due to data insufficiency, data enhancement technology such as random rotation, random cropping, random color change and brightness adjustment were used to expand the collected tea leaf images. The total of 4665 images were obtained through data enhancement. Images of each type was randomly divided into training set and test set in a ratio of 7:3. 3.2. Feature extraction In this study, the Inception V3 model was used for feature extraction. The Inception module used in this model does not only pursue the depth of the network like most popular CNN model, but also balances the width and depth of the network, which helps to enhance the feature extraction ability of the network. At the same time, it divides large convolution kernel into smaller ones, which improves the training efficiency of the model by reducing the number of parameters and reduces the problem of model overfitting as well. 3.3. Transfer learning strategy The classification model of tea leaf disease proposed in this study consists of the feature extraction part and classification part. The feature extraction part uses the Inception V3-based network model for transfer learning, and the classification part is implemented based on the Softmax layer. The training process is described as follows: (1) The network layer before the linear connection layer of the Inception V3 model is defined as the bottleneck layer. The parameters of the bottleneck layer are pre-trained using the public dataset ImageNet and kept fixed in the following model training. The model pre-trained by ImageNet can help the target task converge quickly and enhance the generalization ability of identification. (2) Three consecutive fully connected layers and one Softmax layer are connected behind the bottleneck layer. The processed images of tea leaf disease are used as the input of the model. Parameters of feature extraction part are frozen, only parameters of the subsequent classification part are fine- tuned. In this way, the neural network of tea leaf disease identification can be trained more quickly and accurately. 3.4. Loss function The loss function is used to measure the difference between the predicted results and the true labels, and updates the 77 model parameters by back-propagation to reduce the prediction error. Cross-entropy loss function is commonly used in the classification task. The smaller the value of the cross-entropy indicates, the closer the actual output of the model is related to the expected result. However, the cross- entropy loss function has the same loss weight for all classes, which is not superior in this study with an unbalanced sample type. Therefore, the focal loss function was introduced instead of the cross-entropy loss function, and the final loss function is: FL(ΞΈ) = βˆ’βˆ‘ βˆ‘ 𝛼(1 βˆ’ �̂�𝑐 𝑖)𝛾𝑦𝑐 π‘–π‘™π‘œπ‘” 𝐾 𝑐=1 𝑁 𝑖=1 �̂�𝑐 𝑖 WhereΞΈrepresents the parameters of the model training, N is the number of training samples, K is the total number of classifications, y and yΜ‚ represents the true labels and the predictions respectively, yc i representing the c-th scalar value in the true label corresponding to the i-th sample, and yΜ‚c i representing the c-th scalar value in the results predicted by the i-th sample. The balance factorΞ± is used to solve the problem of unbalanced distribution of different categories of data, Ξ³ is used to reduce the loss of easy to distinguish samples, and to improve the importance of difficult to identify samples, so that the model can be trained to extract more important information hidden in the data. Figure 2. Comparison of training accuracy and validation accuracy based on random parameters and transfer learning 4. Experimental results and analysis To verify the algorithm of this study, several experiments were performed. The input image size was uniformly scaled to 299Γ—299, the learning rate was initialized to 0.001, and the loss function was optimized by using the small-batch stochastic gradient descent algorithm for model training. Figure 2 shows the comparison of training accuracy and validation accuracy based on random parameters and transfer learning. It can be seen that transfer learning is trained based on the learned knowledge, which can make the model converge faster. The training accuracy and verification accuracy are higher, which verifies the effectiveness of transfer learning strategy in the identification of tea leaf diseases. This effectiveness benefits from the pre-trained model that already has the ability to identify the geometry, shape, attitude and other information of the object. This prior knowledge can be very quickly transferred to the recognition task of tea leaf disease images. Table 1. Comparison of the classification accuracy based on cross entropy loss function and focal loss function Loss function type Top1 accuracy (%) Cross-entropy loss function 89.75 Focus loss function 90.42 Table 1 compares the top1 classification accuracy of the tea leaf disease using the cross-entropy loss function and the focus loss function. It can be seen that the accuracy using the focal loss function is promoted by 0.67% compared with the cross-entropy loss function, which proves the effectiveness of the improved loss function. 5. Summary Based on the strategy of deep transfer learning, this study constructed a deep learning network for the recognition of tea leaf disease. The focus loss function was used to solve the problem of unbalanced data distribution in samples. The accuracy could reach more than 90.42%, which verified the effectiveness of transfer learning in the application of tea leaf disease recognition. This study will provide important theoretical support for further achievements transformation, and has important theoretical and practical significance in the development of intelligent agriculture. Acknowledgments This work was supported by the Tai'an Science and technology innovation development project under Grant No.2021NS097. References [1] Hossain S, Mou R M, Hasan M M, et al.Recognition and detection of tea leaf's diseases using support vector machine[C]//2018 IEEE 14th International Colloquium on Signal Processing & Its Applications (CSPA).IEEE, 2018: 150- 154. [2] Shao P, Wu M, Wang X, et al.Research on the tea bud recognition based on improved k-means algorithm[C]//MATEC Web of Conferences.EDP Sciences, 2018, 232: 03050. [3] Xiaoxiao S U N, Shaomin M U, Yongyu X U, et al.Image recognition of tea leaf diseases based on convolutional neural network[C]//2018 International Conference on Security, Pattern Analysis, and Cybernetics (SPAC).IEEE, 2018: 304- 309. [4] Chen J, Liu Q, Gao L.Visual tea leaf disease recognition using a convolutional neural network model[J].Symmetry, 2019, 11(3): 343. [5] Szegedy C, Vanhoucke V, Ioffe S, et al.Rethinking the inception architecture for computer vision[C].Computer Vision and Pattern Recognition.IEEE, 2016: 2818-2826. [6] Lin T Y, Goyal P, Girshick R, et al.Focal loss for dense object detection[C]//Proceedings of the IEEE international conference on computer vision.2017: 2980-2988.