# Plant Disease Detection Using Deep Convolutional Neural Network
## 3 Materials and Methods
### Model Design  
In this section, a DCNN model for diagnosing plant leaf diseases using the PlantDisease59 dataset is proposed. Several DCNN models with different numbers and sizes of convolutional (Conv) and pooling layers were developed, and their performance is compared. The number of Conv layers varies from three to eight in different DCNN models. At maximum, the 14-layered deep convolutional neural network (14-DCNN) gives better training performance than other developed models. Five convolutional and five max-pooling layers were used to develop the proposed 14-DCNN model. The input images of the 14-DCNN are given into the first two-dimensional Conv layer. The dimension of the Conv layer output can be calculated using Equation (1):  
\[Dimension(\text{Conv}(n,k))=\left(\left[\frac{n_{w}-f_{w}}{s}+1\right]\text{, }\left[\frac{n_{h}-f_{h}}{s}+1\right]\text{, }f_{C}\right) \tag{1}\]  
Figure 1: Sample augmented images using BIM, DCGAN and NST techniques. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Dataset Name** & **Number of Images** & **Number of Images in Each Class** \\ \hline Training Set & 132,750 & 2250 \\ Validation Set & 5900 & 100 \\ Testing Set & 8850 & 150 \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Training, validation and test dataset size. The input width (\(n_{w}\)) and height (\(n_{h}\)) of the first convolutional layer are 128 and 128 respectively. Additionally, the \(f_{w}\), \(f_{h}\) and \(f_{c}\) represent the width, height and channels of the kernel filter of the convolutional layer. The stride (\(S\)) value of this Conv layer is one. The first max-pooling layer was introduced to reduce the dimension of the first Conv layer output from 126, 126, 4 to 63, 63, 4 values. The dimension of the max-pooling layer output was calculated using Equation (2):  
\[Dimension(Pooling(n,k))=\left(\left[\frac{n_{w}-f_{w}}{s}+1\right],\ \left[\frac{n_{h}-f_{h}}{s}+1\right],\ n_{c}\right) \tag{2}\]  
The \(n_{w}\), \(n_{h}\) and \(n_{c}\) represent the width, height and channels of input \(n\), respectively. Additionally, the \(f_{w}\), \(f_{h}\) and \(n_{c}\) represent the width, height and channels of the filter (\(f\)) in the max-pooling layer. The output of the first max-pooling layer is given as an input of the second Conv layer. Likewise, the second Conv layer uses the filter sizes of 16, 3, 3 values to extract the features from the data. The output size of the second Conv layer is 61, 61, 16 values. The second max-pooling layer reduces the output data size of the second Conv layer from 61, 61, 16 to 30, 30, 16 with the filter size of 2, 2 values. The third Conv layer was introduced after the second max-pooling layer. It extracts more features from the input data using the 32, 3, 3 size kernel and produces the 28, 28, 32 sized output data. The third max-pooling layer was used to reduce the size of the output data from the third Conv layer with 2, 2 sized kernels. It reduces the size of the data to 14, 14, 32 values from 28, 28, 32 values. Additionally, the fourth Conv layer uses the 64, 3, 3 sized kernels to extract the additional features from the third pooled data and generates the output data with the size of 12, 12, 64 values from the input size of 14, 14, 32 values. In addition, the fourth max pooling layer has a filter size of 2, 2 matrices and stride value of 1 step. The fourth max-pooling layer reduces the size from 12, 12, 64 values to 6, 6, 64 values. The fifth Conv layer was introduced with a filter size of 128, 3, 3 matrices. The size of the input matrix is 6, 6, 64 and the output size of the fifth Conv layer is 4, 4, 128 matrices. After the fifth Conv layer, the fifth pooing layer was used with max-pooling function and stride value of 1 step. The input size of the fifth max-pooling layer is 4, 4, 128 values, and the output size is 2, 2, 128 values. It uses the single-step stride values to apply the kernel to the input data from the fifth Conv layer. The \(ReLu\) activation function was used on all the above Conv layers.