Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pratikkalein/deploy-tf-cloud-run
Deploy TensorFlow models on Google Cloud Run
https://github.com/pratikkalein/deploy-tf-cloud-run
google-cloud-platform ml strea tensorflow tensorflow-tutorials
Last synced: 7 days ago
JSON representation
Deploy TensorFlow models on Google Cloud Run
- Host: GitHub
- URL: https://github.com/pratikkalein/deploy-tf-cloud-run
- Owner: pratikkalein
- License: mit
- Created: 2024-01-18T12:47:32.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-05T12:38:02.000Z (about 1 year ago)
- Last Synced: 2024-12-21T06:13:21.618Z (2 months ago)
- Topics: google-cloud-platform, ml, strea, tensorflow, tensorflow-tutorials
- Language: Python
- Homepage: http://pratik.tech/tf-run-demo
- Size: 3.09 MB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
MNIST Digit App
An end to end project which shows how to deploy a Tensorflow model on Google Cloud
View Demo »
## About The Project

This project demonstrates how to train a ML model with TensorFlow and deploy the model to Google Cloud Run with the help of Cloud Build and Docker.## Built With



## Getting Started
Set up the project locally.
### Prerequisites
1. Python
2. Pip
3. [Google Cloud SDK](https://cloud.google.com/sdk/docs/install)### Installation
1. Clone the repo
```sh
git clone https://github.com/pratikkalein/deploy-tf-cloud-run.git
```
2. Create and activate virtual environment```sh
python3 -m venv venv
source venv/bin/activate
```3. Install requirements.txt
```sh
pip install -r requirements.txt
```### Train the model
1. Open and run the 01-train.py file
```sh
python3 01-train.py
```You can try playing with the batch size and epochs. Once the training is done a `.keras` file will be saved into the root directory.
2. Run the 02-load.py file to load and test the output of the model.
```sh
python3 02-load.py
```### Deploying the Flask app
1. Change your current working directory to `deploy`
```shell
cd deploy
```2. Make sure you are authenticated with gcloud CLI
```shell
gcloud auth login
```Your default browser will open once you run this command. Choose your Google account.
3. Observe the 03-main.py file to understand how the flask API is working. Start the build using gcloud CLI.
```shell
gcloud builds submit --tag gcr.io//
```
It usually takes 3-4 mins to build.
4. Once the build is done deploy to cloud run.
```shell
gcloud run deploy --image gcr.io// --platform managed
```
It usually takes 3-4 mins to deploy.
5. Go to [Google Cloud Console](https://console.cloud.google.com/run) and open Cloud run. You can find the URL endpoint.### Testing
1. Open the 04-st-app.py and add the URL you got from Cloud run and paste it at the location mentioned in the file.
2. Run the file.
```shell
streamlit run 04-st-app.py
```
3. Upload the image and test the prediction output.## License
Distributed under the MIT License. See `LICENSE.txt` for more information.
## Contact
Pratik Kale
Twitter - [@pratikkalein](https://twitter.com/pratikkalein) LinkedIn- [/in/pratikkalein]()
Project Link: [https://github.com/pratikkalein/deploy-tf-cloud-run](https://github.com/pratikkalein/deploy-tf-cloud-run)
Demo Link : [http://pratik.tech/tf-run-demo](http://pratik.tech/tf-run-demo)