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.
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.
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)
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, addtarget-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
cd mobile-app
yarn install
- For macOS users only:
cd ios
pod install
cd ../
- Set up an Emulator
- Run the app using
npm run android
ornpm run ios
cd web-page
npm install
npm start
- Create GCP account
- Create GCP project
- Create GCP bucket
- Create
models
folder in the GCP bucket - Upload
tomato-disease-detection-model.h5
model frommodels
folder in the repo tomodels
folder in the GCP bucket
- Rename GCP bucket name in
apis/gcf/main.py
accordingly - Install Google Cloud CLI
- Initialize Google Cloud CLI
- Deploy
predict
GCF using Google Cloud SDK Shell by running the following commands. Change the Python version and Project ID accordingly.
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
- Change the url in the
.env
files tohttpsTrigger url
- Run accordingly
- Alternatively, install
app-debug.apk
frommobile-app/android/app/build/outputs/apk/debug
onto an Android device and run the Android mobile app
@codebasics