Skip to content

CardzLieraJr/FaceRecognitionLoginSystem_Django

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Έ Face Recognition Login System (Django + DeepFace)

A simple facial recognition system using **Django + DeepFace + OpenCV**.

βš™οΈ Requirements

- Python 3.10 (IMPORTANT ❗)
- Windows 10/11
- Webcam

πŸ” Check Python Version

py -0

Note: Must be Python 3.10


Create Or Switch Virtual Environment

py -3.10  -m venv venv

Activate Environment (Windows)

venv\Scripts\activate

Install Required Libraries

pip install django deepface numpy

pip install opencv-python==4.9.0.80

🧠 Install TensorFlow (IMPORTANT for DeepFace)

pip install tensorflow==2.15.0

🧠 Install Keras (optional but safe)

pip install keras==2.15.0
pip install tf-keras

πŸš€ Create Django Project

django-admin startproject config .

πŸ“Œ Create App

python manage.py startapp users

βš™οΈ Add App to Django

INSTALLED_APPS = [
    ...
    'users',
]

▢️ Run Server

python manage.py runserver

πŸ“Έ Face Recognition Flow

πŸ‘€ Register Face

β€’ Capture multiple images using webcam
β€’ Save in:
media/faces/username/

πŸ” Login Face

β€’ Capture image
β€’ Compare using DeepFace
β€’ Return match result

πŸ—‘ Delete User

media/faces/username/

Project Structure

face_login/
β”‚
β”œβ”€β”€ config/
β”œβ”€β”€ users/
β”œβ”€β”€ media/
β”‚   └── faces/
β”œβ”€β”€ venv/
└── manage.py

⚠️ Important Notes

βœ” MUST use Python 3.10 (3.11/3.13 may break TensorFlow/DeepFace)
βœ” Good lighting improves accuracy
βœ” Webcam must be accessible
βœ” First DeepFace run may be slow (model download)

🧠 Common Fixes

❌ TensorFlow error

pip install --upgrade pip

❌ OpenCV camera not opening

Check webcam permissions

❌ DeepFace slow first run

Normal (downloads AI models)

πŸ‘€ 1. REGISTER (Save Face)

http://127.0.0.1:8000/users/register/?name=ricardo

πŸ“Έ What happens:

1. Camera opens
2. You press:
    β€’ S = save image
    β€’ Q = quit
3. Images are saved here:

    media/faces/ricardo/
        0.jpg
        1.jpg
        2.jpg

🧠 Result:

User β€œricardo” is now registered in the system.

πŸ” 2. LOGIN (Face Recognition)

http://127.0.0.1:8000/users/login/

πŸ“Έ What happens:

1. Camera opens
2. Takes 1 snapshot
3. Saves temporary image:
    β€’ media/temp.jpg
4. DeepFace compares:
    β€’ temp.jpg vs all saved faces

🧠 Result:

If match found:

{
  "status": "success",
  "user": "ricardo"
}

If no match:

{
  "status": "failed"
}

πŸ—‘ 3. DELETE USER (Remove Face Data)

http://127.0.0.1:8000/users/delete/?name=yourname

🧹 What happens:

Deletes folder:
    media/faces/ricardo/

🧠 Result:

if deleted

{
  "status": "deleted",
  "user": "ricardo"
}

If not found:

{
  "status": "not found"
}

βš™οΈ SIMPLE FLOW SUMMARY

πŸ‘€ REGISTER β†’ save face images in folder
πŸ” LOGIN β†’ compare camera face with saved faces
πŸ—‘ DELETE β†’ remove user folder

⚠️ IMPORTANT REMINDERS

βœ” Always run server first:

βœ” Always activate venv:

venv\Scripts\activate

βœ” Use good lighting for face detection


πŸš€ Future Improvements

Real-time video recognition
Face embeddings (faster login)
Database instead of folders
Liveness detection (anti-photo spoofing)
HTML login UI

πŸ‘¨β€πŸ’» Author

Name: Ricardo Jr Liera
Project: Face Recognition Login System
Stack: Django + DeepFace + OpenCV
Year: 2026

About

A simple facial recognition authentication system built using Django, DeepFace, and OpenCV

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages