Points Explanation
Points Explanation
➢ Coffee leaf disease detection using CNN, classifying into Minor Diseases, Phoma, Rust, and
Healthy Leaves.
➢ Fine-tuned VGG16 model with preprocessing and data augmentation.
➢ Achieved TPR: 87.95%, TNR: 96.03%, FPR: 3.97%.
➢ Streamlit web app for real-time disease prediction from uploaded images.
➢ Supports early detection, reducing crop loss and improving yield.
➢ Demonstrates CNN's scalability and effectiveness in agricultural disease detection.
1. Coffee Leaf Disease Detection:
• The project identifies coffee leaf diseases using a CNN(Convolutional Neural Network) model.
• It classifies leaves into four categories: Minor Diseases, Phoma, Rust, and Healthy Leaves.
2. Model Details:
• We used the VGG16 model, which is fine-tuned for this task.
• Preprocessing and data augmentation improved the model's performance and robustness.
3. Performance Metrics:
• The model achieved:
o TPR: 87.95% (diseased leaves correctly identified).
o TNR: 96.03% (healthy leaves correctly identified).
o FPR: 3.97% (low misclassification rate).
4. Web Application:
• A Streamlit-based app allows users to upload leaf images.
• It provides instant predictions, making it easy for farmers to check disease status.
5. Impact:
• Helps in early disease detection, reducing crop losses.
• Improves yield and supports efficient farming practices.
6. Significance:
• Demonstrates how CNN can solve real-world agricultural problems.
• Offers a scalable solution for monitoring plant health in real-time.
VGG16 refers to a deep convolutional neural network model developed by the Visual Geometry
Group at the University of Oxford. The "16" in VGG16 indicates that the model consists of 16
layers with trainable weights, including:
• 13 convolutional layers for feature extraction.
• 3 fully connected layers for classification.
This architecture is known for its uniform use of 3x3 convolutional filters and 2x2 max-pooling layers,
making it effective for image classification tasks.
INTRODUCTION:
➢ India produced 350,000 metric tons of coffee in the 2023-24 season, with 80% exported.
➢ Leaf diseases like Phoma and Rust cause 20-30% yield losses in coffee crops.
➢ Traditional disease detection methods are labor-intensive and prone to errors.
➢ CNNs provide an automated and efficient solution for detecting coffee leaf diseases.
➢ VGG16 architecture and data augmentation enhance the accuracy of disease detection
models.
1. India produced 350,000 metric tons of coffee in the 2023-24 season, with 80% exported.
• Coffee is a vital crop in India, contributing significantly to the global coffee supply. The country
ranks as a major producer and exporter, with 80% of its coffee being shipped abroad, indicating
its importance to both the economy and the global market.
2. Leaf diseases like Phoma and Rust cause 20-30% yield losses in coffee crops.
• Phoma and Rust are harmful diseases that can significantly reduce coffee crop yields. These
diseases can lower the quality and quantity of the coffee harvest, which directly impacts the
livelihoods of farmers and the coffee industry.
3. Traditional disease detection methods are labor-intensive and prone to errors.
• Detecting leaf diseases traditionally requires manual inspection, which is time-consuming,
requires a skilled workforce, and is prone to human error. This method is inefficient, especially
for large-scale farms or regions with limited access to experts.
4. CNNs provide an automated and efficient solution for detecting coffee leaf diseases.
• Convolutional Neural Networks (CNNs) can automate the disease detection process by
analyzing leaf images. CNNs are highly effective for image classification tasks, making them an
ideal solution for identifying diseases in coffee leaves quickly and accurately.
5. VGG16 architecture and data augmentation enhance the accuracy of disease detection models.
• The VGG16 architecture, a deep learning model, is specifically designed for image classification
tasks, offering high accuracy. By using data augmentation, the model can be trained on a
variety of image variations, improving its ability to generalize and detect diseases more
effectively in different conditions.
PROBLEM STATEMENT
1. Coffee leaf diseases reduce coffee yield and quality
Diseases like rust and Phoma severely affect coffee plants, leading to lower production
and poorer quality, which directly impacts farmers' income and the coffee industry's growth.
2. Manual detection methods are slow and prone to errors
Traditional disease detection involves visual inspections by farmers or experts, which
takes a lot of time and can result in mistakes, especially in large-scale plantations.
3. The project uses a CNN model (VGG16) to detect diseases automatically
To solve this, the project implements a Convolutional Neural Network (CNN) using the
VGG16 architecture, which is trained to identify different coffee leaf diseases quickly and
accurately.
4. Challenges include handling image variations and ensuring model accuracy
Leaf images vary due to differences in disease stages, lighting, and environmental
conditions. The project addresses these by preprocessing images, using data augmentation,
and optimizing model training to improve reliability.
5. The goal is to provide a reliable tool for early detection and better crop management
By automating disease detection, this project helps farmers identify issues early,
enabling timely action to reduce losses and improve coffee yield and quality.
OBJECTIVES
1. Develop a CNN-based system using VGG16
Create a system leveraging the VGG16 architecture to detect and classify coffee leaf
diseases into four categories: minor, phoma, rust, and non-diseased. The model will be fine-
tuned to maximize accuracy.
2. Optimize data preprocessing and augmentation
Process images consistently with resizing and noise reduction. Use data augmentation
techniques like rotation, flipping, and zooming to enrich the dataset and improve the model's
robustness against variations.
3. Evaluate model performance using key metrics
Measure the model's effectiveness with metrics such as accuracy, TPR, TNR, and FPR.
Analyze results using a confusion matrix to identify strengths and areas for improvement in
disease detection.
4. Deploy a user-friendly system with real-time detection
Implement the model in a Streamlit-based application, allowing users to upload
images and get instant disease classification. Validate its reliability using unseen test data to
ensure real-world applicability.
5. Showcase practical impact for farmers
Highlight the system's role in early detection and effective disease management,
helping farmers reduce crop losses, improve yield, and adopt more sustainable agricultural
practices.
LITERATURE REVIEW
Tomato Leaf Disease Detection Using-CNN - Shanthi D L, Vinutha K, Ashwini N, Saurav Vashistha –
2023
1. High Computational Requirements: CNNs, especially deep learning models like AlexNet and
VGG16, require significant computational power and GPU resources for training and inference.
2. Large Dataset Requirement: CNNs require large datasets for training to achieve high accuracy.
This can be a limitation in scenarios where sufficient labeled data is not available.
3. Overfitting Risk: Without proper regularization and data augmentation, CNN models can
overfit to training data, leading to poor generalization to unseen data.
4. Long Training Time: Training deep learning models like VGG16 and AlexNet can be time-
consuming, especially with large datasets, which may not be feasible in real-time agricultural
applications.
5. Dependency on Image Quality: The accuracy of CNN-based models can be affected by
variations in image quality, lighting, and background, requiring controlled environments for
optimal performance.
METHODOLOGY
1. Dataset Overview
• 1264 images of coffee leaves, classified into four categories: Minor Diseases, Phoma,
Rust, and Healthy leaves.
• Minor Diseases: 332 images, Phoma: 388 images, Rust: 260 images, No Disease: 284
images.
2. Minor Diseases
• Less severe infections, causing small spots or slight deformities on leaves.
• Long-term impact on plant health and yield despite being less critical initially.
3. Phoma (Leaf Spot Disease)
• Fungal disease causing black or brown spots with yellow halos on leaves.
• Results in leaf distortion, premature leaf drop, and reduced photosynthesis.
4. Rust (Coffee Leaf Rust)
• Caused by Hemileia vastatrix, leads to orange/yellow spots on leaves.
• Severe impact on plant health due to defoliation, reducing plant vitality and
productivity.
5. Healthy Leaves
• Baseline images with uniform color, no spots or deformities.
• Critical for training the model to distinguish between diseased and healthy leaves.
6. Preprocessing Steps
• Resizing images to 256x256 pixels for VGG16 model compatibility.
• Normalizing pixel values to a range of 0-1 to ensure efficient training.
7. Data Augmentation Techniques
• Rotation: Helps the model recognize leaf features from different angles.
• Flipping: Simulates variations in leaf positioning and orientation.
• Zooming: Handles different distances and scales of leaf images.
• Cropping: Focuses on specific leaf areas, improving disease detection accuracy
Here’s a detailed explanation for the PowerPoint points:
1. Dataset Overview
• The dataset consists of 1264 images of coffee leaves, categorized into four distinct
classes: Minor Diseases, Phoma, Rust, and Healthy Leaves.
• Minor Diseases (332 images): Represent infections that cause minor damage, such as
small spots or discolorations.
• Phoma (388 images): A fungal disease causing black or brown spots with yellow halos.
• Rust (260 images): Caused by Hemileia vastatrix, resulting in orange/yellow spots that
lead to leaf defoliation.
• No Disease (284 images): Represents healthy leaves with no visible damage.
2. Minor Diseases
• Minor Diseases cause relatively mild symptoms like small spots, discolorations, or
slight leaf deformities. While these diseases might not cause immediate harm to the
plant, they can affect long-term plant health and yield if left unchecked.
• It’s crucial to identify these diseases early as their impact, though subtle, can
compound over time, leading to lower productivity or resistance to other diseases.
3. Phoma (Leaf Spot Disease)
• Phoma is a fungal disease that causes black or brown circular spots surrounded by a
yellow halo on the leaves.
• As the disease progresses, the spots increase in size and number, leading to leaf
distortion and premature leaf drop.
• This disease affects the plant’s photosynthetic capacity, resulting in a decreased
yield and overall vitality of the plant.
4. Rust (Coffee Leaf Rust)
• Rust is caused by the fungus Hemileia vastatrix and is one of the most destructive
diseases for coffee plants.
• The disease is characterized by orange or yellowish powdery spots on the underside
of the leaves. As the disease progresses, the leaves develop a characteristic rust-
colored appearance.
• Extensive leaf drop occurs as the disease advances, which severely
impacts photosynthesis and overall plant health, reducing coffee
production significantly.
5. Healthy Leaves
• Healthy coffee leaves serve as the baseline for training the CNN model.
• These images are free from any visible spots, discolorations, or deformities,
representing a healthy, undisturbed plant.
• Incorporating healthy leaves is essential for the model to distinguish between
diseased and non-diseased states. The model learns to identify deviations from this
baseline, such as spots or color changes, indicating the presence of disease.
6. Preprocessing Steps
• Resizing to 256x256 pixels: Standardizing image size ensures compatibility with
the VGG16 model. This step ensures that all images are fed into the model in the same
format, helping it process the data more efficiently.
• Normalization: This step scales pixel values between 0 and 1 by dividing each pixel by
255. This normalization makes it easier for the model to learn from the data, ensuring
a faster convergence during training. Without normalization, variations in pixel
intensity could slow the model's learning process.
7. Data Augmentation Techniques
• Rotation: By rotating images at different angles, the model learns to recognize
patterns and features of coffee leaves from various perspectives. This is important
since in real-world scenarios, leaves might be captured at different angles.
• Flipping: Horizontal and vertical flipping of images helps the model generalize better,
making it more robust to variations in leaf orientation.
• Zooming: Zooming in and out introduces scale variation to the images. This ensures
the model can handle leaves that might appear larger or smaller based on camera
distance.
• Cropping: Cropping extracts portions of the leaf image, allowing the model to focus
on specific areas of the leaf, such as spots or edges that indicate disease. This
technique helps the model become adept at detecting diseases in different parts of
the leaf.
DATASET SPLIT
1. Data Split: 80% of images for training, 20% for testing.
2. Training Data: Used to teach the model to recognize diseases.
3. Testing Data: Used to check how well the model works on new data.
4. Balanced Split: Ensures enough data for both learning and testing.
5. Model Evaluation: Testing data helps check the model's accuracy.
6. Prevents Overfitting: Keeps the model from memorizing the data.
1. Data Split: The dataset was divided into two parts, with 80% allocated for training the model and
20% reserved for testing. This helps in training the model effectively while also ensuring it is tested
on unseen data.
2. Training Data: This portion of the data is used to teach the model how to identify and classify
different coffee leaf diseases. It helps the model learn the features of each disease by exposing it
to numerous examples.
3. Testing Data: After training, the model is evaluated on the testing dataset, which it has never seen
before. This allows us to assess how well the model can generalize to new, unseen images.
4. Balanced Split: Using an 80/20 split ensures that there is enough data in both sets. A large training
set helps the model learn effectively, while the smaller testing set provides a meaningful evaluation
without overwhelming the model.
5. Model Evaluation: The testing data is used to calculate accuracy and other performance metrics,
which tell us how well the model can correctly classify new leaf images into the appropriate
disease categories.
6. Prevents Overfitting: By using a separate testing dataset, the model is not just memorizing the
training data (overfitting). It forces the model to learn generalizable patterns, making it more
robust and able to handle new, real-world data.
1. Layer Structure:
• A Convolutional Neural Network (CNN) is built using multiple types of layers,
including convolutional layers, pooling layers, and fully connected layers. These
layers work together to process and analyze image data, extracting key features and
making predictions.
2. Convolutional Layers:
• Convolutional layers apply filters (also known as kernels) to the input image to detect
basic features like edges, textures, and simple patterns. These filters move across the
image, generating feature maps that represent different aspects of the image.
Convolutional layers are the core of CNNs as they help the network identify and
understand the structure of the input data.
3. Activation Function:
• The activation function introduces non-linearity to the model. The most commonly
used activation function in CNNs is ReLU (Rectified Linear Unit), which helps the
network learn more complex patterns by allowing positive values to pass through
while converting negative values to zero.
4. Pooling Layers:
• Pooling layers reduce the spatial dimensions (width and height) of the feature maps
generated by the convolutional layers. The most common type of pooling is Max
Pooling, which takes the maximum value from a set of values in a region (usually 2x2
or 3x3). This step helps reduce the computational load, memory usage, and overfitting
while retaining essential features.
5. Fully Connected Layers:
• In fully connected layers, every neuron is connected to every neuron in the previous
layer. These layers process the features learned by the earlier convolutional and
pooling layers and make the final decision (output) based on the learned patterns.
They help the model learn complex relationships between the extracted features.
6. Output Layer:
• The output layer is where the network makes its final predictions. For multi-class
classification tasks, this layer often uses the softmax activation function, which
converts the final output into probabilities, making it easier to decide which class the
input image most likely belongs to.
7. Parameter Sharing:
• Parameter sharing means that the same filters (weights) are applied across different
regions of the input image. This reduces the number of parameters the network needs
to learn, making the model more efficient in terms of computation and memory. It
also allows the network to detect patterns regardless of where they appear in the
image.
8. Feature Hierarchy:
• CNNs learn a hierarchical representation of features. In the initial layers, the network
detects simple features (like edges or textures). As the data progresses through deeper
layers, the model starts detecting more complex features, such as shapes, objects, and
patterns, building a comprehensive understanding of the image from low-level to high-
level features.
STREAMLIT:
1. Open-source framework for building interactive web apps with Python
• Streamlit is a free, open-source framework that makes it easy to create interactive
web applications using Python. It is specifically designed for data scientists and
machine learning practitioners who want to create applications without needing to
learn complex web development skills.
2. Allows quick creation of data apps with minimal coding
• Streamlit simplifies the app development process. You can create full-fledged data
applications with just a few lines of Python code. It abstracts away the complexities of
front-end development, enabling fast deployment of machine learning models and
visualizations.
3. Real-time updates as users interact with widgets like sliders and buttons
• Streamlit apps are dynamic, meaning they update instantly based on user inputs. For
example, if you use a slider or button in the app, the displayed results or visualizations
will change in real time, creating an interactive and responsive experience.
4. Seamless integration with Python libraries like Pandas and TensorFlow
• Streamlit easily integrates with popular Python libraries such as Pandas for data
manipulation and TensorFlow for machine learning. This makes it ideal for data-driven
applications where you need to display tables, graphs, or results from trained models
directly in the web app.
5. Easy deployment without requiring HTML, CSS, or JavaScript
• With Streamlit, there's no need to learn or use front-end technologies like HTML, CSS,
or JavaScript. The framework allows you to focus entirely on your Python logic,
streamlining the process of creating and deploying data apps without the need for
complex web development.
CONFUSION MATRIX
The Confusion Matrix in the image represents the performance of a classification model, specifically
for coffee leaf disease detection. Here’s an explanation of the matrix:
1. True Labels vs. Predicted Labels:
The matrix compares the actual categories (true labels) against the predicted labels made by
the model. The rows represent the true labels (actual classes), while the columns represent
the predicted labels (model's output).
2. Class Labels:
• miner
• nodisease
• phoma
• rust
3. Matrix Elements:
Each cell of the matrix shows the number of predictions made by the model for a given
combination of true and predicted classes.
• Diagonal Elements (True Positives): These indicate the correct predictions made by
the model. For example:
• 61 correctly predicted as miner
• 56 correctly predicted as nodisease
• 64 correctly predicted as phoma
• 42 correctly predicted as rust
• Off-diagonal Elements (Misclassifications): These show where the model made
incorrect predictions. For example:
• 6 samples of miner were incorrectly predicted as nodisease
• 2 samples of nodisease were incorrectly predicted as miner
• 3 samples of miner were predicted as rust
• And so on for other misclassifications.
4. Accuracy:
The overall accuracy of the model is displayed as 88.14%, which means the model correctly
predicted 88.14% of the cases.
5. Interpretation:
The confusion matrix helps in understanding how well the model is performing across different
categories. It highlights which classes are being confused with each other and where the
model might need improvement. For instance, the miner class is often confused
with nodisease and rust, which could indicate areas for further tuning of the model.
TPR, TNR, FPR
In the image, we see the performance metrics for the model: True Positive Rate (TPR), True Negative
Rate (TNR), and False Positive Rate (FPR). Here’s an explanation of each term:
1. True Positive Rate (TPR), also known as Sensitivity or Recall:
• TPR represents the proportion of actual positives (in this case, coffee leaf diseases)
that were correctly identified by the model.
• Formula:
• The values in the array show the TPR for each class (miner, nodisease, phoma, rust).
For example, the TPR for miner is approximately 0.847.
• Average TPR: The average of all these values is 0.88, indicating the overall model’s
ability to correctly identify positive samples.
2. True Negative Rate (TNR), also known as Specificity:
• TNR represents the proportion of actual negatives (healthy leaves or correctly
classified non-diseased) that were correctly identified by the model.
• Formula:
• The values in the array show the TNR for each class. For example, the TNR for miner is
approximately 0.939.
• Average TNR: The average of all these values is 0.96, meaning the model is good at
correctly identifying negative cases (non-diseased leaves).
3. False Positive Rate (FPR):
• FPR represents the proportion of actual negatives that were incorrectly classified as
positives by the model.
• Formula:
• The values in the array show the FPR for each class. For example, the FPR for miner is
approximately 0.060.
• Average FPR: The average of all these values is 0.04, indicating that the model makes
relatively few false positive errors.
Key Points:
• The True Positive Rate is important for understanding how well the model is detecting positive
cases (diseases).
• The True Negative Rate shows how effectively the model is avoiding false alarms
(misclassifying healthy leaves as diseased).
• The False Positive Rate helps to understand the frequency of misclassifying healthy leaves as
diseased.
In this case, the model performs well overall, with high TPR and TNR, and a low FPR, which suggests
that it accurately detects both disease and healthy cases.
ADVANTAGES:
1. High accuracy in detecting complex patterns: Convolutional Neural Networks (CNNs) are
particularly effective at recognizing intricate patterns in images. This ability is essential for
detecting the subtle differences in coffee leaf diseases. CNNs can identify various visual cues
such as texture, shape, and color, which enables them to achieve high accuracy in
distinguishing between different disease types.
2. Real-time automated disease detection: The system can process images quickly and
automatically, allowing for real-time disease detection. This eliminates the need for manual
inspection and provides immediate feedback, which is crucial for timely intervention and
disease management in coffee plantations, preventing further spread of diseases.
3. Versatility for detecting various plant diseases: While the system is designed to detect coffee
leaf diseases, it can be adapted to detect a wide range of plant diseases. By training the model
with different datasets, it can generalize to other crops, making it versatile and useful for
broader agricultural applications beyond coffee plants.
4. Improved robustness through data augmentation: Techniques such as rotation, zooming,
flipping, and other forms of data augmentation are used to increase the variety of training
data. This helps the model learn to recognize patterns in various orientations and lighting
conditions, which improves its robustness and ability to generalize to new, unseen data,
reducing overfitting.
5. Efficient processing of large datasets: Once the model is trained, it can efficiently process large
volumes of image data without requiring extensive computational resources or manual
intervention. This capability is especially important when monitoring large plantations or
handling datasets with many images, making the disease detection process faster and scalable.
DISADVANTAGES:
1. Requires large amounts of labeled data for training:
• CNNs need a significant amount of labeled data to train effectively. For tasks like
disease detection in plants, collecting a large and diverse dataset is crucial to avoid
overfitting and ensure the model generalizes well. The lack of sufficient data can lead
to poor performance.
2. Computationally expensive, needing high processing power and memory:
• Training CNNs requires substantial computational resources, including high-
performance GPUs, large memory capacities, and extended training times. This can be
a limitation for individuals or organizations with limited computational infrastructure.
3. Overfitting can occur if not properly managed with techniques like regularization:
• CNNs are prone to overfitting, where the model becomes too tailored to the training
data and performs poorly on new, unseen data. To prevent this, techniques such as
dropout, data augmentation, and regularization must be applied, but these can add
complexity to the process.
4. Limited interpretability, making it challenging to understand model decisions:
• CNNs are often considered "black-box" models, meaning their decision-making
process is difficult to interpret. This lack of transparency can be an issue, especially in
critical applications where understanding why a decision was made is important for
trust and accountability.
5. Dependent on quality and diversity of training data for generalization:
• The model's ability to generalize well to new data is highly dependent on the quality
and variety of the training dataset. If the data lacks diversity or contains biases, the
model may perform poorly when exposed to real-world scenarios or new disease
strains not represented in the training set.
APPLICATION:
1. Automated disease detection in coffee plants: Using CNNs, the system automates the
identification of diseases on coffee leaves. This reduces the need for manual inspections and
improves accuracy by detecting diseases early, even in the presence of subtle symptoms.
2. Real-time monitoring of plantations for early disease identification: The system allows for
continuous monitoring of coffee plantations. By processing images in real-time, it can quickly
detect any signs of disease, enabling prompt action to prevent the spread of infections.
3. Integration with drones and IoT devices for large-scale monitoring: The disease detection
system can be integrated with drones and IoT devices, allowing for efficient monitoring over
large plantations. This helps in quickly identifying areas of concern across extensive fields,
making it scalable and cost-effective.
4. Precision agriculture for targeted treatments and resource efficiency: The system can assist
farmers by pinpointing infected areas, enabling more precise application of treatments such
as pesticides or fungicides. This targeted approach reduces resource waste and minimizes the
environmental impact of agricultural practices.
5. Cross-crop disease detection for broader agricultural applications: While focused on coffee
leaf diseases, the system can be adapted to detect diseases in other crops. This expands its
usefulness to other agricultural sectors, improving disease management across various types
of crops.
Here’s a detailed step-by-step explanation of True Positive Rate (TPR), True Negative Rate (TNR),
and False Positive Rate (FPR) with a simple example:
Interpretation:
• The model correctly identifies 80% of diseased leaves.
• Higher TPR means fewer diseased leaves are missed by the model.
2. True Negative Rate (TNR):Measures how many of the actual healthy leaves are correctly
identified.
Interpretation:
• The model correctly identifies 90% of healthy leaves.
• Higher TNR means fewer healthy leaves are wrongly classified as diseased.
3. False Positive Rate (FPR):
Measures how many of the actual healthy leaves are wrongly classified as diseased.
Interpretation:
• The model incorrectly classifies 10% of healthy leaves as diseased.
• Lower FPR means the model makes fewer false alarms.