Severity Stage Identification and Pest Detection of Tomato Disease Using Deep Learning

In Bangladesh, most people depend on agriculture for their livelihood. The country's economy and agricultural production are hampered if plants are affected by diseases. Crop pests also disrupt agricultural production. So, this paper proposes leaf disease, disease severity stage, and pest detection strategies with suggestions for prevention strategies using five notable Convolutional Neural Network models (CNN) such as VGG16, Resnet50, AlexNet, EfficientNetB2, and EfficientNetB3. This paper uses a dataset of tomato leaves consisting of 41,763 images which cover 10 classes of tomato disease, and a dataset of pests consisting of 4,271 images which cover 8 classes of pests. Firstly, these models are used for the classification of diseases and pests. Then disease and pest prevention techniques are shown. For disease and pest detection, EfficientNetB3 gives the best accuracy for training (99.85%), (99.80%), and validation (97.85%), (97.45%) respectively. For severity stage identification, AlexNet gives the best accuracy for training (69.02%) and validation (72.49%).


I. INTRODUCTION
long with the economic growth of any country, the country's GDP also depends on agriculture [1]. So, agriculture is considered one of the world's most important occupations. Like other countries, the main occupation of people in Bangladesh is agriculture. But farmers in our country are facing losses due to foliar diseases and insect attacks which reduce crop productivity. Along with the increase in population, the demand for food is also increasing. Therefore, disease detection and pest identification are essential for good yield [2]. Accurate detection of diseases at an early stage is helpful in reducing losses in agriculture [3].
There are many methods of diagnosing plant disease. Many farmers diagnose the disease using these methods on the advice of experts. But for specialist consultation, collecting samples and taking them to the lab for diagnosis is expensive and timeconsuming. So, digitalized methods of crop disease detection need to be invented [4]. For this purpose, deep learning such as convolutional neural network is more useful which takes an image as an input and gives the predicted result as output depending on various features in less time.
Different crop diseases have different colors, shapes, and sizes which are considered features. These features are used to identify diseases [5]. Although the color of many diseases may be the same other features can be detected by our proposed model which helps to identify the diseases accurately.
Tomato is considered one of the most popular vegetables which are eaten as a salad, served as a cooked vegetable, and various dishes, pickled, and sauces are prepared with tomato. Tomatoes are riched in Vitamin C, beta-carotene, and Vitamin E which are the main antioxidants. Besides potassium is also present in it [6]. But tomatoes are attacked by various diseases and pests which reduce tomato production. So, to identify tomato disease and pest alternative to a manual identification process digitalized process is proposed in this paper.
The proposed methodology consists of four major steps: data acquisition, pre-processing, feature extraction and classification, and suggest prevention technique. Datasets have been collected from Kaggle to implement the proposed method. Data is resized, rescaled, zoomed, horizontally flipped, and sheared in the pre-processing step. Then the images are fed into the classification model. For feature extraction and classification VGG16, Resnet50, AlexNet, EfficientNetB2, and EfficientNetB7 have been used [6].
The rest of the paper is organized as follows: section 2 describes the related work done in the previous year, section 3 describes the preliminaries, section 4 represents the proposed A methodology, section 5 describes the result and discussion, and section 6 is the conclusion. The overall research process is shown in Fig. 1.

