In this project, we will deploy a Pre-trained TensorFlow model with the help of TensorFlow Serving with Docker, and we will also create a visual web interface using Flask web framework which will serve to get predictions from the served TensorFlow model and help end-users to consume through API calls.
The model is entirely based on the official Tensorflow Regression tutorial notebook available here. This model predicts the fuel efficiency of late -1970s and early 1980s automobiles. The model is based on Tensorflow and stored in the Tensorflow SavedModel format. The input features used for this model are attributes of the cars. The output of the model is a single float value.
Prerequisite: Please install docker
- Pull down the source code from this Git repository:
$ git clone https://github.com/bouknify/Flask_Application.git
$ cd Flask_Application- Create and start containers:
If you inspect docker-compose.yml you can see that:
The Tensorflow Serving image is obtained from its public docker hub store (image: tensorflow/serving:2.4.0).
The dnn_service image is defined by the Dockerfile . It's the Containerised Python Web Application (Flask Framework).
And now we can simply run both services together with:
$ docker-compose up- Navigate to 'http://localhost:5000' to view the web interface! and start the predictions...
PyTest is a testing framework that allows us to write test codes using python. It helps to write tests from unit tests to functional tests.
To run all the tests:
$ python -m pytest -v