Mildew Detector is an app that can predict whether a cherry leaf is healthy or is infected with powdery mildew. The app is capable of predicting on new image data of a given cherry leaf is healthy or infected.
The project aim is to create a Predictive Analytics Machine Learning Tool that can rapidly and accurately determine whteher an uploaded image of a cherry leaf is a healthy leaf, or one infected with the Powdery Mildew Disease, which is harmful to plants. The prupose of this is to aid the client in limiting their losses as a busienss that relies heavily on cherry leaves as a product for revenue.
The app has been designed using an ML model based on a supervised learning and single-label binary classification. A binary classifer output is used to predict the outcome of data uploaded to the app.
The cherry plantation crop from Farmy & Foods is facing a challenge where their cherry plantations have been presenting powdery mildew. Currently, the process is to manually verify if a given cherry tree contains powdery mildew. An employee spends around 30 minutes in each tree, taking a few samples of tree leaves and verifying visually if the leaf tree is healthy or has powdery mildew. If it has powdery mildew, the employee applies a specific compound to kill the fungus. The time spent applying this compound is 1 minute. The company has thousands of cherry trees located in multiple farms across the country. As a result, this manual process is not scalable due to time spent in the manual process inspection.
To save time in this process, the IT team suggested an ML system that is capable of detecting instantly, using a leaf tree image, if it is healthy or has powdery mildew. A similar manual process is in place for other crops for detecting pests, and if this initiative is successful, there is a realistic chance to replicate this project to all other crops. The dataset is a collection of cherry leaf images provided by Farmy & Foods, taken from their crops.
-
1 - The client is interested in conducting a study to visually differentiate a cherry leaf that is healthy and that contains powdery mildew.
-
2 - The client is interested to predict if a cherry leaf is healthy or contains powdery mildew.
- The dataset is sourced from Kaggle. We created then a fictitious user story where predictive analytics can be applied in a real project in the workplace.
- The dataset contains 4 thousand images taken from client's crop fields. The images show cherry leaves that are healthy and cherry leaves that contain powdery mildew, which is a fungal disease that affects a wide range of plants. The cherry plantation crop is one of their finest products in the portfolio and the company is concerned about supplying the market with a product of compromised quality.
- Infected leaves have clear marks differentiating them from the healthy leaves.We suspect cherry leaves affected by powdery mildew have clear marks, typically the first symptom is a light-green, circular lesion on either leaf surface, then a subtle white cotton-like growth develops in the infected area.
- The client wants to display the mean and variability of healthy cherry leaf images and cherry leaves that contain powdery mildew infection, so that they can visually differentiate between the two.
- The client wants to visually display the difference between an average healthy cherry leaf, and an average powdery mildew infected cherry leaf. This allows detection of distinguishable variations between the two.
- The client would like an image montage to be available for healthy leaf images, and infected leaf images. This is to allow for a visual differentiation between the two image labels, and to recognise appearance patterns across images of the same label.
- The client requires a tool that accurately predicts whether a given cherry leaf is healthy or infected with powdery mildew disease.
- The client needs a data processing and prediction tool that can be assimilated across the company. This will eliminate need for manual detection of the infection which requires employee time and increased personnel resources.
- The company will save time and labour resources, as well as capital spent on these, by increasing the volume of product they can export and provide to the market. This will in turn increase their revenue and therefore provide the company with greater funds to invest in its own productivity and actvitiy.
- The client wants an ML model with a binary classification output, and to have the ability to generate and download a report of the results.
- As a client I want a ML model to predict if the cherry leaf tree is healthy or has powdery mildew.
- The ideal outcome is provide Farmy & Foods with a faster and reliable mildew detection mechanism that is readily scalable across the multiple farms in the country
- The model success metric are:
- A study showing how to visually differentiate a cherry leaf that is healthy from one that contains powdery mildew.
- The capability to predict if a cherry leaf is healthy or contains powdery mildew.
-
Project Dataset
- The available dataset contains 2104 healthy leaves and 2104 affected leaves individually photographed against a neutral background.
-
Business requirements
- A study to visually differentiate a healthy from an infected leaf.
- An accurate prediction whether a given leaf is infected by powdery mildew or not.
- Download a prediction report of the examined leaves.
-
It will answer business requirement 1
- Lists the findings related to the study to visually differentiate a cherry leaf that is healthy from one that contains powdery mildew.
- Checkbox 1 - Difference between average and variability image
- Checkbox 2 - Differences between Healthy and Powdery Mildew Cherry Leaves
- Checkbox 3 - Image Montage
- It will answer business requirement 2
- Link to download a set of cherry leaf images for live prediction
- file upload widget to upload one or more images for prediction
- Display image and prediction statement indicating whether or not a cherry leaf conatins mildew
- Display table with image name and prediction result
- Download button to download table
- Infected leaves have clear marks differentiating them from the healthy leaves.We suspect cherry leaves affected by powdery mildew have clear marks, typically the first symptom is a light-green, circular lesion on either leaf surface, then a subtle white cotton-like growth develops in the infected area.
- A technical page displaying the model performance
- After deploying my project to Heroku, the Image Montage was not displaying since the directory holding the images had the wrong path. so i type the right path and after its displaying the Image Montage
Steps I took to setup environment and deploy to Heroku
The repository for this project was created off the template provided by Code Institute and GitPod workspace was used to develop this project.
- Click the
Use This Template
button. - Add a repository name and brief description.
- Click the
Create Repository from Template
to create your repository. - Click
Gitpod
to create a Gitpod workspace. - To return to the current workspace, login to your gitpod acoount and open the workspace created earlier, since clicking on GitPod button on the GitHub page creates a new workpspace each time.
Cloning the GitHub Repository
Cloning your repository will enable you to work on a local version of the repository.
- Locate the project repository
- Press the arrow on the Code button
- To clone the repository using HTTPS, copy the link that is shown in the drop-down
- Open Git Bash
- Change the current working directory to the location where you want the cloned created
- In the terminal type
git clone
and then paste the link you copied in step 3git clone https://github.com/JohannHelbert/Mildew-Detection
- Press enter and your local clone will be created.
The Python version in the project is set to 3.8.13, which is not supported by Heroku's current default stack, heroku-22. As a result of the above, the app was created from Heroku CLI and set to use buildstack heroku-20.
Steps take to create the app is as follows:
- download and install Heroku CLI if not already installed
- Copy API key from heroku
- sign in and click on the avatar icon and select Account Settings
- Scroll down to the API Key section and click Reveal button, and copy key displayed.
- login to Heroku via the console and enter your details when prompted
heroku login -i
- enter key copied from step 2 when prompted for password
- create the app
heroku apps:create pp5-mildew-detection --stack heroku-20
- The App live link is: https://YOUR_APP_NAME.herokuapp.com/
- Set the runtime.txt Python version to a Heroku-20 stack currently supported version.
- The project was deployed to Heroku using the following steps.
- Log in to Heroku and create an App
- At the Deploy tab, select GitHub as the deployment method.
- Select your repository name and click Search. Once it is found, click Connect.
- Select the branch you want to deploy, then click Deploy Branch.
- The deployment process should happen smoothly if all deployment files are fully functional. Click now the button Open App on the top of the page to access your App.
- If the slug size is too large then add large files not required for the app to the .slugignore file.
- TensorFlow - used during image preprocessing to filter out corrupt images.
- Keras - used for the CNN model
- joblib for saving and loading image shape
- numpy - used for array manipulation.
- pandas - used to structure the data
- matplotlib For creating the charts and plots for data visaulization
- seaborn Used in conjuction with matplotplib for data visualization
- plotly - used for ploting charts for data visualization
- streamlit For the dashboard development
- scikit-learn - used for data processing
- jupyter notebook - used for writing and running the ML pipelines
- Git - used for version control by utilizing the Gitpod terminal to commit to Git and Push to GitHub.
- GitHub: - used to store the projects code after being pushed from Git. Dashboard wireframes during the design process.
- Heroku - Deployment platform for the project
- GitPod - Workspace used for the project
- Codeanywhere - Workspace used for the project
- AmIResponsive - Used to generate responsive image used in README file.
- The codes used to implement the functionalities in the project are from the Code Institute Walkthrough Project 01 (Data Analysis & Machine Learning Toolkit)
- Dataset is from Kaggle
- https://github.com/georgiagrayland/mildew-detection-cherry-leaves-p5 was used as guidace for the readme
- https://github.com/cla-cif/Cherry-Powdery-Mildew-Detector?tab=readme-ov-file#bugs was used as guidace for the readme
- The images used in the readme are from my App Mildew Detection