Coder Social home page Coder Social logo

one-shot-face-recognition's Introduction

One-Shot Learning for Real-Time Face Recognition

This project implements a Siamese Network for face recognition using live video feed. The Siamese Network is trained to distinguish between different faces by learning to differentiate between pairs of images.

Watch the video

Table of Contents

Introduction

A Siamese Network consists of two identical neural networks with shared weights, which are used to find the similarity between two inputs. This project applies this concept to face recognition, allowing for real-time identification of individuals using a live video feed.

Model

Dataset Preparation

  1. Extract Faces: Use face detection techniques (YOLOV8) to extract faces from a collection of images or video frames.
  2. Create a New Dataset: Organize the extracted face images into a structured dataset. The directory structure should be as follows:
    dataset/
    ├── person1/
    │   ├── image1.jpg
    │   ├── image2.jpg
    │   └── ...
    ├── person2/
    │   ├── image1.jpg
    │   ├── image2.jpg
    │   └── ...
    └── ...
    

Model Training

  1. Preprocess Images: Convert images to BGR, resize them to a fixed size, and normalize pixel values.
  2. Create Pairs: Generate positive and negative pairs of images. Positive pairs are two images of the same person, and negative pairs are two images of different people.
  3. Data Augmentation: Apply data augmentation techniques such as random rotations, shifts, flips, and zooms to increase the diversity of the training dataset and improve model robustness.
  4. Train Siamese Network: Train the Siamese Network using the generated pairs. The network learns to output a similarity score indicating whether two images belong to the same person.

Real-Time Application

  1. Capture Video: Use a webcam or any video capturing device to get a live feed.
  2. Preprocess Frame: For each frame, detect faces and preprocess the face images.
  3. Compare Faces: Compare the detected faces with known faces using the trained Siamese Network to determine if they match any known individual.
  4. Display Results: Display the video feed with recognition results overlayed on the detected faces.

Dependencies

  • Python 3.9+
  • TensorFlow
  • ultralytics
  • OpenCV
  • NumPy

You can install the required dependencies using:

pip install -r requirements.txt

Usage

  1. Prepare Dataset: Ensure your dataset is organized as described in the Dataset Preparation section.
  2. Train Model: Run the training NoteBook to train the Siamese Network.
  3. Run Real-Time Recognition:Use the following command to start the real-time face recognition. Before run change the image path.
python main.py

contributing

Contributions are welcome! Please submit a pull request or open an issue to discuss any changes.

Contact

For any questions or inquiries, you can reach me on LinkedIn: Shukur Alam

one-shot-face-recognition's People

Contributors

shukur-alom 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.