This repository contains a Face Detection & Verification system built using FastAPI. The model utilizes One-Shot Learning with a deep learning-based FaceNet model to identify and verify individuals.
- Face detection using OpenCV
- Face embedding extraction using FaceNet
- One-shot learning for face verification
- FastAPI-based REST API for easy interaction
git clone https://github.com/Moaz0009/Face-Detection-Verification-FASTAPI.git
cd Face-Detection-Verification-FASTAPIMake sure you have Python installed, then run:
pip install -r requirements.txtuvicorn main:app --reloadThe API will be available at: http://127.0.0.1:8000
Endpoint: GET /
Response:
{"health_check": "OK"}Endpoint: GET /info
Response:
{"name": "Face_Detect_Verify", "description": "A model using One-Shot Learning to Identify and Verify Individuals"}Endpoint: POST /upload_image
Request:
name(form data) - Name of the personimage(file) - Image file to upload
Response:
{"status": "success", "message": "John Doe added to database"}Endpoint: POST /detect_verify
Request:
image(file) - Image file to verify
Response:
{"status": "success", "faces": {"John Doe": [x, y, w, h]}}- Face Embeddings Generation:
- When an image is uploaded, the model extracts face embeddings using FaceNet and stores them in a database.
- Face Verification:
- When an image is sent for verification, the model extracts embeddings and compares them with stored embeddings using Euclidean distance.
- Face Detection:
- Uses OpenCV’s Haar cascade classifier to detect faces before encoding.
FastAPIOpenCVTensorFlow/KerasNumPy
Install them using:
pip install fastapi opencv-python-headless tensorflow numpy uvicorn- Improve face recognition accuracy using different distance metrics.
- Add support for multiple faces in a single image.
- Implement database persistence instead of in-memory storage.
Moaz Abdeljalil
Feel free to contribute or report issues! 🚀