How To Deploy Tensorflow 2.0 Models As An API Service With FastAPI & Docker

Bernard Brenyah
DS Biz
Published in
7 min readNov 3, 2019

--

Image credit: tech-coffee

Machine learning models are meant to be deployed! For some reason, coverage on the deployment of machine learning models is very thin in both literature and the blogging space. It seems the glamour of designing the shiniest and latest cutting edge model with state of the art results appeals more to the machine learning community than what happens after such models are crafted. While that is understandable, some efforts also need to be directed towards the integration of these generated models in production systems. After all, what good is a model if it is not being used after it has been generated? This post attempts to contribute with the deployment of an artificial neural network model (as a RESTfull with FastAPI and Docker

Why FastAPI In The First Place?

There are so many API frameworks for serving models. Just so we are clear this is not some post which will spend bashing the amazing efforts and contributions of each framework. The aim of this post is the exploration of a relatively new API framework which can serve as an alternative to other established frameworks and like Flask, Django and the likes.

FastAPI, according to the authors, has the following advantages compared to the rest of the ecosystem:

--

--