Skip to content

About

Face finder web app powered by DeepFace

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

deepface-finder

GitHub Actions Workflow Status GitHub Release Docker pulls

Face finder web app powered by DeepFace

Docker Hub: https://hub.docker.com/r/deniskrumko/deepface-finder

Features:

  • Supports range of ML models to use (see DeepFace docs)
  • Has nice desktop and mobile web UI 💅
  • UI is translated to both English and Russian (can be configured)
  • Supports many image formats (like .heic from iPhones)
  • Uses AWS S3 (or compatible storages) as images/embeddings storage
  • Works both on CPU/GPU

preview

How it works

  • You take a lot of photos (on your birthday party or any huge event)
  • Preprocess files locally using provided scripts once. Read "How to prepare images" section
  • Upload original/resized/embedding files to cloud storage (currently, only AWS S3 is supported)
  • Run deepface-finder as a web server. Read "How to run service" section
  • Upload 1 to 5 files (e.g. your selfies) and instantly find your photos 👌

preview

How to prepare images

This service needs some configuration and files processing before you can use it:

  • Clone deepface-finder repository

    gh repo clone deniskrumko/deepface-finder
  • Create Python 3.12 virtual environment (I like virtualenv-wrapper with pyenv)

    mkvirtualenv deepface-finder -p ~/.pyenv/versions/3.12.4/bin/python
  • Prepare config file. See "Configuration" section bellow. For example, it will be my_config.toml

  • Locate directory with your photos, for example photos/original

  • First, run resizing script

    PYTHONPATH=src py src/scripts/prepare_images.py \
    --src photos/original \
    --dst photos/resized
  • Second, run embedding script

    PYTHONPATH=src py src/scripts/prepare_embeddings.py \
    --src photos/original \
    --dst photos/embeddings \
    --config my_config.toml
  • And the last step, run uploading script

    PYTHONPATH=src py src/scripts/upload_to_s3.py \
    --config my_config.toml \
    --original photos/original \
    --resized photos/resized \
    --embeddings photos/embeddings
  • That's it! Now you can run the service. See "How to run service" section

Configuration

[ui]
language = "en"  # en/ru supported
branding_title = "My Face Finder"
branding_image = "https://media1.tenor.com/m/x8v1oNUOmg4AAAAd/rickroll-roll.gif"
branding_text = """
<p>Welcome to <span class="highlight">My Face Finder</span></p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec dapibus nibh mollis viverra interdum. Donec tortor urna, fringilla quis mattis in, vehicula quis ipsum. Duis ut ligula nec massa pretium viverra. Duis tortor odio, finibus sit amet libero quis, sodales pulvinar quam<p>
"""

[deepface]
model_name = "Facenet"
detector_backend = "yolov8"

[s3]
region = "us-east-1"
endpoint = "YOUR_ENDPOINT"
key = "YOUR_ACCESS_KEY"
secret = "YOUR_SECRET_KEY"

[proxy]
url = "https://my-images-proxy.com/"

[images]
bucket = "deepface-images"
original = "my_birthday_party/original/"
resized = "my_birthday_party/resized/"
embeddings = "my_birthday_party/embeddings/"

With this configuration UI will look like...

preview

How to run service

NOTE: See "CUDA support" section bellow to use CUDA-based Docker image.

  1. Locally using virtual env:

    PYTHONPATH=src APP_CONFIG=my_config.toml python3 -m uvicorn app.main:app --host 0.0.0.0 --port 8080
  2. Using docker-compose.yml

    services:
    
      deepface-finder:
        image: deniskrumko/deepface-finder:latest
        volumes:
          - ./my_config.toml:/config.toml:ro
        ports:
          - 8080:8080
    
  3. Using Docker

    docker run -p 8080:8080 -v ./my_config.toml:/config.toml deniskrumko/deepface-finder:latest

Preload model to Docker image

You can build your custom Docker image with preloaded model and detector backend. It will significantly speedup processing because typically model/detector are loaded only after first request to deepface-finder.

Example Dockerfile with build args:

FROM deniskrumko/deepface-finder:latest

# Preload models
ARG model_name
ARG detector_backend
RUN python3 -m scripts.prepare_models --model-name ${model_name} --detector-backend ${detector_backend}

Then run:

docker build -t deepface-finder:facenet-yolov8 . \
    --build-arg model_name=Facenet \
    --build-arg detector_backend=yolov8

CUDA support

There is a separate Dockerfile that uses CUDA versions of Torch and TorchVision.

Currently there is no CUDA image in DockerHub due to Github Actions CPU/RAM limitations. Best way to use CUDA image is to clone this repository and build own image. Sorry for inconveniences...

Credits

About

Face finder web app powered by DeepFace

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages