0% found this document useful (0 votes)
2 views

Image recognisition

The document discusses the significance of advanced technologies in detecting crop diseases, particularly through machine learning and deep learning methods. It outlines a model utilizing ResNet and EfficientB algorithms to identify diseases from images, aiming to be user-friendly for farmers. The study emphasizes the importance of accurate disease detection to enhance agricultural productivity and reduce economic losses.

Uploaded by

mebhatt007
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Image recognisition

The document discusses the significance of advanced technologies in detecting crop diseases, particularly through machine learning and deep learning methods. It outlines a model utilizing ResNet and EfficientB algorithms to identify diseases from images, aiming to be user-friendly for farmers. The study emphasizes the importance of accurate disease detection to enhance agricultural productivity and reduce economic losses.

Uploaded by

mebhatt007
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

PREFACE

Agriculture, one of the most important forms of livelihood is often affected by various factors which
either serve as beneficial or destructive for the crop. Crops can get destroyed in large quantities due
to many reasons such as sudden climate change, flood, drought, etc. but one of the most prominent
and deadly reason can be diseases that spread in crops. These diseases not only hamper the growth of
crop but also the quality and quantity of yield. Therefore, it becomes very crucial to detect these
diseases properly and find out a proper cure for the same. However, any of the traditional method of
crop disease prediction is not suitable for the same. So, it is important to figure out more advanced
ways to deal with this. The urge for figuring out the disease-causing organisms in crops have led to
various advanced technologies which are now used to detect the diseases.
Still, there is lot more scope in it and many possible ways which would not only be easy for the
educated society but also the lesser advanced section of society who indulge in traditional farming
methods. Our aim is to produce a model that would be fast, efficient, and easy to understand by the
farmers too, so that they will not need any other’s assistance for the same. In our model we have
basically worked on the model using ResNet 50 and EfficientB0 to EfficientB7 series of algorithms.
These models take the picture of the diseased image and produce the result i.e. the name of the
disease based on the other thousands of training data. This model works in very simple language and
easily understandable by the lesser educated people too.
TABLE OF CONTENTS

Acknowledgement 2
Preface 3
1. INTRODUCTION 5
2. MATERIALS AND METHODS 6
2.1 Dataset(s) Description
2.2 Schematic Layout/Model Diagram/Use case Diagram/DFD
2.3 Methods
2.4 Tools/Technologies
2.5 Evaluation Measures
3. EXPERIMENTATION AND RESULTS 9
3.1 System Specification
3.2 Parameters Used
3.3 Results and Outcomes
3.4 Result Analysis and Validation
4. CONCLUSIONS 14
5. REFERENCES 15

2
INTRODUCTION

Agriculture is crucial for many economies, especially in countries like India, where a big part of the
population depends on it. However, crop diseases pose a constant threat. These diseases, caused by
fungi, bacteria, viruses, or tough conditions, can ruin yields and lead to economic challenges.
Traditional ways of detecting these diseases involve manual checks, which take a lot of time and
need expert knowledge not easily available to most farmers. Fortunately, advances in technology,
especially in machine learning (ML) and deep learning (DL), bring hope. Systems using these
technologies can analyze large sets of plant images, accurately spot diseases, and suggest appropriate
treatments. Convolutional Neural Networks (CNNs), a type of deep learning great at recognizing
images, excel at finding plant diseases from leaf pictures.

