Simple browser-based face login built with Django and OpenCV.
The app has a simple flow:
- Register a username and a reference photo
- Go to login
- Enter the username
- Take a new photo or upload one
- If the face matches, the user is logged in
- Django 5.2
- OpenCV 4.11
- YuNet face detector
- SFace face recognizer
- Python 3.11+
pip
Important paths:
- Django project root:
facialrecognition/ - Django entry point:
facialrecognition/manage.py - Media uploads:
facialrecognition/facialrecognition/media/ - Face models:
facialrecognition/models/
From the repo root:
python3 -m pip install -r requirements.txtFrom the repo root:
python3 facialrecognition/manage.py migrate
python3 facialrecognition/manage.py runserverThen open:
Find what is using the port:
lsof -nP -iTCP:8000 -sTCP:LISTENKill that process:
kill <PID>If it does not stop:
kill -9 <PID>Or just run Django on another port:
python3 facialrecognition/manage.py runserver 127.0.0.1:8001Then open:
python3 facialrecognition/manage.py check
python3 facialrecognition/manage.py test accounts- Registered profile images are stored on disk in
facialrecognition/facialrecognition/media/images/ - Verification images used during login are not stored permanently
- Media files are now ignored by Git so your uploaded images are not pushed to GitHub
- The app uses the browser camera, not the server camera
- If camera permissions are blocked, you can upload an image instead
- The ONNX face model files are already included in
facialrecognition/models/
Install requirements again:
python3 -m pip install -r requirements.txtRun:
python3 facialrecognition/manage.py migrateUse the commands in the "If Port 8000 Is Already In Use" section above.
Make sure:
- you allowed camera access in the browser
- you are using a browser that supports camera access
- or use the upload option instead