Plant disease detection
Classify images of leaves
Use pretrained AI to build a powerful model using a publically available dataset.
Human society needs to increase food production, but currently, infectious diseases reduce the potential yield by an average of 40% 1. We need easy ways to diagnose crop disease in order to maximize the harvest.
This tutorial will show you how to build an app similar to Nuru, the app that helps farmers diagnose crop disease in the field.
- Target audience: Beginners
- Tutorial type: Learn AI & platform
- Problem type: Image classification
You will learn to
- Build an image classification model quickly and easily.
- Make the model available for use in an app.
First, click New project to create a project. Name it, so you know what kind of project it is. Naming is important.
Add dataset to the project
After creating the project, you will be taken to the Datasets view, where you can import data.
Click the Import free datasets button.
Find and select the Plant_village dataset.
If you agree with the license, click Accept and import.
This will import the dataset in your project, and you can now edit it.
The Plant village dataset
The Plant village dataset consists of over 50,000 expertly curated images on healthy and infected leaves of crop plants from the online platform PlantVillage.
The images belong to one of 38 possible categories, including a category of images that have no leaves in them.
Create smaller subsets
All samples in the dataset are by default split into 10% validation, 10% test, and 80% training subsets. The default settings are used to train a deployed model for real-world use.
However, this dataset is large, so training your model will take a long time, consuming time, and GPU resources.
At Peltarion, we think it’s a good idea to test your AI model first with a smaller part of the dataset. You will therefore start by using only 8% of the dataset for training and 2% for validation. This will leave 4000 images for training and 1000 images for validation, which is enough to get a quick idea about how well the model can learn the data.
Click Show advanced settings.
In the Subsets section, click New subset.
Name the subset Train 8 / Val 2.
Click the 2. Split subset tab and select Random.
Set the Size of the first subset to 8 and name it Training 8%.
Set the Size of the second subset to 2 and name it Validation 2%.
Click Save version then Use in new experiment.
Build a model in the Experiment wizard
The Experiment wizard pops up. Name the experiment, and in the:
Make sure that the Plant_village dataset and the Train 8 / Val 2 subset is selected.
Inputs / target tab
Select image as Input feature and label as Target feature.
Problem type tab
Select the Single-label image classification.
Single-label image classification is when a deep learning model predicts one class for each example.
Click Create, and all blocks needed will be added to the Modeling canvas.
The wizard creates a complete experiment for you with a complete model and run settings.
You just have to click Run.
Analyze the experiment
Training a model takes some time. It’s the nature of deep learning, and that’s why you use smaller subsets when you test your first model. Using the complete dataset takes even longer time but will probably give you better results.
When the training has stopped, navigate to the Predictions inspection tab in the Evaluation view.
Since the model solves a classification problem, a confusion matrix is displayed.
The top-left to bottom-right diagonal shows correct predictions.
Everything outside this diagonal are errors.
This confusion matrix looks good, but note that the metrics are based on the validation subset, which only consists of 2% of the original dataset.
Let’s deploy this experiment. Note that, in a real project, you want to train the final model on the whole dataset.
Deploy the trained model
Click Create deployment.
Leave the default experiment and checkpoint, since we have trained only one model.
Make the deployment public
Your experiment shows up in the Deployment view.
To make your deployment public, toggle the Private/Public switch. This will allow you to share your results with friends and colleagues on, e.g., with the link, Twitter, LinkedIn.
Enable the deployment
Click Enable to use the experiment outside the platform.
You can now call your deployed experiment with your own product using the Url and Token.
Test with deployment web app
We’ve made it super easy for you to test the deployment.
Click Open web app, and you will be directed to the Deployment web app.
Now, you just need an image to test. Download this image of a potato leaf (same as the one below of an infested plant). Image source AHDB..
Add the image to the app.
Click Get your result.
Share with friends
Now that you see that your AI model works, share the web app with friends and colleagues.
This tutorial has shown you how to use the Experiment wizard and a publically available dataset to create a model ready to classify images.
Your next step can be to dive deeper into how you can improve image classification models. Navigate to our section on how to improve experiments and use our suggestions in your project.
Build an app using your deployed model
Now that you have a deployed model, you can follow our Bubble tutorial. This tutorial will show you how to build an image classifier app. Use the deployed model from this tutorial. Soon you’ll have a functional AI image classification app.
David P. Hughes, Marcel Salathé: An open access repository of images on plant health to enable the development of mobile disease diagnostics, 2015