A real-time face recognition system built with Flask, OpenCV, and PyTorch, capable of detecting and recognizing faces in images and video streams. The Above is Python Based project. To test live demo of FACE RECOGNITION visit client side based project.
-Link for live demo:- https://cyberface-scan.netlify.app/ -Link of GitHub Repository:- https://github.com/SanketKumarKar/cyberpunk-face-recognition
- Real-time face detection and recognition via webcam
- Video file processing with face detection
- Face alignment using facial landmarks
- Snapshot capture functionality
- Web interface for easy interaction
- Python 3.8 or higher (Python 3.13 compatible)
- Webcam (for real-time recognition)
- Operating System: Windows, macOS, or Linux
git clone https://github.com/SanketKumarKar/face-recognition-project
cd face-recognition-project
python -m venv venv
venv\Scripts\activate
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
- If you encounter issues with dlib installation, install CMake first:
pip install cmake pip install dlib
- Make sure Visual C++ build tools are installed (Download here)
- You might need to install XCode Command Line Tools:
xcode-select --install
- If you encounter dlib installation errors, try:
pip install cmake pip install dlib
- Install the following packages before installing requirements:
sudo apt-get update sudo apt-get install -y build-essential cmake libopenblas-dev liblapack-dev libx11-dev libgtk-3-dev python3-dev
- If you encounter dlib installation errors, try:
pip install cmake pip install dlib
- dlib may not support Python 3.12+ yet. Use Python 3.8–3.11 for best compatibility.
The application will work without a pre-trained model, but will only detect faces without recognizing them.
To include face recognition:
- Place your trained model file in the project root directory
- For PyTorch models, name it
face_recognition_model.pt
- Install system dependencies:
sudo apt-get update sudo apt-get install -y build-essential cmake libopenblas-dev liblapack-dev libx11-dev libgtk-3-dev python3-dev
- (Recommended) Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate
- Install Python dependencies:
pip install -r requirements.txt
- Run the app:
python app.py
- Install Visual C++ Build Tools.
- (Recommended) Create and activate a virtual environment:
python -m venv venv venv\Scripts\activate
- Install CMake and dlib if you have issues:
pip install cmake pip install dlib
- Install Python dependencies:
pip install -r requirements.txt
- Run the app:
python app.py
- Install Xcode Command Line Tools:
xcode-select --install
- (Recommended) Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate
- Install Python dependencies:
pip install -r requirements.txt
- Run the app:
python app.py
- Activate your virtual environment if it's not already activated
- Start the Flask application:
python app.py
- Open your web browser and navigate to:
http://127.0.0.1:5000
-
Live Face Recognition:
- The home page shows your webcam feed with real-time face detection
- Detected faces will be highlighted with a blue rectangle
- If a trained model is loaded, recognized faces will be labeled
-
Take Snapshots:
- Click the "Take Snapshot" button to capture the current frame
- Snapshots will be saved in the
static/snapshots
directory
-
Process Video Files:
- Click "Choose File" to select a video for processing
- Click "Upload" to process the video
- Results will be displayed after processing completes
To train the system to recognize specific faces:
- Collect images of faces you want to recognize
- Organize them into folders, one folder per person
- Run the training script:
python train_model.py --data_dir path/to/face/images
- Make sure your browser has permission to access the camera
- Close other applications that might be using your camera
- Verify that your model file is in the correct format for PyTorch
- Check console logs for specific error messages
- For dlib issues, make sure you have the proper build tools installed (see above OS-specific instructions)
- If you see
ModuleNotFoundError: No module named 'dlib'
, ensure dlib installed successfully:pip install dlib
- If installation fails, check your Python version (dlib may not support Python 3.12+)
- Use
pip install -v
for verbose output to identify specific errors - For Windows, ensure Visual C++ build tools are installed
- For macOS, ensure Xcode Command Line Tools are installed
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.