https://github.com/igopalakrishna/potato-disease-classification
https://github.com/igopalakrishna/potato-disease-classification
Last synced: about 1 year ago
JSON representation
- Host: GitHub
- URL: https://github.com/igopalakrishna/potato-disease-classification
- Owner: igopalakrishna
- Created: 2024-02-14T15:48:02.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-02-14T15:54:38.000Z (over 2 years ago)
- Last Synced: 2024-02-14T16:51:39.044Z (over 2 years ago)
- Language: Jupyter Notebook
- Size: 19 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Potato Disease Classification
## Setup for Python:
1. Install Python ([Setup instructions](https://wiki.python.org/moin/BeginnersGuide))
2. Install Python packages
```
pip3 install -r training/requirements.txt
pip3 install -r api/requirements.txt
```
3. Install Tensorflow Serving ([Setup instructions](https://www.tensorflow.org/tfx/serving/setup))
## Setup for ReactJS
1. Install Nodejs ([Setup instructions](https://nodejs.org/en/download/package-manager/))
2. Install NPM ([Setup instructions](https://www.npmjs.com/get-npm))
3. Install dependencies
```bash
cd frontend
npm install --from-lock-json
npm audit fix
```
4. Copy `.env.example` as `.env`.
5. Change API url in `.env`.
## Setup for React-Native app
1. Go to the [React Native environment setup](https://reactnative.dev/docs/environment-setup), then select `React Native CLI Quickstart` tab.
2. Install dependencies
```bash
cd mobile-app
yarn install
```
- 2.1 Only for mac users
```bash
cd ios && pod install && cd ../
```
3. Copy `.env.example` as `.env`.
4. Change API url in `.env`.
## Training the Model
1. Download the data from [kaggle](https://www.kaggle.com/arjuntejaswi/plant-village).
2. Only keep folders related to Potatoes.
3. Run Jupyter Notebook in Browser.
```bash
jupyter notebook
```
4. Open `training/potato-disease-training.ipynb` in Jupyter Notebook.
5. In cell #2, update the path to dataset.
6. Run all the Cells one by one.
7. Copy the model generated and save it with the version number in the `models` folder.
## Running the API
### Using FastAPI
1. Get inside `api` folder
```bash
cd api
```
2. Run the FastAPI Server using uvicorn
```bash
uvicorn main:app --reload --host 0.0.0.0
```
3. Your API is now running at `0.0.0.0:8000`
### Using FastAPI & TF Serve
1. Get inside `api` folder
```bash
cd api
```
2. Copy the `models.config.example` as `models.config` and update the paths in file.
3. Run the TF Serve (Update config file path below)
```bash
docker run -t --rm -p 8501:8501 -v C:/Code/potato-disease-classification:/potato-disease-classification tensorflow/serving --rest_api_port=8501 --model_config_file=/potato-disease-classification/models.config
```
4. Run the FastAPI Server using uvicorn
For this you can directly run it from your main.py or main-tf-serving.py using pycharm run option (as shown in the video tutorial)
OR you can run it from command prompt as shown below,
```bash
uvicorn main-tf-serving:app --reload --host 0.0.0.0
```
5. Your API is now running at `0.0.0.0:8000`
## Running the Frontend
1. Get inside `api` folder
```bash
cd frontend
```
2. Copy the `.env.example` as `.env` and update `REACT_APP_API_URL` to API URL if needed.
3. Run the frontend
```bash
npm run start
```
## Running the app
1. Get inside `mobile-app` folder
```bash
cd mobile-app
```
2. Copy the `.env.example` as `.env` and update `URL` to API URL if needed.
3. Run the app (android/iOS)
```bash
npm run android
```
or
```bash
npm run ios
```
4. Creating public ([signed APK](https://reactnative.dev/docs/signed-apk-android))
## Creating the TF Lite Model
1. Run Jupyter Notebook in Browser.
```bash
jupyter notebook
```
2. Open `training/tf-lite-converter.ipynb` in Jupyter Notebook.
3. In cell #2, update the path to dataset.
4. Run all the Cells one by one.
5. Model would be saved in `tf-lite-models` folder.
## Deploying the TF Lite on GCP
1. Create a [GCP account](https://console.cloud.google.com/freetrial/signup/tos?_ga=2.25841725.1677013893.1627213171-706917375.1627193643&_gac=1.124122488.1627227734.Cj0KCQjwl_SHBhCQARIsAFIFRVVUZFV7wUg-DVxSlsnlIwSGWxib-owC-s9k6rjWVaF4y7kp1aUv5eQaAj2kEALw_wcB).
2. Create a [Project on GCP](https://cloud.google.com/appengine/docs/standard/nodejs/building-app/creating-project) (Keep note of the project id).
3. Create a [GCP bucket](https://console.cloud.google.com/storage/browser/).
4. Upload the potatoes.h5 model in the bucket in the path `models/potatos.h5`.
5. Install Google Cloud SDK ([Setup instructions](https://cloud.google.com/sdk/docs/quickstarts)).
6. Authenticate with Google Cloud SDK.
```bash
gcloud auth login
```
7. Run the deployment script.
```bash
cd gcp
gcloud functions deploy predict_lite --runtime python38 --trigger-http --memory 512 --project project_id
```
8. Your model is now deployed.
9. Use Postman to test the GCF using the [Trigger URL](https://cloud.google.com/functions/docs/calling/http).
Inspiration: https://cloud.google.com/blog/products/ai-machine-learning/how-to-serve-deep-learning-models-using-tensorflow-2-0-with-cloud-functions
## Deploying the TF Model (.h5) on GCP
1. Create a [GCP account](https://console.cloud.google.com/freetrial/signup/tos?_ga=2.25841725.1677013893.1627213171-706917375.1627193643&_gac=1.124122488.1627227734.Cj0KCQjwl_SHBhCQARIsAFIFRVVUZFV7wUg-DVxSlsnlIwSGWxib-owC-s9k6rjWVaF4y7kp1aUv5eQaAj2kEALw_wcB).
2. Create a [Project on GCP](https://cloud.google.com/appengine/docs/standard/nodejs/building-app/creating-project) (Keep note of the project id).
3. Create a [GCP bucket](https://console.cloud.google.com/storage/browser/).
4. Upload the tf .h5 model generate in the bucket in the path `models/potato-model.h5`.
5. Install Google Cloud SDK ([Setup instructions](https://cloud.google.com/sdk/docs/quickstarts)).
6. Authenticate with Google Cloud SDK.
```bash
gcloud auth login
```
7. Run the deployment script.
```bash
cd gcp
gcloud functions deploy predict --runtime python38 --trigger-http --memory 512 --project project_id
```
8. Your model is now deployed.
9. Use Postman to test the GCF using the [Trigger URL](https://cloud.google.com/functions/docs/calling/http).
Inspiration: https://cloud.google.com/blog/products/ai-machine-learning/how-to-serve-deep-learning-models-using-tensorflow-2-0-with-cloud-functions