Skip to content

codewithhanzlah/FaceVault-CNN-Biometric-Banking

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏦 Face Recognition Banking System

A secure, modern banking application with facial recognition authentication using a custom-trained Convolutional Neural Network (CNN).


👤 Project Owner

Muhammad Hanzlah
📧 Contact: codewithhanzlah@gmail.com
🎓 Arfa Kareem Technology Incubators - 6 Month Course Final Project


🎯 Project Overview

This is a full-stack web application that combines:

  • 🧠 Deep Learning (96% accuracy face recognition model)
  • 🌐 Web Development (Flask backend + modern frontend)
  • 💰 Banking System (complete financial operations)
  • 🔐 Biometric Security (passwordless login via face scan)

Key Feature: Face authentication replaces traditional password login, providing a seamless and secure banking experience.


✨ Features

🔐 Security Features

  • Face Recognition Login: CNN model with 96% accuracy
  • Biometric Authentication: No password needed for login
  • Session Management: Secure 30-minute sessions
  • 3-Attempt Limit: Prevents brute force attacks
  • Password Protection: Required for sensitive operations (withdraw, transfer)

💰 Banking Features

  • Check Balance: Real-time balance display
  • Deposit Money: Instant deposits with voice confirmation
  • Withdraw Money: Secure withdrawals (password required)
  • Transfer to Beneficiary: Send money to saved contacts
  • Beneficiary Management: Save and view beneficiaries
  • Transaction History: Complete audit trail with timestamps
  • Voice Announcements: Audio feedback for transactions

🎨 UI/UX Features

  • Modern, responsive design (works on mobile + desktop)
  • Smooth animations and transitions
  • Real-time camera preview
  • Confidence score display during authentication
  • Voice feedback for key actions
  • Professional banking interface

🛠️ Technology Stack

Backend

  • Framework: Flask 3.0
  • Language: Python 3.8+
  • Session Management: Flask sessions with secure cookies

Machine Learning

  • Framework: PyTorch 2.2
  • Model: ResNet18 (Transfer Learning)
  • Face Detection: MTCNN (FaceNet PyTorch)
  • Accuracy: 96% on validation set
  • Training Dataset: 233 authorized + 300+ unauthorized face samples

Frontend

  • HTML5: Semantic markup
  • CSS3: Modern styling with animations
  • JavaScript: Camera access, AJAX, voice synthesis
  • WebRTC: Real-time camera streaming

Libraries

  • torch & torchvision: Deep learning
  • opencv-python: Image processing
  • facenet-pytorch: Face detection (MTCNN)
  • pillow: Image manipulation
  • pyttsx3: Text-to-speech (backend)
  • Web Speech API: Text-to-speech (frontend)

📁 Project Structure

face_banking_system/
├── app.py                      # Main Flask application
├── config.py                   # Configuration settings
├── requirements.txt            # Python dependencies
├── README.md                   # This file
├── face_recognition_model.pth  # Trained CNN model (96% accuracy)
├── .gitignore                  # Git ignore rules
│
├── utils/
│   ├── __init__.py
│   ├── face_auth.py           # Face authentication (singleton)
│   ├── banking.py             # Banking logic & Account class
│   └── decorators.py          # Route protection decorators
│
├── static/
│   ├── css/
│   │   └── style.css          # Modern banking design
│   ├── js/
│   │   └── script.js          # Frontend logic
│   └── images/
│       └── logo.png           # Bank logo (optional)
│
└── templates/
    ├── face_login.html        # Face scan login page
    ├── welcome.html           # Welcome splash screen
    ├── dashboard.html         # Main banking dashboard
    ├── deposit.html           # Deposit page
    ├── withdraw.html          # Withdraw page
    ├── transfer.html          # Transfer to beneficiary
    ├── save_beneficiary.html  # Save new beneficiary
    ├── beneficiaries.html     # View all beneficiaries
    └── history.html           # Transaction history

🚀 Installation & Setup

Prerequisites

  • Python 3.8 or higher
  • Webcam (for face authentication)
  • pip package manager

Step 1: Clone Repository

git clone <your-repo-url>
cd face_banking_system

Step 2: Install Dependencies

pip install -r requirements.txt

Step 3: Add CNN Model

  • Place your trained face_recognition_model.pth file in the project root
  • This file should be the output from your Google Colab training

Step 4: Run Application

python app.py

Step 5: Access Application

Open browser and navigate to:

http://127.0.0.1:5000

📸 How to Use

1. Login with Face

  • Open the application
  • Position your face in front of the camera
  • Click "Scan Face" button
  • System detects and authenticates your face
  • Shows confidence score (must be ≥85%)

2. Welcome Screen

  • Full-screen welcome message
  • Voice announcement: "Welcome Muhammad Hanzlah"
  • Automatic redirect to dashboard after 3 seconds

3. Banking Dashboard

  • View current balance
  • Access quick actions (deposit, withdraw, transfer)
  • See recent transactions
  • Navigate to any banking feature

4. Perform Transactions

  • Deposit: No password required
  • Withdraw: Password required (enter your configured password)
  • Transfer: Select beneficiary, enter amount, password required
  • Save Beneficiary: Add new contact with 11-digit account number

5. View History

  • Complete transaction log
  • Timestamps for all operations
  • Filter by transaction type

6. Logout

  • Secure logout from any page
  • Clears session completely

🧠 CNN Model Details

Architecture

  • Base Model: ResNet18 (pre-trained on ImageNet)
  • Transfer Learning: Froze early layers (conv1-layer3)
  • Fine-tuned: Layer4 + custom classifier
  • Classes: 2 (Authorized / Unauthorized)

Training Details

  • Dataset: 233 authorized faces + 300+ unauthorized faces
  • Data Augmentation: Rotation, flip, brightness, zoom
  • Epochs: 50 (with early stopping)
  • Optimizer: Adam (with filtered parameters)
  • Loss: CrossEntropyLoss
  • Validation Accuracy: 96%

Face Detection

  • Library: MTCNN (Multi-task Cascaded Convolutional Networks)
  • Confidence Threshold: 90% for face detection
  • Authentication Threshold: 85% for authorization

⚙️ Configuration

Edit config.py to customize:

# Authentication
FACE_CONFIDENCE_THRESHOLD = 85.0  # Min confidence for login
MAX_LOGIN_ATTEMPTS = 3

# Account Details
# Sensitive values loaded from environment variables

# Session
PERMANENT_SESSION_LIFETIME = 30  # minutes

🔒 Security Features

  1. Face Authentication: 96% accurate CNN model
  2. Session Management: Expires after 30 minutes
  3. Attempt Limiting: 3 failed attempts = lockout
  4. Password Protection: Required for withdrawals/transfers
  5. HTTPS Ready: Can be deployed with SSL certificate
  6. No Credential Storage: Face features extracted on-the-fly

📊 Performance

  • Model Accuracy: 96%
  • False Accept Rate: <3%
  • False Reject Rate: <5%
  • Face Detection Speed: ~100-200ms
  • Authentication Speed: ~300-500ms
  • Total Login Time: <1 second

🎓 Learning Outcomes

This project demonstrates proficiency in:

  • ✅ Deep Learning (CNN, Transfer Learning)
  • ✅ Computer Vision (Face Detection, Recognition)
  • ✅ Web Development (Flask, HTML/CSS/JS)
  • ✅ System Design (MVC pattern, Singleton)
  • ✅ Security (Session management, Authentication)
  • ✅ User Experience (Modern UI, Voice feedback)
  • ✅ Software Engineering (Clean code, Documentation)

🐛 Known Limitations

  • Requires good lighting for face detection
  • Single-user system (designed for one account holder)
  • In-memory data storage (resets on restart)
  • Requires webcam access

🚀 Future Enhancements

  • Multi-user support
  • Database integration (PostgreSQL/MySQL)
  • Mobile app version
  • Liveness detection (anti-spoofing)
  • Dark mode toggle
  • Multi-factor authentication (face + OTP)
  • Email notifications for transactions
  • API for third-party integrations

📜 License

This project is created for educational purposes as part of a 6-month course final project.


🙏 Acknowledgments

  • Instructor: Sir Saad
  • Institute: Arfa Kareem Technology Incubators
  • Course: 6-Month Generative AI Course
  • PyTorch: For the deep learning framework
  • MTCNN: For face detection capabilities
  • Flask: For the web framework

📧 Contact

Muhammad Hanzlah
📧 codewithhanzlah@gmail.com 🔗 github.com/codewithhanzlah 🔗 linkedin.com/in/codewithhanzlah


⭐ If you found this project interesting, please star the repository!

About

ResNet18-based face recognition banking system with 96% accuracy built with PyTorch, Flask & OpenCV

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors