Skip to content

Martlgap/livefaceidapp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

26 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎭 Live Face Recognition App

A real-time face recognition application built with Gradio that allows you to recognize faces in live webcam video streams directly in your browser. Upload reference images to build a face gallery, then watch as the system identifies matching faces in real-time with confidence scores and visual annotations.

✨ Key Features: Real-time processing β€’ Web-based interface β€’ Multi-face detection β€’ Adjustable similarity thresholds β€’ Live confidence scoring

Python 3.12 Gradio uv License: MIT Last Commit Code style: black

πŸ“‘ Table of Contents

πŸ‘€ Example

As an example, instead of using a webcam I fed a snippet of BigBangTheory into the app and it recognized the characters in real-time:

Demo

πŸš€ Quick Start

πŸ’» System Requirements

Minimum Requirements

  • Python 3.12 (exactly - not 3.11 or 3.13)
  • 4GB RAM (8GB recommended)
  • Webcam (built-in or USB)
  • Modern web browser (Chrome, Firefox, Safari, Edge)

Recommended Setup

  • 8GB+ RAM for optimal performance
  • Multi-core CPU (Intel i5/AMD Ryzen 5 or better)
  • Good lighting conditions for best recognition accuracy
  • uv for fastest dependency management

Supported Platforms

  • βœ… macOS (Intel & Apple Silicon)
  • βœ… Linux (Ubuntu 20.04+, CentOS 8+)
  • βœ… Windows 10/11 (with proper Python setup)

Browser Compatibility

  • βœ… Chrome/Chromium 90+
  • βœ… Firefox 88+
  • βœ… Safari 14+
  • βœ… Edge 90+

Installation & Usage

🟒 Method 1: Using uv (Recommended)

The fastest and most reliable way to get started:

# Clone the repository
git clone https://github.com/Martlgap/livefaceidapp.git
cd livefaceidapp

# Install dependencies and run
uv sync
uv run python main.py

Or use the convenience script:

chmod +x run.sh
./run.sh

βšͺ Method 2: Using pip (Alternative)

If you prefer traditional Python package management:

# Clone and setup virtual environment
git clone https://github.com/Martlgap/livefaceidapp.git
cd livefaceidapp
python -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install dependencies
pip install gradio scikit-image scikit-learn opencv-python-headless onnxruntime mediapipe numpy pillow watchdog memory-profiler

# Run the application
python main.py

πŸ’‘ Pro Tip: The uv approach is significantly faster for dependency resolution and installation, especially on fresh setups.

🌐 Deployment Options

Local Development

The app runs on http://localhost:7860 by default with share=True enabled, automatically generating a public shareable link for easy testing and demonstration.

Server Deployment with HTTPS

For production deployment on a server with HTTPS support:

# Download and setup ssl-proxy
wget https://github.com/suyashkumar/ssl-proxy/releases/download/v0.2.7/ssl-proxy-linux-amd64.tar.gz
tar -xzf ssl-proxy-linux-amd64.tar.gz

# Run with HTTPS proxy
./ssl-proxy-linux-amd64 -from 0.0.0.0:8502 -to 0.0.0.0:7860

Then access your app securely at https://your-server-ip:8502

πŸ”— Alternative: Using Gradio's Built-in Sharing

The app automatically provides a public shareable link when launched, perfect for:

  • Remote demonstrations
  • Cross-device testing
  • Sharing with team members
  • Mobile device access

✨ Why Gradio?

This implementation leverages Gradio's strengths for computer vision applications:

  • πŸŽ₯ Native Webcam Support: Seamless browser-based camera integration
  • ⚑ Real-time Streaming: Optimized for live video processing
  • 🌍 Zero Configuration: Works across platforms without WebRTC setup
  • πŸ“± Mobile Friendly: Responsive design for various devices
  • πŸ”§ Simple Deployment: No complex server configurations needed

πŸ“– How to Use

Step-by-Step Guide

1. πŸ–ΌοΈ Build Your Face Gallery

  • Click "Upload Reference Images" in the left panel
  • Select one or more photos containing faces you want to recognize
  • The system automatically detects faces and adds them to your gallery
  • Each image filename becomes the person's name label

2. πŸŽ₯ Start Live Recognition

  • Allow browser access to your webcam when prompted
  • Position faces in front of the camera
  • Watch as the system detects and recognizes faces in real-time

3. πŸŽ›οΈ Fine-tune Performance

  • Adjust the "Similarity Threshold" slider:
    • Lower values (0.3-0.7): Stricter matching, fewer false positives
    • Higher values (0.8-1.2): More lenient matching, catches more matches
  • Monitor live match scores and confidence percentages in the right panel

4. πŸ“Š Understand the Results

  • Green boxes: Successfully matched faces
  • Blue boxes: Detected but unmatched faces
  • Distance scores: Lower = better match (typically < 1.0 for good matches)
  • Confidence %: Higher = more certain match

βš™οΈ Technical Architecture

The application processes video streams through three optimized stages:

  1. πŸ” Face Detection: MediaPipe's FaceMesh identifies up to 7 faces per frame with precise landmark detection
  2. 🧠 Face Recognition: MobileNetV2-based neural network extracts 512-dimensional face embeddings via ONNX Runtime
  3. 🎯 Face Matching: Cosine distance similarity matching against your gallery with configurable thresholds

The entire pipeline is optimized for real-time performance, processing frames at up to 10 FPS depending on hardware capabilities.

A detailed description of the implementation can be found here:

Medium

🧠 Machine Learning Models

The app uses the following machine learning models:

πŸŽ›οΈ Features

Core Functionality

  • πŸŽ₯ Real-time Face Recognition: Process live webcam feeds with minimal latency
  • πŸ“ Dynamic Gallery Management: Upload multiple reference images to build your face database
  • 🎯 Adjustable Similarity Threshold: Fine-tune recognition sensitivity from strict to lenient
  • πŸ‘₯ Multi-face Detection: Simultaneously detect and recognize up to 7 faces per frame
  • πŸ“Š Live Confidence Scoring: Real-time distance metrics and confidence percentages
  • 🎨 Visual Annotations: Dynamic bounding boxes, name labels, and match indicators

Technical Features

  • 🌐 Browser-based Interface: Zero installation for end users - runs in any modern browser
  • πŸ“± Responsive Design: Optimized for desktop, tablet, and mobile devices
  • ⚑ High Performance: ONNX Runtime optimization for fast inference
  • πŸ”„ Streaming Architecture: Efficient frame processing with Gradio's streaming capabilities
  • πŸŽ›οΈ Interactive Controls: Real-time threshold adjustment and gallery updates

User Experience

  • πŸš€ One-click Setup: Simple script execution to get started
  • πŸ“€ Drag & Drop Upload: Intuitive image gallery management
  • πŸ“ˆ Live Feedback: Instant visual and numerical match results
  • πŸ”— Share Ready: Built-in public link generation for demonstrations

πŸ“– About This Project

πŸŽ“ Background

This application was developed during research at the Chair of Human-Machine Communication at TUM (Technical University of Munich). The primary goal was to evaluate and compare live face recognition systems across different platforms and frameworks.

πŸ”¬ Research Context

The project explores the practical implementation of real-time face recognition in web-based environments, focusing on:

  • Performance benchmarking of different ML frameworks
  • User experience optimization for browser-based computer vision
  • Accessibility of advanced AI technologies through simple interfaces
  • Privacy considerations in live video processing applications

πŸ—οΈ Architecture Evolution

This implementation represents a significant evolution from earlier versions:

  • V1: Original WebRTC-based streaming (complex setup, platform limitations)
  • V2: Streamlit implementation (good but limited real-time capabilities)
  • V3: Current Gradio-based solution (optimal balance of performance and usability)

🀝 Contributing

This project serves as both a research tool and an educational resource. Contributions, suggestions, and improvements are welcome! Whether you're interested in:

  • Performance optimizations
  • Feature enhancements
  • Platform compatibility
  • Documentation improvements

Feel free to open issues or submit pull requests.

πŸ“„ License & Usage

Released under MIT License - feel free to use, modify, and distribute for both academic and commercial purposes. If you use this work in research, please consider citing the associated publications.

οΏ½ Troubleshooting

Common Issues & Solutions

πŸŽ₯ Webcam Problems

  • Camera not detected: Ensure browser permissions are granted and no other apps are using the webcam
  • Poor video quality: Check lighting conditions and camera resolution settings
  • Laggy performance: Close other browser tabs/applications using camera resources

πŸ” Recognition Issues

  • No faces detected: Ensure adequate lighting and face visibility
  • False matches: Decrease similarity threshold (try 0.5-0.7)
  • Missing matches: Increase similarity threshold (try 0.9-1.2)
  • Low confidence scores: Add more/better quality reference images

πŸ’» Performance Issues

  • Slow processing: Check system resources, close unnecessary applications
  • High CPU usage: Normal behavior - face recognition is computationally intensive
  • Memory warnings: Restart the application if processing many large images

πŸš€ Installation Problems

  • Python version: Ensure Python 3.12 is installed (not 3.11 or 3.13)
  • uv not found: Install uv with curl -LsSf https://astral.sh/uv/install.sh | sh
  • Dependencies fail: Try the pip installation method as fallback

πŸ“Š Performance Tips

  • Optimal conditions: Good lighting, clear face visibility, minimal background motion
  • Image quality: Use high-resolution reference images with clear, front-facing photos
  • Hardware: Better performance on systems with dedicated GPUs (future CUDA support planned)

πŸ“š Resources & References

Core Technologies

  • Gradio - Modern ML app framework powering the interface
  • MediaPipe - Production-ready face detection
  • ONNX Runtime - Cross-platform ML inference optimization
  • OpenCV - Computer vision processing library
  • uv - Fast Python package management

Documentation & Guides

Research Papers

About

Simple Live Face Recognition Streamlit App

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors