# Adaptive Thresholding of CNN Features for Maize Leaf Disease Classification and Severity Estimation
## 3 Materials and Methods
### Proposed Methodology
#### 3.2.1 Architecture of the Proposed CNN  
Here, we define our custom CNN model. Most state-of-the-art CNNs are very deep, and are hence more complex. For example, VGG16 has 16 layers, while ResNet50 has 50 layers, and so on. In order to investigate the influence of CNN depth on classification accuracy, two separate CNN pipelines are implemented. The first consists of a shallow CNN (only three convolutional layers) and is trained from scratch, while the second uses deep CNN architectures (up to 250 convolutional layers) and employs transfer learning to speed up network training.  
Figure 4: Example of maize leaf images from the PlantVillage dataset. The dataset contains the following classes: (**a**) Northern Corn Leaf Blight _Exserhelium turticum_, (**b**) Gray Leaf Spot _Cercospora zeae-maydis_, (**c**) Common Corn Rust _Puccinia sorghi_ and (**d**) healthy maize leaf.  
Below summarizes the network architecture of the shallow CNN shown in Figure 6.  
1. Input image data: The images in our dataset have different sizes of width \(\times\) height. However, the pre-processing stage of the CNN models resizes the images to a 3D matrix of \(224\times 224\times 3\). We have three channels since we are using RGB images.
2. First hidden layer: The first hidden convolutional layer is called _conv2d_1_. It has 32 feature maps of size \(3\times 3\) and a ReLu activation function.
3. Second hidden layer: The second hidden layer is called _conv2d_2_. It has 32 feature maps of size \(3\times 3\) and a ReLu activation function.
4. Third hidden layer: Referred to as _conv2d_3_, it has 64 filters of size \(3\times 3\).
5. Pooling layer: The pooling layer is called _MaxPooling2D_ and is added after every convolutional layer.
6. Dropout layer: A dropout layer is added to reduce overfitting; in this model, it has been set to exclude 30% of the neurons.
7. Flatten layer: This layer is added to convert the 2D feature maps to a 1D vector.
8. First fully connected layer: This has 128 neurons with a ReLu activation function.  
Figure 5: Research method of maize leaf disease classification and severity estimation using deep CNN features. As shown in this diagram, simultaneous maize leaf disease classification and quantification is the major component of our work, which comprise the following: CNN training, CAM heatmap extraction, and thresholding. First, several deep learning models are trained on the augmented PlantVillage maize leaf disease dataset. In Stage 2, the CAM extracted from the covnet layers from Stage 1 is obtained and eventually used for disease quantification. Although not illustrated in this diagram, the CAM can be treated as a 2D heatmap of pixels with different intensities. Bright pixels represent regions that have been identified by the CNN to be of great importance (regions of interest (ROI)), while darker regions correlate to a lack of features. In Stage 3, we use an adaptive thresholding technique that extracts the ROI from the heatmap of Stage 2 and represents that area as a percentage of the total leaf area.  
Output layer: This has four neurons and a softmax activation function.