Skip to content

sujitha-kotyada/face-recognisation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

👤 Real-Time Face Recognition

A real-time face recognition application using a pre-trained Keras model (Teachable Machine) and OpenCV. The app detects faces from a live webcam feed, identifies recognized individuals, and displays bounding boxes with confidence scores.

Python OpenCV TensorFlow


✨ Features

  • 🎥 Real-Time Detection — Live webcam feed with face detection using Haar Cascade classifier
  • 🧠 Face Recognition — Identifies faces using a pre-trained Keras model (Teachable Machine)
  • 📊 Confidence Scores — Displays recognition confidence percentage for each detected face
  • 🟩 Visual Overlays — Green bounding boxes and labeled name tags on detected faces
  • ⚙️ Configurable Threshold — Adjustable confidence threshold (default: 65%) to control recognition sensitivity

🛠️ Tech Stack

Component Technology
Language Python 3.8+
Face Detection OpenCV Haar Cascade
Face Recognition TensorFlow/Keras (Teachable Machine model)
Image Processing OpenCV, NumPy

🚀 Getting Started

Prerequisites

  • Python 3.8+ installed
  • A webcam connected to your computer
  • (Optional) Train your own model at Teachable Machine

Installation

  1. Clone the repository

    git clone https://github.com/your-username/face-recognition.git
    cd face-recognition
  2. Create a virtual environment

    python -m venv .venv
  3. Activate the virtual environment

    • Windows:
      .venv\Scripts\activate
    • macOS/Linux:
      source .venv/bin/activate
  4. Install dependencies

    pip install opencv-python numpy tf-keras
  5. Run the application

    python app.py
  6. Press q to quit the webcam window


📖 How It Works

  1. Face Detection — OpenCV's Haar Cascade classifier detects faces in each webcam frame
  2. Preprocessing — Detected face regions are resized to 224×224 pixels and normalized to [-1, 1] range
  3. Recognition — The pre-trained Keras model predicts the identity from the preprocessed image
  4. Display — Bounding boxes and confidence-labeled name tags are drawn on recognized faces

🎯 Training Your Own Model

  1. Go to Google Teachable Machine
  2. Create an Image Project
  3. Add classes for each person you want to recognize
  4. Train the model and export as Keras (.h5 format)
  5. Replace keras_model.h5 and update labels.txt with your class names

Labels Format (labels.txt)

0 Person_Name_1
1 Person_Name_2
2 Person_Name_3

📁 Project Structure

face-recognition/
├── app.py              # Main application with webcam loop
├── keras_model.h5      # Pre-trained Keras model (Teachable Machine)
├── labels.txt          # Class labels for recognition
├── .gitignore
└── README.md

⚙️ Configuration

You can adjust these constants in app.py:

Constant Default Description
INPUT_SIZE 224 Model input resolution
CONFIDENCE_THRESHOLD 0.65 Minimum confidence to display a name
BOX_COLOR Green Bounding box color (BGR)
FONT_SCALE 0.7 Label text size

📜 License

This project is open source and available under the MIT License.


🙋‍♀️ Author

Sujitha Kotyada@sujitha-kotyada

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages