Cotton Disease Prediction into Web & Application

Yagnikbavishi
5 min readMar 17, 2021

Written by Yagnik Bavishi And Prince Ajudiya .

Now a day’s financial impact of agriculture is increase day by day with the economic growth of our country, still, agriculture is one wide sector and that plays a very important role for our county. While keeping track of diseases in plants with the help of specialists can be very costly in the agriculture region. There is a need for a system that can automatically detect the diseases as it can bring revolution in monitoring large fields of crop and then plant leaves can be taken cure as soon as possible after detection of disease. There are so many diseases that affect cotton and many more crops that affect many filed of agriculture. So those identify this disease and how to recover from it. This objective will satisfy our application which helps for doing the prediction of cotton disease as well as how to overcome it.

Project Overview:-

For this project, We have to download the dataset from Kaggle. In this dataset, there are three folders like train, test, and validation folder. In this dataset, there are 4 categories like a diseased cotton leaf, diseased cotton plant, fresh cotton leaf, fresh cotton plant.

In this project, We have created two transfer learning models like Xception and Resent101 and CNN.

Why Transfer Learning?

In transfer learning, we take the pre-trained weights of an already trained model(one that has been trained on millions of images belonging to 1000’s classes, on several high-power GPU’s for several days) and use these already learned features to predict new classes.

Below fig. you can see that the what is accuracy and no of parameter required for the train our model.

For Xception Model:-

Fig.1 No Parameter require for Xception Model
Fig.2 Accuracy and loss after 20 epoch for our dataset

Fig.1&2 we can see that to train our model we require more than twenty-one million total parameters are used to run our model and also we getting an accuracy of more than 98% but it takes so much time to train our model.

Output:-

Fig.3 Predict diseased cotton plant & fresh cotton leaf

For Resent101 Model:-

Fig.4 No of parameter require for Resent101
Fig.5 Accuracy and loss after 20 epochs for our dataset

Fig.3 & 4 we can see that to train our model we require more than forty-three million total parameters is used to run our model and also we getting accuracy more almost 75% but it is also taking so much time to train our model. So we use Xception over Resent101.

To avoid the use of a large no of parameters to train our model we use a convolutional neural network.

Why we using CNN?

Because CNN's are used for image classification and recognition because of their high accuracy. The CNN follows a hierarchical model which works on building a network, like a funnel, and finally gives out a fully connected layer where all the neurons are connected to each other and the output is processed.

After getting the dataset next step is to pass our training data for our CNN model to learn to identify or classify different classes of images. The model architecture used was:

Fig. 6model summary

The loss function used was “sparse_categorical_crossentropy” and the optimizer used was “Adam”. For training the model we used Keras API with tensorflow at backend. The model showed good performance achieving a decent

Fig. 7Accuracy & Loss graph

For the deployment of our convolutional neural network, we have to create a simple website using HTML, CSS, and javascript. This website is useful for the farmer. Using this website users can use input images like cotton plant images or cotton leaf images and predict the output like in cotton plant or cotton leaf is suffering from disease or it is a healthy plant. Also, farmers can see that if the cotton plant or leaf is suffering from the disease how to overcome from that and which medicine is used and which website to use the purchase the medicine that things I have mention in the website.

Fig.8 index.html output
Fig.9 in crop predict disease
Fig. 10 Solution for the disease
Fig.11 Predict healthily plant

Flutter Application:

After that, we have created an android application with help of flutter technology and dart language. In this application, the user enters any cotton leaf or cotton plant image after the user clicks on the predict button it show the prediction of diseases.

Fig.12 Output of the application

Conclusion:-

I learned how to use transfer learning and how to deploy the deep learning model into the flask.

I hope you enjoyed this project.

Source Code:-

Written by Yagnik Bavishi And Prince Ajudiya .

--

--