The process starts with taking high-resolution leaf images, often using drones or smartphones right in
the fields. These images show visual signs of diseases like spots, discoloration, or wilting.
Environment sensors may also gather data on temperature, humidity, and soil conditions. These
pictures are then preprocessed to enhance crucial disease identification features. This might involve
reducing noise, fixing color variations, or segmenting the image to focus on key areas. Key features
like color properties, texture analysis, or shape characteristics of affected areas are extracted from
these preprocessed images. In our paper we have used various algorithms of the Convolutional
Neural Network such as ResNet50, Inception algorithm, CNN using PyTorch Lightning etc.[1] A
suitable ML algorithm is then trained using labeled data indicating the presence or absence of
diseases in the images and any environmental details. In training, the model learns to spot patterns
that separate healthy and diseased crops. Once trained, this powerful tool can predict disease
presence and type in new unseen images. We have used the technique of transfer learning by which
we are comparing the test results of fewer of our models with the pre-existing trained model.[2] The
model thus trained is compared with the rest of the models based on parameters such as accuracy,
precision, recall and F1 score.
The model's accuracy is crucial for classifying images correctly. Precision measures the ratio of
correctly predicted positive observations to total predicted positives.[3] It shows the real positive
instances among expected ones. Recall is the ratio of accurately predicted positive observations to all
actual positives.[4] It is also called Sensitivity or True Positive Rate, showing how many real
positive events were detected. F1 Score is the harmonic mean of recall and precision.[5] It balances
precision and recall, especially with an uneven class distribution, offering a single score that
combines both.

Equipped with this information‚ farmers can act early with precision‚ applying specific pesticides or
fungicides to reduce crop damage and ensure good harvests. Machine learning boosts disease
identification accuracy‚ saves time for farmers‚ and cuts economic losses overall. It is an advantage
for both the agriculture sector and the hardworking farmers who keep our food systems strong. [6]

3
MATERIALS AND METHODS

2.1 Dataset(s) Description


The dataset we are using is taken from Kaggle comprises of 4,800 images that are used for this study
with a specific focus on plant diseases. It is important to note that these images represent three
different types of plant diseases such as bacterial blight of rice. Each picture has a size of 244x244
pixels, which allows us to maintain dimension and quality consistency all through the set. The
uniformity in image sizes enables faster processing and analysis thus creating a solid foundation for
training and assessing our convolutional neural network models. The wide variety of plant diseases
covered by this dataset makes it particularly suitable for comprehensive training so that the model
can identify a range of plant health conditions with accuracy.

2.2 Schematic Layout

Figure 1:Schematic layout of model

The given flowchart illustrates a step-by-step process of creating a crop disease detection system
using machine learning. Here is the detailed description of each stage presented in Fig. 1. First, there
is a need to identify the problem at hand which is detecting crop diseases. Once the problem has been
identified, an appropriate dataset is selected. This dataset usually includes images of crops damaged
by different diseases which will be used for training and verifying the model. After the dataset is
selected, data preprocessing comes next. This entails cleaning and transforming data to prepare for
analysis. In the case of image data, this can involve resizing images, normalizing pixel values and
expanding the data to increase the diversity and number of training samples. Once all the
preprocessed data is ready, it’s time to build a model. This involves developing and deploying a
machine learning model. CNNs are often used in this case as an architecture for image classification
tasks. The choice of model design must be deliberate in order to allow it to be capable of effectively
learning patterns that indicate crop diseases. After creating your model, it goes through evaluation
stage where it checks its performance against a validation set which ensures that it generalizes well
on unseen data. To assess how well a given model works, metrics such as accuracy, precision, recall
or F1 score are commonly employed.

4
Once initial evaluation has been carried out; testing should be done using a different test dataset from
the one used during training. The final test phase presents an unbiased gauge on how accurately crop
diseases can be detected by the model under real world circumstances