II. RELATED WORKS
Various CNN models are shown in this paper for classifying tomato leaf disease, tomato pest, and tomato bacterial spots at different stages. Previous also different CNN model is used to classify leaf disease. This section describes the different process of previous work that is used for the classification of leaf disease and pest detection.
Omkar Kulkarni [5] proposed a deep-learning-based model to identify crop diseases. They used the PlantVillage dataset which is a public dataset. InceptionV3 and MobileNet are used from different deep-learning-based models to identify crop diseases in this paper. 5277 images of 5 different types of crops are used to fine-tune these models. 99.62% and 99.74% accuracy are achieved by InceptionV3 and MobileNet models respectively.
Prajwala TM et al. [6] experimented AlexNet, GoogleNet, and LeNet models architecture for tomato leaf disease detection. But LeNet which is the variation of a convolutional neural model was given the best accuracy. From the PlantVillage dataset, 10 different classes of tomato leaf disease images are used in this paper. These images are resized into 60 × 60 resolution in pre-processing phase. For feature extraction convolutional and max pooling layers are used and for classification, the fully connected layer is used. 94-95% accuracy was achieved by the proposed model. Husnul Ajra et al. [7] used 4000 images of Potato early blight, Tomato early blight, Potato late blight, and Tomato late blight to classify and give a graphical layout of a preventive measurement for identified disease. Also, 2000 healthy images are used in this paper. By using 2 CNN models ResNet50 and AlexNet, at first healthy and unhealthy leaves are classified then these unhealthy leaves are classified into four different leaf diseases and also give preventive measures for this detected disease. 97%  proposed. The fine-tuning method gives the best accuracy for all these models. The best accuracy of 97.12% is achieved by fine-tuned VGG16.
Divyansh Tiwari et al. [9] utilized 2152 images of potato late blight, potato healthy, and potato early blight images from the PlantVillage dataset. For feature extraction VGG16, VGG19, and Inceptiov3 are used as well as for classification SVM, KNN, neural network, and logistic regression are used. Along with VGG16 logistic regression gave the best accuracy of 97.8%.
Ebrahim Hirani et al. [4] used CNN, transfer learning, and Visual transformers approach for plant disease detection. In CNN, different filters are used in the convolutional layer, and the 'relu' activation function is used in the fully connected layer to reduce overfitting dropout. In transfer learning, the InceptioV3 model is used. In visual transformer approaches STN (Small Transformer Network) and LTN (Large Transformer Network) are used. The LTN achieved the best validation accuracy of 97.98%.
Although plant disease detection and rarely insect detection have been done in the past, disease detection alone is not a good solution for increasing crop production. A prevention strategy with this detection is more effective. The achievement of this paper is to identify 10 different diseases and 8 different pests of tomatoes and provide a preventive solution for each disease and pest that is more helpful for farmers. Identifying stage-wise tomato bacterial spots and providing solutions for each stage is another achievement of this paper.

A. TOMATO
Among different types of vegetables, tomato is the most popular vegetable across the world. So agricultural development depends on the production of tomatoes [10]. Vitamin C, folate, and potassium are present in tomatoes. Tomatoes contain more carotenoids than phytonutrients. The most important carotenoid in tomatoes is lycopene, as well as other carotenoids, including gamma-carotene, beta-carotene, and phytoene also present. Besides vitamin E, flavonoids, trace elements, phytosterols, and different water-soluble vitamins are also present in tomatoes [11]. But tomato leaves are attacked by various diseases and pests which destroy the production of tomatoes.

B. TOMATO LEAF DISEASE
Tomato leaf disease impacts the growth and production of tomatoes. As a result, farmer faces economic problems [12]. Leaf diseases are caused by various pathogens such as viruses, fungi, bacteria, and pests. As a result, foliar diseases and insect attacks cause 10% to 25% crop loss every year and farmers suffer huge economic losses as income depends on the number of healthy crops they produce. So, overcoming this problem is a big challenge. So, by detecting leaf diseases and pests through an automated system we can help the farmer to overcome this challenge [13]. Tomato leaves are attacked by nine common diseases.

C. TOMATO PEST
Various pest affects tomato and decreases their growth. So, to increase production identification of tomato pests is essential [16]. Tomato leaves and tomatoes are attacked by various types of pests. The most common types of pests are Tetranychus urticae, Bemisia argentifolii, Zeugodacus cucurbitae, Thrips palmi, Myzus persicae, Spodoptera litura, Spodoptera exigua, and Helicoverpa armigera. Eight different pests are shown in Fig. 3.

