A minimal implementation of face-detection models using flask, gunicorn, nginx, docker, and docker-compose

This is a simple implementation of dockerized face-detection restful-API implemented with flask, Nginx, and scaled up with Gunicorn. This web service accepts an image as input and returns face-box coordinates.

  1. For face-detection, I used pytorch version of mtcnn from deep_utils library. For more information check
    out deep_utils.
  2. The service is scaled up using gunicorn. The gunicorn is a simple library with high throughput for scaling python services.
    1. To increase the number workers, increase number of workers in the docker-compose.yml file.
    2. For more information about gunicorn workers and threads check the following stackoverflow question
    3. gunicorn-workers-and-threads
  3. nginx is used as a reverse proxy
  1. The face-detection name in docker-compose can be changed to any of the models available by deep-utils library.
  2. For simplicity, I placed the weights of the mtcnn-torch model in app/weights.
  3. To use different face-detection models in deep_utils, apply the following changes:
    1. Change the value of FACE_DETECTION_MODEL in the docker-compose.yml file.
    2. Modify configs of a new model in app/ file.
    3. It’s recommended to run the new model in your local system and acquire the downloaded weights from ~/.deep_utils
      directory and place it inside app/weights directory. This will save you tons of time while working with models with
      heavy weights.
    4. If your new model is based on tensorflow, comment the pytorch installation section in app/Dockerfile and
      uncomment the tensorflow installation lines.

To run the API, install docker and docker-compose, execute the following command:


docker-compose up --build

[email protected]

If you run the service on your local system the following request shall work perfectly:

curl --request POST -F [email protected]/sample-images/movie-stars.jpg

The output will be as follows:


If you find something missing, please open an issue or kindly create a pull request.


Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at:

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

See the License for the specific language governing permissions and limitations under the License.


View Github

Custom react-table-component / Storybook User Guide

5 Things elementary OS 6 Should Improve for a Better Linux Desktop Experience