Following folders and files are included in this repo:
- pets - TensorFlow SavedModel Directory
- static - Empty directory which will be used for storing images by the flask app
- templates - HTML templates are here
- app.py - Flask app
You will require Python3 installed. I used python 3.7 and TensorFlow 2.1.0, and I'd recommend you do the same. It is recommended that you create a new virtual environment to avoid issues with existing installations.
All the dependencies and required libraries are included in the file requirements.txt
See here
- Clone the repo
$ git clone https://github.com/pavitrashah/Deploy-Cats-Vs-Dogs-Model-with-TensorFlow-Serving-and-Flask.git
- Change your directory to the cloned repo and create a Python virtual environment named 'test'
$ python3 -m venv test/
- Now, run the following command in your Terminal/Command Prompt to install the libraries required
$ python3 -m pip install -r requirements.txt
- Open terminal. Go into the cloned project directory folder and type the following command:
$ sudo docker run -p PORT_NUMBER:8501 --name=pets -v "YOUR_SAVED_MODEL_PATH:/models/pets/1" -e MODEL_NAME=pets tensorflow/serving
- In the project, I used 8502 for the PORT_NUMBER , and YOUR_SAVED_MODEL_PATH needs to be the absolute path of the pets folder in your local machine. So, if you extracted the downloaded zip file in, say, /home/example/ , and want to use 8502 for the server port, the above command will become:
$ sudo docker run -p 8502:8501 --name=pets -v "/home/example/pets/:/models/pets/1" -e MODEL_NAME=pets tensorflow/serving
- Once the docker instance is running, you can launch the flask app:
$ python3 app.py
Feel free to mail me for any doubts/query :email: [email protected]
Made with ❤️ by Pavitra Shah
GNU General Public License © Pavitra Shah