Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

15 Commits

Folders and files

Repository files navigation

Project logo

Face Detection and Log Data

Status GitHub Issues GitHub Pull Requests License


Face Recognition Microservices With FastApi and AI Tools

📝 Table of Contents

🧐 About

This project utilizes a microservices architecture to detect and recognize faces from video streams. The workflow is divided into four stages, each handled by a separate microservice. Here’s how it works:

  • First Microservice: Receives video input and preprocesses the frames.
  • Second Microservice: Uses MTCNN to detect faces in each frame and forwards the detected faces along with timestamps to the third microservice.
  • Third Microservice: Employs FaceNet to recognize faces against a pre-existing database. If a face is recognized, it sends the face data, the recognized person's name, and the timestamp to the fourth microservice.
  • Fourth Microservice: Logs the recognized face data along with the name and timestamp.

All microservices are implemented using FastAPI and communicate with each other via POST requests.

🏁 Getting Started and Installation

Before running the microservices, ensure that Docker and Docker Compose are installed on your system.For Docker Instalation see link. Follow these steps to set up the project:

Prerequisites

Clone the repository:

git clone https://github.com/rezasouri/Ai-Task.git
cd AI-Task

Using Docker

First Navigate to Docker directory

cd Docker

Build and run the containers:

docker-compose up --build

This command builds the images if they don’t exist and starts the containers.

Running Locally Without Docker

If you prefer not to use Docker, you can run the APIs locally:

  1. Navigate to the API directory.
  2. Run each service using Python in Terminal with Uvicorn. For example:
uvicorn script_name:app --port PORT_NUMBER --host HOST --reload
  • script_name: Replace this with the name of your Python file that contains the FastAPI app instance (e.g., main.py).
  • app: This should be the name of the FastAPI instance in your script.
  • PORT_NUMBER: Specify the port number on which the server should listen (e.g., 8000).
  • HOST: Define the host address (e.g., 127.0.0.1 for local development or 0.0.0.0 to allow external access).
  • --reload: This optional flag enables auto-reload on code changes, which is very useful during development.

🎈 Usage

Once the services are running, you can send a video stream to the first microservice's endpoint to begin the face detection and recognition process. Use the following endpoint to post video data:

curl -X POST http://localhost:8000/docs#/default/read_video_upload__post \
     -F "file=@/path/to/your/video.file" \
     -H "Content-Type: multipart/form-data"


Or you can go to

http:\\localhost:8000/docs

and send post request (select video and send it)

Alt text

In Docker

You can use this command for see logs data

docker logs [container id]

Results

Results are look like below:

Alt text

⛏️ Built Using

✍️ Authors

📦 Additional Data

For those who prefer to run face detection locally without using the API, you can utilize the scripts provided in the Model directory. Here's how to use them:

1. Encoding Images

  • Navigate to the Model directory.
  • Run the encoding.py script to create embedding data from your images. This step preprocesses your images and creates a dataset of face embeddings that can be used for recognition.

2. Recognizing Faces in Images

  • Use the face_detection_images.py script to recognize faces within static images. This script will analyze each image, detect faces, and attempt to recognize them based on the embeddings created previously.

3. Recognizing Faces in Videos

  • For real-time face recognition, run the face_detection_video.py script. This script is capable of recognizing faces in video streams, including live feeds from a webcam. It processes video frames in real time, detects and recognizes faces, and displays the results.

These tools provide a flexible way to implement face recognition technology directly on your local system, either for development or testing purposes. Feel free to explore and modify the scripts according to your needs!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages