🧠 Face Recognition Attendance System This project is a full-stack face recognition-based attendance system built using:
InsightFace for face detection and embedding.
Pinecone vector database for face similarity search.
Flask for the web interface.
PostgreSQL for attendance record storage.
Integration with Roboflow for dataset management.
📸 Features Extract frames from videos to build datasets.
Train on face embeddings using InsightFace.
Upload embeddings to Pinecone for similarity matching.
Real-time photo capture and recognition in Google Colab.
Flask-based web portal for:
Face recognition via photo.
Attendance logging (enter/exit).
View recent attendance history.
Robust handling of repeated entries and exits.
🚀 Quick Start
- 📦 Install Dependencies bash Copy Edit pip install roboflow insightface onnxruntime faiss-cpu opencv-python-headless matplotlib scikit-learn tqdm flask sqlalchemy python-dotenv If using Pinecone:
bash Copy Edit pip install -U pinecone-client 2. 📥 Download Training Dataset from Roboflow python Copy Edit from roboflow import Roboflow
rf = Roboflow(api_key="YOUR_API_KEY") project = rf.workspace("YOUR_WORKSPACE").project("face-tlml4") version = project.version(1) dataset = version.download("folder") 3. 🧠 Extract Face Embeddings python Copy Edit from insightface.app import FaceAnalysis
app = FaceAnalysis(name="buffalo_l", providers=['CPUExecutionProvider']) # or CUDAExecutionProvider for GPU app.prepare(ctx_id=0)
- 🧠 Upload Embeddings to Pinecone python Copy Edit from pinecone import Pinecone, ServerlessSpec
pc = Pinecone(api_key="YOUR_PINECONE_API_KEY") index_name = "face-embeddings"
pc.create_index( name=index_name, dimension=512, metric="cosine", spec=ServerlessSpec(cloud="gcp", region="us-west1") )
index = pc.Index(index_name) index.upsert([...]) # Upload embeddings in batch 5. 📷 Real-Time Face Recognition in Colab Use webcam-based photo capture and run inference:
python Copy Edit from IPython.display import display, Javascript from google.colab import output Detect face → Get embedding → Query Pinecone → Return label and score.
- 🌐 Flask Web App for Attendance ⚙️ Setup Set up environment variables in .env:
env Copy Edit SECRET_KEY=your-secret-key DATABASE_URL=postgresql://user:password@localhost/face_attendance PINECONE_API_KEY=your-pinecone-key PINECONE_INDEX_NAME=face-embeddings Initialize the database:
bash
Copy
Edit
python initialize_db.py
🔐 Security Notes Use environment variables (.env) for all secrets and keys.
Limit the number of face queries per second if using public APIs.
Enable HTTPS for production deployments.
📚 Future Improvements Add user registration and admin panel.
Add support for mobile camera capture.
Improve recognition accuracy via face alignment.
👨💻 Author Arif M.
📄 License This project is licensed under the MIT License.