D. TOMATO BACTERIAL SPOT STAGE
Tomato Bacterial Spot is caused by bacteria. Tomato production is disrupted due to bacteria. Each Disease has different stages. Usually, the last stage of any disease is more serious than the first stage. So, stage identification is required to reduce intensity. Because if its severity is identified, the disease can be reduced by taking proper measures at the early stage. Tomato bacterial spot is classified into five stages depending on disease radiation percentage. Five stages of tomato bacterial spot and tomato healthy leaf images are shown in Fig. 4.  For pest detection, the tomato pest dataset is used which is available on Mendeley Data [17]. This dataset contains 4,271 images of 8 different pests of tomato. At first, the dataset is split into two parts: the training part contains 3,456 images (70%) and the validation part contains 431 images (30%). Then from the training part, 384 images (10%) are used for testing purposes.
For stage-wise prevention technique suggestion, from PlantifyDr Dataset Tomato Bacterial Spot is taken which contains 4,355 images. From these images, 882 images are categorized into 5 stages (1st stage,2nd stage, 3rd stage, 4th stage, and 5th stage) depending on 5 features that are suggested by a pathologist which is shown in Table 2 [18]. Then the dataset is split into two parts: the training part contains 1,117 images (70%) and the validation part contains 538 images (30%). Then from the training part, 125 images (10%) are used for testing purposes. 5 features are:  Table 2 shows the severity stage of tomato bacterial spots. If 0-5%, 6-20%, 21-40%, 41-70%, or more than 70% of the leaf area is affected by spots, the severity stage will be 1st, 2nd, 3rd, 4th, or 5th respectively. If the leaf is free from the spot is called a healthy leaf. Figure 6. Pre-processing The next phase is the image pre-processing phase which is shown in Fig. 6. Image pre-processing is used for preparing images into a desirable format to feed into the model. By image pre-processing technique raw images can be converted into desirable images with high quality. The dataset that is used in this proposed system is random-sized tomato leaf and pest images, as well as the dataset, is not split into training, validation, and testing set. The pre-processing technique's different phases that are applied to the proposed system are shown in Fig. 6. In the first phase, the images are resized into a suitable form. Then these resized images are split into training, validation, and testing sets. Finally, pre-processing technique gave the desired secure image datasets to classify tomato leaf disease, tomato pest, and tomato Bacterial Spot severity stage.

C. FEATURE EXTRACTION AND CLASSIFICATION
After pre-processing the images next phase is to extract features from the images so that the images can be classified depending on these features. For feature extraction and classification, transfer learning approaches are used in this paper. Classification of tomato leaf disease, tomato pest as well as stage-wise tomato bacterial spot detection is the main motive of this paper. Different transfer learning models such as EfficientNetB3, VGG16, ResNet50, AlexNet, and EfficientNetB2 are used to identify the disease and pest. Classification means categorizing the images or objects depending on the predetermined categories. Pre-trained models are:

1) EfficientNet
The main objective of deep neural networks is to achieve optimal accuracy with a small model. The EfficientNet model is considered a state-of-the-art model because in 2019 it achieved 84.4% and 97.1% as top-1 and top-5 accuracies, respectively, on the ImageNet dataset with fewer parameters. B0-B7 are eight models of EfficientNet. The Leaky ReLu activation function is used in the EfficientNet model instead of the Rectifier Linear Unit (ReLu). The EfficientNet architecture produces an efficient result by using a composite coefficient to scale the depth, width, and resolution of the network equally. Bottleneck convolutional layer is used in the EfficientNet model which is first used in MobileNetV2 architecture. Compare to other models, EfficientNet requires less computation by f^2 factor where f is the kernel size [15,20]. EfficientNetB2 and EfficientNetB3 models are used in this research which architecture and modules are shown in Fig. 7,  Fig. 8, and Fig. 9 Fig. 10 shows the AlexNet architecture consisting of eight layers, with five convolutional layers and three fully connected layers. The first convolutional layer consists of 96 filters and (11×11) kernels for feature extraction, and then a 3×3 MaxPooling layer is added to reduce the size of thefeature map. The second convolutional layer is the same as the first convolutional layer but contains 256 filters and (5×5) kernels. The third, fourth, and fifth convolutional layers have 384, 384, and 256 filters and (3×3) kernels respectively. A 6×6 MaxPooling layer is then added to reduce the size of the feature map by the convolutional layer. A fully connected layer is added to transform the features into one-dimensional vectors. Among the three fully connected layers, two fully connected layers use the ReLu activation function. Finally, a fully connected layer is used as the output layer and the SoftMax activation function is added for prediction [21]. return model accuracy 23. end step 9's for loop

3) VGG16
In Fig. 11 shows VGG16 architecture which consists of sixteen layers with thirteen convolutional and three fully connected layers. 3×3 and 2×2 kernels are used in the convolutional and pooling layer respectively. VGG16 has five blocks. Each block consists of multiple convolutional layers and one pooling layer. The pooling layer is used to reduce the feature map size. In block-1 and block-2 has two convolutional layers with 64 and 128 filters for feature extraction and one pooling layer for reducing the feature map size. Similarly, block-3, block-4, and block-5 have three convolutional layers with various filters for feature extraction and one pooling layer for reducing the feature map size. Among three fully connected layers, two fully connected layers used ReLu activation functions. At last, one fully connected layer is used as the output layer and the SoftMax activation function is added for predictions [21].
Algorithm of VGG16: Input: Tomato leaf disease and pest image Output: Classification of disease and pest Procedure: 1. Follow steps 2 to 5 for a training and validation dataset. 2.

