Deploy deepface model fastapi (develop)

Alireza Moosavi
2 min readSep 4, 2020

In this article the deployment of this deepface model is going to be explained. This implementation is with Fastapi, Traefik and mongodb.

The repo of this article is here.

Data Model

For the purpose of saving the images from request app, two mongodb model is developed:

Mongo connection
Data model

Fastapi

In order to deploy deepface app, Fastapi framework is going to be employed. This development is built on the docker image:

In docker image the builtin models for face analyze and face compare is going to be downloaded by running preload.py

download dependencies
API for analysis

The art in this implementation is changing the image file into array, for analysis by deepface.

Face compare
Face analyzer

For load balancing Traefik is used.

Traefik configs

To build and run the app:

docker-compose up — build

In the NEXT article the deployment on heroku is explained.

--

--