$$\rightleftharpoonup{xx}$$
$$\longleftharp{xx}$$,
$$\longrightharp{xx}$$,
Dataset description
The dataset used in this research was obtained from the publicly available Kaggle repository titled Paddy Leaf Diseases Detection Dataset. It consists of 18,545 images of paddy leaves categorized into 10 disease classes and 1 healthy class. Images vary in resolution and were captured under different lighting and environmental conditions.
Image preprocessing
All images were resized to 224 x 224 pixels using TensorFlow's tf.image.resize() function. This uniformity ensures compatibility with the input requirements of pre-trained CNN models.: Pixel values were normalized to the range [0,1] using rescale=1./255 parameter in Keras ImageDataGenerator. Augmentation (for training only): Techniques such as horizontal and vertical flipping, rotation (± 20°), and zoom (up to 20%) were applied using ImageDataGenerator to improve generalization.
Image segmentation
A UNet model was employed for image segmentation to isolate diseased leaf areas from background clutter. The UNet architecture was built using Keras functional API with encoder-decoder layers, skip connections, and ReLU activation. Segmentation masks were applied to original images using pixel-wise multiplication (cv2.bitwise_and) to retain only relevant features.
Model architecture and training
The following models were used as backbone classifiers: VGG16, ResNet50, InceptionV3, MobileNet, AlexNet, and DenseNet121. Pre-trained models (on ImageNet) were imported with include_top=False. A custom classification head was added, consisting of a global average pooling layer, two dense layers with 128 and 64 neurons (ReLU activation), a Dropout layer (rate = 0.4), and a final dense layer with 11 outputs and Softmax activation.
Experimental setup
All experiments were conducted using the following settings: Programming Environment: Python 3.11.5 with TensorFlow and Keras, Execution Platform: Jupyter Notebook, Hardware: Intel Core i5-6300U, 8 GB RAM, Windows 11, Batch Size: 32, Epochs: 50, Optimizer: Adam, Learning Rate: 0.0001, Loss Function: Categorical Crossentropy, Activation Functions: ReLU for hidden layers, Softmax for the final output layer.
Evaluation metrics
Accuracy, precision, recall, and F1-score were calculated using classification_report from sklearn.metrics. Confusion matrices were plotted using confusion_matrix and seaborn.heatmap. Performance was assessed on both non-segmented and UNet-segmented images for comparative evaluation.
GUI development
A simple graphical user interface was created using Python's Tkinter library. Users can upload a leaf image using the GUI, which is then passed through the trained model. The predicted disease class is displayed on screen, along with a confidence score.
Dataset creation
The dataset used in this study is the publicly available Paddy Leaf Diseases Detection dataset from Kaggle36, comprising a total of 18,545 high-resolution images of paddy leaves categorized into 10 disease classes and 1 healthy class. The images were captured under varying lighting conditions and diverse environmental settings, making the dataset highly representative and suitable for building robust deep learning models. The dataset is approximately 8.33 GB in size and contains the following classes: Tungro, Sheath Blight (SB), Paddy Hispa (PH), Neck Blast (NB), Narrow Brown Spot (NBS), Leaf Scald (LS), Leaf Blast (LB), Healthy, Brown Spot (BS), and Bacterial Leaf Blight (BLB).
To ensure reproducibility and effective model evaluation, the dataset was randomly divided into training (80%) and testing (20%) subsets while maintaining class distribution. The training set was used to train the models, while the test set was reserved for performance validation on unseen data. The evaluation was based on standard classification metrics: Accuracy, Precision, Recall, and F1-score, which provided a comprehensive assessment of each model's classification capability. The study compared six deep learning models: VGG16, ResNet, InceptionV3, MobileNet, AlexNet, and DenseNet121, with DenseNet121 delivering the best performance for the task.
Data distribution
The disease classification was carried out using deep learning models trained on the dataset. The dataset was divided into two subsets: a training set and a testing set. The training set was used to teach the model, whereas the testing set was used to evaluate its performance on previously unseen data. A summary of the image distribution across the ten disease categories and the healthy leaf class is provided in Table 1. This table provides a comprehensive understanding of the visual symptoms associated with each disease, facilitating the training and evaluation of classification models.
This distribution ensures an equitable representation of each disease category during both the training and testing phases. The training set includes the majority of the images, enabling the model to effectively learn the unique characteristics of each class. The testing set, consisting of a smaller subset of images, ensures a reliable evaluation of the model's accuracy and its ability to generalize to new, unseen data.
The balanced and diverse distribution of images across categories ensures that the model has sufficient data to learn the unique patterns associated with each disease type, while also mitigating the risk of overfitting or bias toward any particular class. This data split is essential for achieving robust and reliable classification results.
Data cleaning
In the preprocessing phase, cleaning the data is essential to enhance the accuracy and efficiency of the classification model. The raw paddy leaf images often include unwanted background elements such as soil, nearby vegetation, or farming tools, which can introduce noise and degrade the model's overall performance.
To address this, image segmentation was carried out using the UNet37,38 model, a well-known convolutional neural network architecture designed specifically for semantic segmentation tasks. The UNET model is capable of segmenting leaf regions from the background with high precision, ensuring that only the relevant portions of the images are retained for further processing39. The segmentation process was illustrated in Figure 1.
Process of segmentation with UNet model (Figure 2): Raw images from the dataset are fed into the UNET model. The UNET model consists of an encoder that extracts hierarchical features and a decoder that reconstructs the image while segmenting the leaf region. The model outputs a binary mask where the leaf region is marked, and the background is removed. The segmented images are further refined by applying morphological operations to ensure smooth edges and remove any residual noise (Figure 3).
Mathematical formulation of UNet segmentation: UNet performs semantic segmentation by learning a mapping from the input image space to a binary mask that highlights the region of interest (ROI), i.e., the diseased leaf area, while suppressing the irrelevant background. Let:
denote the input RGB image of size H*W with C=3 color channels.
be the output of the trained UNet model, where each pixel value in M represents the probability of that pixel belonging to the diseased leaf region.
The final binary segmentation mask 
where τ [0,1] is the segmentation threshold (commonly set to 0.5).
The segmented image
is then computed as:

