Giter Site home page Giter Site logo

facial-recognition-deployment's Introduction

Facial Recognition Deployment with PostgreSQL and pgvector

Deploying App

This repository contains code for deploying a FastAPI application that utilizes PostgreSQL as its database backend, with support for the pgvector extension for facial recognition. It includes functionality for extracting and saving facial embeddings to PostgreSQL, as well as comparing new embeddings to find the closest facial embeddings.

Containerization and Persistent Storage

The application is containerized using Docker, enabling easy deployment and scalability. Docker volumes are utilized to provide persistent storage, ensuring that data is retained even if containers are restarted or recreated. Additionally, the containers are connected via a Docker network, facilitating seamless communication between different components of the deployed application.

In the Kubernetes deployment, Persistent Volume Claim (PVC) is utilized to ensure that the storage is retained even if the pods are deleted. This provides data persistence and prevents data loss.

To configure Persistent Volume Claim, we have included the following YAML file: YAML

Description

The FastAPI application provides endpoints for various functionalities, including:

  • Interaction with a PostgreSQL database.
  • Integration with the pgvector extension for vector-based operations.
  • Serving API endpoints for your application.

Deploying with Docker Compose

Before running the application, ensure you have the following installed:

  1. Clone the repository:
git clone https://github.com/anas-rz/facial-recognition-deployment.git
cd facial-recognition-deployment
  1. Build and start the Docker containers:
docker compose up -d

Deploy with Kubernetes on GKE

  1. Build the Docker Image

docker build -t gcr.io/[project]/image_name .

  • Replace [project] with your Google Cloud project ID.
  • Replace image_name with the desired name for your image.
  1. Push the Image to Google Container Registry (GCR)

docker push gcr.io/[project]/image_name

  1. Apply YAML Files
kubectl apply -f fastapi-deployment.yaml
kubectl apply -f fastapi-service.yaml
kubectl apply -f postgres-deployment.yaml
kubectl apply -f postgres-pvc.yaml
kubectl apply -f postgres-service.yaml 

Usage

  • Use the provided API endpoints to interact with the application.

    • For registering faces:
    for file in images/input_embeddings/*; do
        curl -X POST -F "file=@$file" -F "name=$(basename $file)" http://localhost:8000/embeddings
    done
    • For comparing faces:
    curl -X POST -F "file=@images/test/shahid_test.jpeg" http://localhost:8000/embeddings/closest

    Make sure to replace images/test/shahid_test.jpeg with the path to the image you want to compare.

  • Modify the FastAPI application code in main.py to add custom functionality as needed.

  • Update the Docker Compose file (docker-compose.yml) to configure additional services or settings.

License

This project is licensed under the MIT License.

Acknowledgements

FastAPI: FastAPI framework documentation.

pgvector: pgvector extension for PostgreSQL.

psycopg2: psycopg2 PostgreSQL adapter for Python.

Docker: Docker Containerization platform.

DeepFace: DeepFace library for facial analysis.

facial-recognition-deployment's People

Contributors

anas-rz avatar

Stargazers

 avatar  avatar Felipe Menegazzi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.