2.3 Methods
Data preprocessing is super important to make sure your dataset is all set and ready to roll for
training lots of Convolutional Neural Network (CNN) models. Our dataset has a total of 4800
images, each one all set at 244x244 pixels, showing three kinds of rice diseases: bacterial blight,
brown spot, and blast. First off, we group the dataset into folders for each type of disease, making
sure everything is neat and tidy for easy access and control. Then, we spice things up with data
augmentation to boost the dataset's variety and toughness. These tricks include random flips up and
down and left & right to jazz things up, spins around randomly to make the model chill no matter
which way it is looking, snips of random cropping to give it different angles, and playing with colors
to imitate different lightings by changing brightness, contrast, saturation, and hue. On top of that, we
make sure everything is evened out by scaling pixel values from 0 to 1 and normalizing images using
mean & standard deviation values from the dataset or standard values from cool pre-trained models
like ImageNet if specific values are not known. We then break it into two sets– one for training
(80%) and another for validation (20%) – to see how the model is doing during training while saving
some bits for final tests later. We use fancy-schmancy data pipelines through PyTorch to smoothen
out the preprocessing work, making sure loading data and adding twists during training runs
smoothly.
The technique we have used here is a form transfer learning with a pre trained model which is
previously trained on a large dataset, and we adapted the pre-trained model for the specific but
related task. Transfer learning: Transfer learning is a machine learning method where a model is
developed for a task that reuses a model developed for a related task. well-trained models, on a wide
variety of datasets, typically for the same task (e.g., image categorisation in ImageNet).
The most excellent transfer for learning is that it increases the speed of training because it takes a lot
of time to build a model from scratch, especially when working on large data sets.
Using a pre-trained version to obtain performance often yields better outcomes, especially while the
untrained dataset is small or akin to the dataset used for the pre-training of the model. Additionally,
for the reason that model has already picked up helpful features from the pre-trained dataset, transfer
studying can be effective inspite of little facts. For this cause, it calls for less records.

2.4 Tools/Technologies
In creating our model for detecting rice leaf diseases, we used a variety of programming languages,
frameworks, and. The main language used was Python because it's simple and great for scientific
computing and machine learning. To do deep learning, we used TensorFlow and Keras. These tools
helped us build and train model easily. NumPy and Pandas were used for data processing and
analysis. Matplotlib was used to make different types of plots for analyzing results. Google Colab
was our development environment, making it easy to run Python code online. We also used GPUs to
speed up training deep neural networks. For evaluating our model, we used Scikit-learn to measure

5
performance metrics. By using these tools together, we created an effective model for detecting rice
leaf diseases.

This visualization exploit the MLxtend (Machine Learning Extensions), Python library containing
many useful tools for it machine learning. Widely used for adding a wide range of data analysis,
machine learning and visualisation capabilities to the capabilities offered by well-known libraries
like NumPy, SciPy, and scikit-learn.
We used Gradio, that is an open-source Python library a totally new and easy way to develop web-
based ML & AI applications. Is aiming to do this by simplifying the process for academics and
developers alike to display their models and algorithms with interactive demos, so that in-depth web
development knowledge is no longer a necessity.

2.5 Evaluation Measures


The evaluation measures provided for each model include Accuracy, Precision, Recall, F1-score,
Model Size, Parameters, Depth, Inference Time (CPU), and Inference Time (GPU). These metrics
are crucial for selecting the most appropriate model for a specific task.
The model's accuracy is crucial for classifying images correctly. Model size, measured in megabytes,
is key for deployment and storage. Parameters indicate model complexity and potential overfitting.
Precision measures the ratio of correctly predicted positive observations to total predicted positives.
It shows the real positive instances among expected ones.
Precision = (TP+FP)/TP.
Recall is the ratio of accurately predicted positive observations to all actual positives. It's also called
Sensitivity or True Positive Rate, showing how many real positive events were detected.
Recall = TP/(FN+TP).
F1 Score is the harmonic mean of recall and precision. It balances precision and recall, especially
with an uneven class distribution, offering a single score that combines both.
F1 Score = 2× ((Precision * Recall) / (Precision + Recall)).

