Skip to content

Latest commit

 

History

History
101 lines (85 loc) · 4.69 KB

README.md

File metadata and controls

101 lines (85 loc) · 4.69 KB

Tomato Disease Detection

License

This is an end-to-end project in the agricultural domain. A Convolutional Neural Network (CNN) model is trained to detect whether a tomato plant has a particular disease by using a picture of its leaf. The model can be accessed from a mobile application or a web page.

Mobile App

Web Page

Problem Description

Farmers face economic losses for failing to identify diseases in their tomato plants or giving them wrong treatments after making incorrect assumptions. It is also an additional cost to hire experts to inspect tomato plants and identify diseases.

Solution Approach

A mobile app is developed to help farmers identify tomato diseases by taking pictures of the leaves. This is simple and accurate. The app uses a CNN model trained for image classification.

  • Data Collection: Kaggle PlantVillage Dataset
  • Model: TensorFlow, CNN
  • MLOps: TensorFlow Serving, Docker
  • Backend: FastAPI
  • Frontend: React Native, React JS
  • Deployment: GCP (Google Cloud Platform)

Model

Open In Colab

Running Locally

Setting up Local API

  • cd apis/local
  • pip install -r requirements.txt
  • Install Docker
  • Get docker image for TensorFlow Serving
  • Serve a model by running the TF serving container. Change the folder path accordingly and add the appropriate config file at the end of the command. To serve the latest model, add all-models.config. To serve a target model, add target-models.config.
docker run -t --rm -p 8605:8605 -v C:\Users\User\tomato-disease-detection:/tomato-disease-detection tensorflow/serving --rest_api_port=8605 --allow_version_labels_for_unavailable_models --model_config_file=/tomato-disease-detection/config-files/
  • Change the endpoint in apis/local/main.py accordingly, then run the file in an IDE or using the following command:
uvicorn main:app --reload --host 0.0.0.0

Running Mobile App

  • cd mobile-app
  • yarn install
  • For macOS users only:
cd ios
pod install
cd ../

Running Web Page

cd web-page
npm install
npm start

Running on GCP

Setting up GCP

  • Create GCP account
  • Create GCP project
  • Create GCP bucket
  • Create models folder in the GCP bucket
  • Upload tomato-disease-detection-model.h5 model from models folder in the repo to models folder in the GCP bucket

Deploying GCF (Google Cloud Functions)

cd apis/gcf
gcloud functions deploy predict --runtime python310 --trigger-http --memory 512 --project project-id
  • Enable Google Cloud Build API if necessary
  • Get httpsTrigger url after deployment

Running Mobile App & Web Page

  • Change the url in the .env files to httpsTrigger url
  • Run accordingly
  • Alternatively, install app-debug.apk from mobile-app/android/app/build/outputs/apk/debug onto an Android device and run the Android mobile app

Credits

@codebasics