Frontiers in Computing and Intelligent Systems ISSN: 2832-6024 | Vol. 3, No. 2, 2023 48 Tea Leaf Disease Classification using Domain Adaptation Method Wei Wu Taishan University, Tai'an 271000, China Abstract: Tea trees are extremely vulnerable to diseases and insect pests in the growth process, which seriously affects the yield and quality of tea leaves. This requires the identification and treatment of infected tea leaves in time. With the rapid development of artificial intelligence and computer vision, there is a new trend to identify the images by computer. However, there often exists environmental changes such as illumination intensity, sample angles and background in the leaf images collected in natural scenes, which results in the difference of data distribution. This makes the traditional deep learning method unable to solve the problem of cross-domain classification very well, thus seriously affecting the accuracy of classification. This study mainly focuses on the cross-domain task with unaligned data distribution. A domain-adaptive based method was proposed to realize the cross-domain classification of tea leaf diseases. The experimental results verify the effectiveness of the presented method and provide new thoughts for the cross-domain classification problem in agriculture. Keywords: Deep learning; Domain adaptation; Tea leaf disease classification. 1. Introduction Tea tree is an important economic crop in the world and an important industry to drive tea farmers out of poverty. However, tea leaves are often attacked by diseases and insect pests. It is of great significance to ensure the yield and quality of tea by identifying the types of infected tea leaves accurately and taking protective measures timely. The appearance and growth state of tea leaves can provide a prediction basis for the growth trend of tea trees. With the rapid development of computer technology, the identification of tea leaves images has been widely studied with the help of computer vision. Since 2006, deep learning technology has developed rapidly and has made remarkable achievements in the field of image recognition. As the core technology of deep learning, convolutional neural network (CNN) is widely used in the field of automatic recognition of tea leaf images. Chen et al. [1] developed a CNN model called LeafNet to classify tea leaf diseases by extracting image features automatically. Gayathri et al. [2] proposed a deep CNNs called LeNet to discover the tea plant diseases from leaf image set, which can be applied to improve the diagnostic measurement of tea leaves. Hu et al. [3] proposed an improved deep CNN for tea leaf disease identification, in which the depthwise separable convolution is used to reduce the number of model parameters and accelerate the calculation of the model. Experiments show that the average identification accuracy is higher than classical deep learning methods . The effectiveness of deep learning benefits from the construction of deep neural networks, and its training process requires a large number of parameters training tasks. In order to improve the generalization ability of the neural network models and avoid the overfitting problem, the model training process usually requires the input of a large number of labeled data samples for learning. However, in practical application scenarios, the acquisition of data samples may have environmental changes, such as the change of illumination intensity, shooting equipment and shooting angles. Changes in the environment often lead to different data distribution of the acquired sample images, thus reducing the effect of image recognition. In other words, the model with good recognition effect of one kind of data distribution may show poor performance in another kind of data distribution. To solve this problem, domain-adaptive methods emerge. This method is a transfer learning method aiming to transfer the classification recognition ability learned in the source domain to the target domain. Domain adaptive methods divide the training dataset into labeled source domain and target domain with little or no labels depending on the data distribution. When the model has the ability to recognize the source domain data, this kind of ability can be quickly transferred to the target domain through the domain adaptive method. The basic idea of domain adaptation is to map the data sets from different domains to a same feature space and make their feature distribution as close as possible, so as to realize cross-domain recognition. There are many ways to realize domain adaptation, among which the domain adversarial based neural network DANN [4] is proposed. Its adversarial based idea has become one of the main methods to realize domain alignment. chen et al. [5] solve the domain shift problem at two levels: image level and instance level, and construct domain classifiers by using adversarial training to realize cross-domain object detection. Hsu et al. [6] realize the conversion of the source domain to the target domain by constructing the transition domain, and adopts the adversarial training method to achieve domain alignment at the feature level. Tseng et al. [7] use feature-wise transformation layers by using affine transforms to simulate various feature distributions under different domains. There experiments show improvements on the few-shot classification performance under domain shift. 2. Related theory 2.1. Convolutional neural network Convolutional neural networks (CNN) is one of the key factors for the success of deep learning in the field of computer vision recognition. Unlike traditional machine learning methods, which require manual feature extraction, CNN can achieve end-to-end automatic feature extraction for input images. The typical CNN structure is mainly composed 49 of convolutional layers, pooling layers and fully connected layers. Convolutional layer is one of the important structures of CNN. It performs convolution computation by convolutional kernels for the input features, so as to realize feature extraction. The model parameters of the convolutional layer are divided into the convolutional kernel part and the deviation part. A convolutional network with different structure and complexity can be designed between multiple convolutional layers through parallel or serial connection. The characteristic output of the i-th layer in the convolutional network can be expressed as: 𝑦𝑖 = 𝑓(π‘¦π‘–βˆ’1π‘Šπ‘– + 𝑏𝑖) where π‘Šπ‘– is the weight parameter of the convolution kernel in i-th layer, 𝑏𝑖 is the standard deviation value, π‘¦π‘–βˆ’1 is the feature input of the convolutional layer (𝑦0 represents the input image), and f represents the activation function. The main function of the pooling layer is to strengthen the spatial invariance of the features extracted by the convolution layers and reduce the excessive sensitivity to the spatial position, so that the same object can be well recognized by the model even if there are position changes. The common pooling methods include maximum pooling and average pooling, which calculate the maximum value and average value in the pooling window respectively, so as to realize the down sampling process of features. The characteristic output of the j-th pool region of the s-th pool layer can be expressed as: x𝑗 𝑠 = 𝑑(x𝑗 π‘ βˆ’1, 𝑝, π‘ž) where x𝑗 π‘ βˆ’1 represents the feature input for this pooling layer, p and q correspond to the height and width of the pooling window respectively, and d represents the pooling function. After a series of convolution and pooling operations, one or more fully connected layers are usually followed for the image classification task. Softmax function is usually used to map the output of the final network layer 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 z represents the output vector of the last connected layer. K is the output numbers of the last connected layer, and j∈ {1, …, K}. 2.2. Domain adaptation The traditional deep learning model is mainly trained on the training samples with the same data distribution, and is applied to the test samples with the same distribution. When there are different data distributions between training samples and test samples, the learned model based on a certain data distribution usually cannot adapt to this difference well in another data distribution, and shows poor generalization in the specific classification task. Domain adaptation is the way to solve this problem of differences in data distribution. It divides the data sets into source domain and target domain, aiming to realize the data alignment of different domains, so as to transfer the recognition ability of the source domain to the target domain. Therefore, the domain adaptive method is essentially a transfer learning method. 3. Method This study proposes a tea leaf disease classification method based on domain adaptation, which is introduced from the aspects of data sets and domain adaptive method respectively. 3.1. Data sets The data sets of tea leaf diseases selected in this study were all collected in the tea garden in Tai'an, Shandong Province. There are totally 746 images including healthy leaves and three kinds of infected leaves, namely tea white star, tea leaf blight, and tea wheel spot. After applying data enhancement technology such as random rotation, random cropping, random color change, the number of the collected tea leaf images were expanded to 4610. For each category, 70% of the data were randomly selected as the training set and 30% as the test set. The data of each category in the training set are divided into source domain and target domain in a ratio of 4:1. To simulate the different data distributions of the source and target domains, the brightness of the target domain data and the raw images in the training sets are increased [8]. Figure 1. Domain-adapted classification model of tea leaf disease 3.2. Domain-adaptive method The source domain dataset in this study contains a large amount of labeled data, and the target domain dataset contains a large amount of label-free data. Assuming that the data amount of the source domain images X𝑠 in the tea leaf disease training set is 𝑛𝑠, and the number of categories is K, the source domain data can be expressed as 𝐷𝑠 = {(π‘₯𝑖 𝑠, 𝑦𝑖 𝑠)}𝑖=1 𝑛𝑠 , where π‘₯𝑠ϡX𝑠 , 𝑦𝑠ϡY𝑠 = {1,2, … , 𝐾} ., The amount of the target domain images X𝑑 is 𝑛𝑑, then the target domain data can be represented as 𝐷𝑑 = {(π‘₯𝑖 𝑑)}𝑖=1 𝑛𝑑 , where π‘₯𝑑ϡX𝑑 . The data distribution of π‘₯𝑠 and π‘₯𝑑 are similar but different, constituting the cross-domain dataset. The data labels π‘Œπ‘‘ of the dataset π‘₯𝑑 are the same with π‘Œπ‘  . The purpose of domain adaptation is to make the network model with the ability of source domain data classification be applied to predict the target domain data by reducing the difference in data distributions of the source domain and target domain. The domain-adapted classification model of tea leaf disease in this study is shown in Figure 1, which mainly includes three modules: feature extraction module G, leaf disease classification module C and domain classification module D. The function of the feature extraction module is to extract image features and confuse the feature distribution of source domain and target domain; the leaf disease classification module is to recognize leaf disease species using the extracted features; the domain classification module is to recognize which domains the input features are from. It can be seen that the features obtained by the feature extraction module are used as the input of the other two modules simultaneously. In order to train the model, on the one hand, it is necessary to input the source domain images into the feature extraction module, and predict the leaf disease type. The classification loss 𝐿𝑦 are calculated by the predicted labels and the true 50 labels through the cross-entropy loss function, and the parameters of the network branch are updated by back propagation. On the other hand, it is necessary to input the source domain images and the target domain images at the same time. Then the features of these images are extracted to enter the domain classification module for domain prediction. The domain prediction loss of this branch can be expressed as: 𝐿𝑑 = βˆ’βˆ‘π‘‘log (𝐷(𝐺(𝐼))) 𝐼 βˆ’βˆ‘(1 βˆ’ 𝑑)log(1 βˆ’ 𝐷(𝐺(𝐼))) 𝐼 where 𝐼 represents the images from source and target domain, d takes the value 0 when the input image is from the source domain and 1 when it is from the target domain. The training goal of the domain classification module is to make the domain classifier more accurate, while the training goal of the feature extraction module is to extract the common features in the source domain and the target domain, making the domain classifier unable to discriminate. Therefore, the network training in this branch is a typical adversarial thinking, and its training goal can be expressed as max 𝐺 min 𝐷 𝐿𝑑. In the specific implementation, Gradient Reversal Layer (GRL) [9] is added between the feature extraction module and the domain classification module to achieve the effect of adversarial training. The loss function of the above two branches constitutes the final loss of the network model, which is expressed as πΏπ‘‘π‘œπ‘‘π‘Žπ‘™ = 𝐿𝑦 + πœ†πΏπ‘‘πœ† , where πœ† is the hyperparameter used to balance the two branches of the network. After the training stage, tea leaf disease types are predicted using the test set data. At this time, the domain classification module is removed, and only the feature extraction module and leaf disease classification module are reserved for prediction. Table 1. Comparison of classification accuracy of tea leaf disease based on different models Method Accuracy Traditional neural network model 46.1% Domain adaptive model 84.7% 4. Experiment To verify the effectiveness of the domain adaptive method in this study, we compare it with the traditional neural network model method. Both the feature extraction module and the leaf disease classification module use a pre-trained GoogLeNet neural network architecture. The domain classification module consists of three fully connected layers with a number of neurons of 1024, 512 and 1, respectively. The experimental comparison results are shown in Table 1. It can be seen that the average accuracy of cross-domain classification of tea leaf disease in the traditional neural network model trained only with source domain data is only 46.1%, indicating that there is a large data distribution difference between the target domain image and the source domain image after brightness processing, and the classification accuracy is low. However, the neural network trained by domain adaptation can reduce the difference in data distribution, and improve the classification accuracy of the test set to 84.7%. The experimental results fully illustrate the necessity of using the domain adaptive algorithm on the cross-domain data set of tea leaf disease, which can bring great accuracy improvement. 5. Conclusion In this paper, the classification method of tea leaf disease based on domain adaptation are proposed. At first the tea leaf disease classifier is trained with source domain data. Then the data distribution between different domains are aligned through adversarial training, so as to achieve a good classification effect of leaf disease on cross-domain datasets. The experimental results verify the effectiveness of the domain adaptive method to solve the cross-domain classification problem of tea leaf disease. Future studies will combine cross-domain classification and few-shot learning to conduct more beneficial exploration in the field of smart agriculture. Acknowledgment This work was supported by the Tai'an Science and technology innovation development project under Grant No.2021NS097. References [1] Chen J, Liu Q, Gao L. Visual tea leaf disease recognition using a convolutional neural network model[J]. Symmetry, 2019, 11(3): 343. [2] Gayathri S, Wise D C J W, Shamini P B, et al. Image analysis and detection of tea leaf disease using deep learning[C]//2020 International Conference on Electronics and Sustainable Communication Systems (ICESC). IEEE, 2020: 398-403. [3] Hu G, Yang X, Zhang Y, et al. Identification of tea leaf diseases by using an improved deep convolutional neural network[J]. Sustainable Computing: Informatics and Systems, 2019, 24: 100353. [4] Ganin Y, Ustinova E, Ajakan H, et al. Domain-adversarial training of neural networks[J]. The journal of machine learning research, 2016, 17(1): 2096-2030. [5] Chen Y, Li W, Sakaridis C, et al. Domain adaptive faster r-cnn for object detection in the wild[C]//Proceedings of the IEEE conference on computer vision and pattern recognition. 2018: 3339-3348. [6] Hsu H K, Yao C H, Tsai Y H, et al. Progressive domain adaptation for object detection[C]//Proceedings of the IEEE/CVF Winter Conference on Applications of Computer Vision. 2020: 749-757. [7] Tseng H Y, Lee H Y, Huang J B, et al. Cross-domain few-shot classification via learned feature-wise transformation[J]. arXiv preprint arXiv:2001.08735, 2020. [8] Marino S, Beauseroy P, Smolarz A. Unsupervised adversarial deep domain adaptation method for potato defects classification[J]. Computers and Electronics in Agriculture, 2020, 174: 105501. [9] Ganin Y, Lempitsky V. Unsupervised domain adaptation by backpropagation[C]//International conference on machine learning. PMLR, 2015: 1180-1189.