6
EXPERIMENTATION AND RESULTS
3.1 System Specification
Hardware:
The system configuration consists of an 8GB RAM and a Core i5 processor, which together provide
a balanced performance for various computational tasks.
Software:
The setup includes Google Collab, a cloud-based platform that allows users to run Python code in a
web- based interface. This environment is particularly beneficial for data science and machine
learning projects as it supports TensorFlow, a powerful library for deep learning.
Additionally, Google Collab provides access to a 12GB GPU, significantly enhancing the ability to
handle large datasets and complex neural network models, thereby speeding up the training and
execution processes.
3.2 Parameters Used
Optimizer:
An optimizer is really crucial for the training of machine learning models, especially deep learning.
It changes the weights of the neural network to minimise the loss function. Optimize for training
efficiency and effectiveness the choice of optimizer can make a big difference in training your
model.
The other type of adaptive learning rate method is a family of algorithms such as "RMSProp" that
maintain a moving average of the squared gradients to normalize the gradient and "AdaGrad" which
modifies the learning rate to be larger for infrequent parameters and smaller for frequent parameters.
We are using Adaptive Moment Estimation (Adam), an algorithm for first-order gradient-based
optimization of stochastic objective functions that is very simple to implement, compute and
efficient, and it computes individual adaptive learning rates for different parameters from estimates
of first and second moments of the gradients. This combines two powerful ideas: (a) Adaptive
learning rate methods are effective (e. g. AdaGrad).
Learning Rate:
The learning rate highlights the rate at which the learning algorithm can update the existing
information for the newly discovered information or in other words, how fast is the model capable of
learning.8 A high learning rate could shake the model or may converge on a suboptimal decision
tend to be faster, thus making the training less stable. A small value of learning rate might cause the
model to stick at a local optima and might take a long time to converge during training. 0.001 is a
nice beginning point since it is especially appropriate for the Adam optimizer, meaning that learning
rate which has been multiplied by the vector of parameters.
Activation Function:
Activation functions are one of the most important parts of neural networks.They give non-linearity
(which makes the network more expressive and allows it to model/replicate complex patterns in
data). We only used ReLU and Softmax as activation functions. Relu can have output [0, ∞], its

7
equation is Relu(x)=max(0,x). This then reduces the vanishing gradient problem and is
computationally efficient. It is often in hidden layers of neural networks. The Softmax equation is

and Range: (0, 1) and (sum to 1) In multi-class classification issues as an


output layer, where results are interpretable as probabilities, Outputs a list of probabilities.
Shuffle
Shuffled: Means that the order of data samples in the dataset has been put into a random order
Meaning of shuffle phenomenon. The phenomenon of categories that can cause the predictions of
data samples to change drastically depending on the order in which the samples are added to the
dataset This is an important step in the training of NNs as this ensures that the model doesn't learn
any spurious correlation that might have formed due to the ordering of the data, the batches are
independent of each other and that each batch gets an equal representative sample from the data set
and it helps to generalize well by making the training data to resemble more an entire distribution.

Epoch
An epoch is a single pass through the full training dataset. In the training we perform multiple
epochs, allowing model to learn iteratively from the data. The model then can learn from each epoch
and update the weights based on data. We have used 10 epochs in our model trainings.

Pooling
One common type of convolutional networks uses pooling, which is a technique of down-sampling
the input volume through reducing the spatial dimensions (most commonly width, height) in the
CNN volume. Popular pooling types are average pooling, which averages each patch in a feature
map, and max pooling, which takes the maximum value of each patch. This reduces the workload of
running the model, prevents overfitting, and allows for a slightly off input translation.

Batch Size
The no of training samples used in one iteration of training called batch size in keras. With batch
size, it seems that the decision really is between memory use (bigger batch size means larger
memory) and training speed (smaller batch size means the gradient estimate is noisy, and more
iterations can be done in the same amount of time). Also, smaller batches usually tend to generalize
better, however there are buts and ifs in choosing the perfect batch size. In our models, the batch size
was 32.

Validation Split
The part of the training data that is being put aside for the model to learn from during training is
called the validation split. It helps you look for overfitting and it provides a way to see if the model is
fitting the training set too well. It also enables easier tuning of model hyperparameters because you
can get feedback on how well those settings perform to the model. The validation split we used was

8
0.2, which is to say that 20% of the data that I was doing training on we minced from the entire data
was reserved for validation.

9
3.3 Results and Outcomes

Confusion Matrix:
A confusion matrix was generated to visualize the performance of the model in terms of true
positives (TP), true negatives (TN), false positives (FP), and false negatives (FN).

Figure 2:Confusion matrix for PyTorch

Figure 3:Confusion matrix for Inception v3

Accuracy, Precision, Recall and F1-Score:

10
11
3.4 Result Analysis and Validation