4) ResNet50
The architecture of ResNet50 has 50 layers which are shown in Fig. 15. The vanishing gradient problem is a notable problem of convolutional neural networks. The vanishing gradient problem means that during backpropagation when the gradient value decreases, then a slight change in weights occurs. In ResNet50 skip, the connection is used to control this problem which is shown in Fig. 12. Without a skip connection output is: (1) With a skip connection output is: F(x) + x Along with this vanishing gradient problem, optimization of the network and degradation problem is found in CNN which is also solved by the ResNet50 model. [24] Two types of blocks are used in the ResNet50 model such as identity block and the convolutional block is shown in Fig. 13 and Fig. 14 respectively. Identity block means x is added to the output layer if the input size is equal to the output size. To build the input size and output size equal a convolutional block is added in the shortcut path [25].

D) SUGGEST PREVENTION TECHNIQUE
The other motive of this paper is to give suggestions for a preventive technique for tomato leaf disease, and tomato pests and also suggest step-wise prevention ways of Tomato Bacterial spots. So that farmers can be befitted for reducing the effect of tomatoes' different diseases and pests. After classifying tomato disease, tomato pest, and different stages of tomato bacterial spot, the prevention technique is suggested by using the EfficientNetB7, VGG16, ResNet50, AlexNet, and EfficientNetB2 models.

V. RESULT AND DISCUSSION
To analyze the best result for tomato leaf disease detection, tomato pest detection, and tomato bacterial spot severity stages detection, a comparison among 5 different classification models' training, validation and testing accuracy has been drawn in Fig. 16. Fig. 16(a), there is shown a comparison among 5 classification models' training accuracy for tomato leaf disease detection, tomato pest detection, and tomato bacterial spot severity stages detection. Fig. 16(b), there is  shown a comparison among 5 classification models' validation accuracy for tomato leaf disease detection, tomato pest detection, and tomato bacterial spot severity stages detection. Fig. 16(c), there is shown a comparison among 5 classification models' testing accuracy for tomato leaf disease detection, tomato pest detection, and tomato bacterial spot severity stages detection. From the analysis of Fig. 16(a), (b), and (c), it is shown that for tomato leaf disease detection EfficientNetB3 is given the best training (99.85%), validation (97.85%), and testing (96.33%) accuracy. On the other hand, for tomato pest detection also EfficientNetB3 is given the best training (99.80%), validation (97.45%), and testing (98.70%) accuracy. As well as for tomato bacterial spot severity stages detection AlexNet is given the best training (69.02%), validation (72.49%), and testing (71.20%) accuracy.
(a) For prevention techniques: After applying different classification models such as EfficientNetB3, VGG16, ResNet50, AlexNet, and EfficientNetB2 for classifying tomato leaf disease, tomato pest, and tomato bacterial spot severity stages detection, suggest prevention techniques (Organic Control and Chemical control) that help the farmer to take proper steps for disease severity control. Organic and chemical control for leaf disease, tomato pest, and tomato Bacterial Spot Severity stages detection is shown in Fig. 17. In Fig. 17 tomato disease name also suggests organic as well as chemical control for the given input image of the disease. In Fig. 17's middle side, there is shown the tomato pest name also suggests organic as well as chemical control for the given input image of the pest. In Fig. 17's right side, there is shown the tomato Bacterial Spot Severity Stages also suggest organic as well as chemical control for the given input image of the Tomato Bacterial Spot.

VI. CONCLUSIONS
Various problems of agriculture are mentioned in this research paper. This problem has disrupted the agricultural sector economically. So, given the importance of agriculture, the accurate detection of plant diseases and pests is very important.
For this purpose, ten categories of tomato leaf diseases and eight categories of tomato pests are considered. Not only is a foliar disease and pest detection a good method to increase crop productivity, but this disease prevention strategy is the most effective. In this paper, these detections are done by using five convolutional neural network models and suggest prevention techniques for each disease and pest. Among the five models for disease and pest, detection EfficientNetB3 gives the best accuracy for training (99.85%), (99.80%), and validation (97.85%), (97.45%) respectively. In the future, we aim to identify diseases and pests with a large dataset of various types of plants and pests. We thank you in advance for supplying carefully prepared camera-ready papers, which can be sent for publication without modification.  Table 3. Accuracy table Figure 17. Suggest prevention technique