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.

Person- Target audience: Beginners
Spaceship- Tutorial type: Learn AI & platform
Bell- Problem type: Image classification

You will learn to
Peltarion logo- Build an image classification model quickly and easily.
Peltarion logo- Make the model available for use in an app.

Want to try it first?
Potato disease
Download the picture above, click Test our live demo, and see if our model finds any disease.

Test our live demo

Create project

First, click New project to create a project. Name it, so you know what kind of project it is. Naming is important.

New project button

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.

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.

Plant disease examples
Figure 1. Examples of images included in the Plant village dataset.

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.

Show advanced settings
  1. In the Subsets section, click New subset.

  2. Name the subset Train 8 / Val 2.

  3. Click the 2. Split subset tab and select Random.

  4. 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%.

  5. Click Create.

Click Save version then Use in new experiment.

Save version - Use in new experiment button

Build a model in the Experiment wizard

The Experiment wizard pops up. Name the experiment, and in the:

  • Dataset tab
    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.

Create button

Run experiment

The wizard creates a complete experiment for you with a complete model and run settings.

You just have to click Run.

Run button

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.

Confusion matrix
Figure 2. Model evaluation — Normalized confusion matrix
  • 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.

Create deployment button

Leave the default experiment and checkpoint, since we have trained only one model.

Click Create

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.

Private to public

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.

URL and token example
Figure 3. URL and token example.

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.

Add the image to the app.

Click Get your result.

Potato disease
Figure 4. Potato leaf with Alternaria. Image source AHDB.

Share with friends

Now that you see that your AI model works, share the web app with friends and colleagues.

Share web app

Tutorial recap

This tutorial has shown you how to use the Experiment wizard and a publically available dataset to create a model ready to classify images.

Next steps

Continue experimenting

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.


Was this page helpful?
Yes No