where
denotes element-wise multiplication, applied spatially across all channels. This operation retains pixel values in the ROI (where
) and masks out background pixels (where
). This segmented output is passed as input to the classification model (e.g., DenseNet121), allowing it to focus exclusively on disease-relevant features while ignoring noisy, non-informative background areas, which improves classification performance and model generalization.
This preprocessing step guarantees that the following stages of feature extraction and classification are performed on clean, relevant data, thereby enhancing the overall performance and reliability of the paddy leaf disease classification model.
Transfer Learning
Transfer learning utilizes pre-trained neural networks to tackle new but related problems, eliminating the need to build models from the ground up. This approach leverages knowledge gained from previous tasks, enabling efficient learning40. Pre-trained models are often developed on extensive datasets and possess robust feature extraction capabilities, making them suitable for fine-tuning on specific datasets. This reduces training time, avoids overfitting, and achieves high accuracy even with limited computational resources.
In this study, transfer learning was employed to identify paddy leaf diseases by evaluating various pre-trained deep learning models. The architecture explored in the experiments includes VGG16, ResNet, InceptionV3, MobileNet, AlexNet, and DenseNet121. Each of these models was initially trained on large datasets, such as ImageNet, and their pre-trained weights were utilized in this work. To adapt the models to the classification task, the following modifications were made:
Model modification: The original fully connected (classification) layers of each model were removed using the parameter include_top=False during model import in Keras. This ensured that only the convolutional base (feature extractor) of each pre-trained model was retained. The output of the last convolutional block was flattened into a one-dimensional vector using the Flatten() layer.
Dense layers: Three fully connected (Dense) layers were appended sequentially after the flattening step. These layers were defined using the Keras Dense() function: the first with 256 neurons and ReLU activation, the second with 128 neurons and ReLU activation, and the third with 64 neurons and ReLU activation. A Dropout layer was also added between layers to reduce overfitting.
Output layer: Three fully connected (Dense) layers were appended sequentially after the flattening step. These layers were defined using the Keras Dense() function: the first with 256 neurons and ReLU activation, the second with 128 neurons and ReLU activation, and the third with 64 neurons and ReLU activation. A Dropout layer (rate 0.4) was also added between layers to reduce overfitting.
The overall pipeline and flow of the methodology, including preprocessing, segmentation, transfer learning model implementation, and evaluation, is depicted in Figure 4. This figure provides a comprehensive overview of the steps followed in this research. By employing transfer learning, training time was successfully minimized, dependency on high-end computational resources was reduced, and significant performance improvements were achieved in paddy leaf disease classification.
Proposed DenseNet121 model for leaf disease classification
Among all the models tested, DenseNet121 exhibited the best performance in classifying paddy leaf diseases, achieving remarkable accuracy. This cutting-edge deep learning model is distinguished by its innovative architecture40, which promotes efficient information flow and enhances feature reuse.
Architecture of DenseNet121: DenseNet121 is characterized by densely connected layers, where each layer can access the feature maps from all preceding layers. This design optimizes information flow, reduces redundancy, and significantly improves the model's overall efficiency.
The architecture consists of the following key components:
Input layer: Receives images resized to 224 x 224pixels for standardized processing.
Initial convolutional layer: Applies a 7 x 7 convolution operation followed by max pooling to reduce the spatial dimensions and extract low-level features.
Dense blocks: The model contains four dense blocks. Each block comprises several convolutional layers connected in a dense manner, meaning each layer has direct access to the outputs of all previous layers within the block.
Transition layers: Positioned between dense blocks, these layers perform a 1 x 1 convolution followed by average pooling to reduce feature dimensions, improving computational efficiency.
Global Average Pooling (GAP): Reduces the spatial dimensions of feature maps before the fully connected layers.
Fully Connected Layer: Produces the output vector for classification.
Custom layers for classification: For this research, the default fully connected layers were replaced with a custom architecture: Flatten layer, three dense layers (256, 128, and 64 neurons with ReLU activation), and a final sigmoid-activated layer for binary classification.
DenseNet121's ability to reuse features and its compact architecture contributed significantly to its superior performance on the paddy leaf disease dataset. This efficiency, coupled with its ability to minimize overfitting, makes it ideal for tasks with limited training data. DenseNet121 achieved better accuracy and generalization than other models due to its feature reuse and gradient flow properties. While models like ResNet and VGG16 performed well, DenseNet121 outperformed them in terms of accuracy and computational efficiency.
In all models, three fully connected (dense) layers were included utilizing ReLU activation functions (as shown in Equation 1), culminating in a final dense layer with a SoftMax activation (Equation 2) to facilitate multi-class classification. This adaptation allowed each model to effectively utilize its pre-trained weights while classifying the images in the dataset.
ReLu f(x) = max(0, X) (1)

where xi represents the input to the SoftMax function, adjusted for classification across the ten Paddy leaf diseases categories. Each model’s unique architecture, combined with this customized output layer, enabled effective feature extraction and accurate image classification.
Figure 5 presents the architectural layout of DenseNet121, showcasing the seamless flow of information through its dense blocks, transition layers, and the tailored classification layers integrated for this research. This visual depiction clarifies how DenseNet121 handles image inputs and generates prediction outputs