Crop Disease Detection Using Machine Learning

The main idea behind this project is to build such a crop disease detection system that can help the farmers to save their major crops from damage and disease. This project covers the two major crops in Pakistan which are wheat and rice. These crops are essential for food production and are required

2025-06-28 16:26:02 - Adil Khan

Project Title

Crop Disease Detection Using Machine Learning

Project Area of Specialization Internet of ThingsProject Summary

The main idea behind this project is to build such a crop disease detection system that can help the farmers to save their major crops from damage and disease. This project covers the two major crops in Pakistan which are wheat and rice. These crops are essential for food production and are required in large quantities. A disease on a single plant can cause the whole field to get affected. This system helps overcome this problem and helps to detect the diseases at an early stage. According to studies, crop disease has been a major reason for their disaster, and can be overcome with early stage detection which is not possible for a farmer but possible for scientific technology. Technology has taken over the world in every field, even in agriculture but there are some areas which need to be covered. This disease detection has been made possible with the help of machine learning and deep learning. It also contains a device that takes images in the field and tells the disease type with the image and also share the location of the diseased leaf. It helps save the crops, especially wheat and rice which are the most used as food in Pakistan. It can save the investment of farmers which is used to grow these crops in a large area and also save their workload. 

Project Objectives

Many businesses have come to a standstill due to COVID-19. Many people have lost their jobs. Food is the basic need of living. The food shortage increases day by day due to an increase in the world population. The rest of the businesses can be shut down because of COVID-19, but farming is a process that cannot be stopped. And we can not bear any larger-scale damage to our crops. Diseases are often discovered very late and by then a lot of the crop has gone bad. So there must be a way to detect crop diseases in the early stages with much speed and accuracy. This thing can be achieved by machine learning/deep learning using image processing techniques.

The hardest job in the world is farming. Farmers have to keep an eye on and take care of the crops day and night so that pests and diseases do not wipe out the crops. We want to make things easier for farmers. This project especially focuses on the early-stage detection of crop diseases. It detects the disease in wheat and rice crops. The diseases that are detected include loose smut, brown rust, and black rust in wheat crop, while bacterial leaf blight, brown spot, leaf smut in the rice crop. The farmers get alerts if there is any abnormality in the leaves. It helps to prevent crops from being damaged on a larger scale and creates automation in the agriculture industry. Farmers will not have to go and keep an eye on their crops day and night. With the early-stage detection of crop diseases, it is also easier to treat these diseases and pests. 

Project Implementation Method

To detect the diseases in the crop, a robot is to move over the field to collect the images of the leaves and send them to the server. The robot moves through a rope in a single direction and will be shifted to step for next detection. The image localization technique helps to identify the different number of objects in an image by building a bounding box around them and stating the name on top of it. Each leaf is checked for disease type and then declared as clear or diseased with the disease type. After the disease type is confirmed, the location of the leaf along with its image and disease name is shared on the server and displayed on the screen for the farmer to see it.

'Crop Disease Detection Using Machine Learning' _1659396185.png

To detect the diseases in the crop, the images taken from the camera are first segmented to separate the leaves from a whole bunch. Each leaf will be then checked for the disease to identify the type of the disease and the crop. After training the model,  we got an precision of 0.439 with a loss of 0.017. The image localization technique helps to identify the different number of objects in an image by building a bounding box around them and stating the name on top of it. Each leaf is checked for disease type and then declared as clear or diseased with the disease type. After the disease type is confirmed, the leaf image and disease name is shared on the server and displayed on the screen for the farmer to see it.

Benefits of the Project

The agriculture system has been struggling with plant diseases that affect the production of crops. Due to the diseases in crops, the farmers are facing many problems. The main focus of this project is to detect disease in rice and wheat crops that are spread over a field which makes it difficult for a farmer to detect any disease in the whole crop field. The proposed system will hover over the whole field to detect any type of disease present in those crops.

This project mainly target the farmers and the agricultural industries. Every farmer could need this type of automated system in his fields. Regarding this, the imperative and the most important crops include cotton, rice, wheat, and sugarcane, which accounts overall more than 75% out of the value of the total crop.
The market size could be varying for different farmers based on the type of crops. Along with the farmers, the project can be pitched to different pesticide or agriculture related companies to implement this system. This will help to collect the new data easily and create an ease for farmers.

Technical Details of Final Deliverable

Leaf Detection
The camera, which will be connected to a ESP32, will capture images at regular intervals. Data set of wheat and rice images is used to train the model using YOLOv5, the latest release of the YOLO family which is an object detection method to identify objects separately. It can process pictures roughly at a rate of 155 frames per second, outperforming other object detectors like R-CNN in terms of mean average precision. Each image is processed by the program to identify all the leaves present in it.

Training
The program loads the the YOLOv5 library from GitHub and installs the other required libraries. The augmented dataset is loaded using the Roboflow library and saved in the run time directory. the YOLOv5 train.py file and the data.yaml file containing the class names, and train and validatuon data directory used to train the model. Following hyper-parameters are used in the training of the leaf detection model:

Leaf Segmentation

The idea of segmentation in Machine Learning is well defined in Orkun Furat’s paper titled “Machine Learning Techniques for the Segmentation of Tomographic Image Data of Functional Materials” . It is a technique in which images are segmented using both machine learning and image processing methods. Image localization technique is used and a bounding box is drawn around the objects in the image. The labels are shown on each object referring to the class of that object.

Disease Detection
Once the leaves are detected, the next step is to identify the type of disease on the leaves. A large number of data sets including approximately 300 images of each class is used to train the model. Each class is labeled as the disease type of that particular crop. Each leaf image is resized to 250x250 pixels and optimization is performed on these images. The images are checked using RGB colors and grayscale to identify the diseased part. The model is trained using class names and colored images.

Final Deliverable of the Project HW/SW integrated systemCore Industry AgricultureOther Industries Food Core Technology Internet of Things (IoT)Other Technologies Artificial Intelligence(AI)Sustainable Development Goals Zero Hunger, Good Health and Well-Being for People, Decent Work and Economic Growth, Responsible Consumption and Production, Climate ActionRequired Resources
Item Name Type No. of Units Per Unit Cost (in Rs) Total (in Rs)
Total in (Rs) 21140
ESP32-CAM Equipment116001600
Memory Card Equipment113001300
Robot Structure Miscellaneous 11000010000
Motor Equipment28001600
TFT LCD Display Equipment150005000
IR Sensor Equipment580400
Arduino Uno with Cable Equipment1800800
Breadboard Equipment2100200
Gears Equipment460240

More Posts