The first model which we trained was inception v3 using transfer learning, and after training we got a
accuracy of 95% on both the training set and validation set but when we tried to test the model on
test data or unseen data the model didn’t gave accurate results which means the model is overfitted,
we tried to remove the problem by introducing drop out layer and applying data augmentation but the
results were not good.

The second model which we trained was RestNet50 which gave us an accuracy of 65%, then we train
RestNet 152V2 which gave us an accuracy of 35% making us clear that the Restnet model require
more data to train on which our system would not support.

Then we trained the Pytorch Lightning model and achieved an accuracy of 90% on the test dataset,
indicating the proportion of correctly predicted instances.

The last model which we trained was Efficient Net B0 which produced a accuracy of 99% on both
training and validation set. The model worked well in the test data by giving us an accuracy of 98-
100% . We also tried testing the model on unseen images, where the model gave correct predictions.

Thus, seeing all the model’s accuracy and predictions we can conclude that Efficient Net B0 is the
best Model to proceed with, we then used the gradio module and hosted a web app using the
Efficient Net model which predicts the disease of the uploaded rice plant image by giving us the
probability of it being to the different disease class.

12
CONCLUSION

Creating a crop disease prediction model using advanced machine learning algorithms like
ResNet50, ResNet150 V2, PyTorch CNN and Inception V3 can yield significant insights and
improvements in agricultural diagnostics. ResNet50 and ResNet150 V2 models, known for their
depth and residual connections, perform well in image classification tasks by handling vanishing
gradients and enabling the training of very deep networks. ResNet150 V2, being a deeper version,
typically offers improved accuracy over ResNet50 due to its greater capacity to learn complex
features.

Efficient Net model balances network depth, width, and resolution through a compound scaling
method, making it highly efficient. Efficient Net models tend to achieve high accuracy with fewer
parameters and lower computational costs compared to other architectures. Inception models utilize
factorized convolutions and aggressive dimension reductions, which allow for a deep network with
relatively low computational cost. Inception V3 is particularly adept at capturing multi-scale
features. The dataset's diversity, with 38 classes of crop diseases, presents a complex classification
problem requiring robust feature extraction and generalization capabilities from the model.

The success of the models also depends on the quality and variability of the images. High intra- class
variability and inter-class similarity can affect model performance. Efficient Net often outperforms
others in terms of accuracy and efficiency due to its optimized scaling. Inception V3, while effective,
may require more computational resources compared to Efficient Net for similar accuracy levels due
to its architectural complexity. Efficient Net, due to its balance of accuracy and computational
efficiency, is generally more suitable for real-time applications in resource-constrained
environments. Res Net models, particularly ResNet150 V2, might be more appropriate for scenarios
where computational resources are abundant and the primary goal is achieving the highest possible
accuracy.

Understanding the decision- making process of deep networks remains a challenge. Techniques such
as Grad-CAM can be used to interpret and visualize model predictions, aiding in trust and adoption
by end-users like farmers. While each model architecture has its strengths, EfficientNet stands out
for its balance between accuracy and computational efficiency, making it an excellent choice for
practical deployment in crop disease prediction tasks. ResNet150 V2, with its depth, might provide
the highest accuracy in well-resourced environments. Inception V3 remains a strong contender,
especially in scenarios where multi-scale feature extraction is crucial. Future advancements and
complementary techniques will continue to enhance the effectiveness and applicability of these
models in the agricultural domain.

13
REFRENCES

1. https://www.analyticsvidhya.com/blog/2019/10/building-image-classification-models-cnn-
pytorch/
2. https://www.analyticsvidhya.com/blog/2017/06/transfer-learning-the-art-of-fine-tuning-a-pre-
trained-model/
3. https://en.wikipedia.org/wiki/Precision_and_recall#:~:text=In%20a%20classification%20task
%2C% 20the,false%20positives%2C%20which%20are%20items
4. https://encord.com/blog/classification-metrics-accuracy-precision
5. https://towardsdatascience.com/a-look-at-precision-recall-and-f1-score-36b5fd0dd3ec
6. https://www.itransition.com/machine-learning/agriculture

14

You might also like