Serving ML Model — Photo2Cartoon and RetinaFaceAntiCov

alpha2phi
3 min readApr 20, 2021

Serving Photo2Cartoon and RetinaFaceAntiCov machine learning models using FastAPI and Streamlit.

Overview

In my previous article, I talked about hosting machine learning models using FastAPI and Streamlit. In this article let’s continue to add additional models into the application.

Setup

The application is dockerized into 2 containers separately — 1 for the Streamlit frontend and another for the FastAPI backend. To bring up the application, clone the repository here and run the “make up” command under serving-ml-models folder.

The command basically runs the docker-compose command to create the Docker images and containers and then runs the start-up scripts.

Below is the content of the Makefile.

up:
docker-compose up
build:
docker-compose build
down:
docker-compose down
restart:
make build
make up

The application shall take a while to start as there are quite a number of steps to be executed. Once started, log in to http://localhost:8051 and you should see the Streamlit user interface.

--

--

alpha2phi

Software engineer, Data Science and ML practitioner.