Smart face recognition attendance system with real-time emotion detection
PresenSense is a full-stack attendance system combining facial recognition, emotion detection, and attention tracking. Built with React and FastAPI, it uses DeepFace and MediaPipe for accurate, real-time biometric analysis.
Key Features:
- π― Real-time face recognition with DeepFace (Facenet)
- π Emotion detection and attention tracking
- π· Multi-camera support with fullscreen mode
- π€ Admin panel for user and attendance management
- βοΈ Google Cloud Storage integration
- π Attendance deduplication
- React 19.1.1 + Vite 7.1.2
- React Router DOM 7.8.2
- Tailwind CSS 4.1.13
- ESLint 9.33.0
- FastAPI 0.116.1 + Uvicorn 0.35.0
- SQLAlchemy 2.0.43
- DeepFace 0.0.95 + MediaPipe 0.10.18
- TensorFlow 2.19.1 + OpenCV 4.12.0.88
- Google Cloud Storage 3.3.0
- Node.js 18+
- Python 3.8+
- ~2GB disk space (for AI models)
1. Clone the repository
git clone https://github.com/SN7k/presensense.git
cd presensense2. Backend Setup
cd server
python -m venv .venv
# Windows
.venv\Scripts\activate
# Linux/Mac
source .venv/bin/activate
pip install -r requirements.txt
python main.py3. Frontend Setup (New terminal)
cd frontend
npm install
npm run dev4. Access Application
- Frontend: http://localhost:5175
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
VITE_API_BASE_URL=http://localhost:8000# Database
DATABASE_URL=sqlite:///./backend.db
# Google Cloud Storage (Optional)
GCP_PROJECT_ID=your-project-id
GCP_BUCKET_NAME=your-bucket-name
GCP_CREDENTIALS_PATH=/path/to/credentials.json
# Face Recognition
MATCH_THRESHOLD=0.6
ATTENDANCE_DEDUP_SECONDS=300presensense/
βββ frontend/ # React application
β βββ src/
β β βββ components/ # UI components
β β βββ pages/ # Page components
β β βββ layouts/ # Layout templates
β β βββ config.js # API configuration
β βββ package.json
β βββ vite.config.js
β
βββ server/ # FastAPI backend
β βββ models/ # AI/ML models
β βββ routes/ # API endpoints
β βββ utils/ # Utility functions
β βββ main.py # App entry point
β βββ db.py # Database models
β βββ requirements.txt
β
βββ README.md
POST /admin/upload # Register user with image
GET /admin/attendance # Get attendance recordsPOST /match/ # Verify face and log attendance
POST /match/stream # Stream processingPOST /emotion/start-session # Start emotion analysis
POST /emotion/analyze-frame # Analyze frameGET /health # Health status
GET /ready # Readiness probe- Facenet-based face embeddings (128-dimension)
- Cosine similarity matching (threshold: 0.6)
- Automatic attendance logging
- 5-minute deduplication window
- 7 emotion categories (happy, sad, angry, fear, surprise, disgust, neutral)
- Real-time confidence scores
- Eye gaze tracking with MediaPipe
- Attention percentage metrics
- Front/back camera switching
- Fullscreen mode with navbar hiding
- Stream persistence during transitions
- Automatic error recovery
- File upload or camera capture registration
- Real-time attendance monitoring
- User management
- Session-based authentication
cd server
gcloud run deploy presensense-backend \
--source . \
--platform managed \
--region asia-south1 \
--allow-unauthenticatedcd frontend
npm run build
# Deploy dist/ folder to NetlifyUpdate frontend .env.local:
VITE_API_BASE_URL=https://your-backend-url.run.app- Ensure HTTPS in production (camera requires secure context)
- Check browser permissions
- Verify camera availability
- Check internet connection for model downloads
- Ensure ~2GB disk space
- Verify Python 3.8+ compatibility
- Adjust
MATCH_THRESHOLD(lower = more lenient) - Ensure good lighting conditions
- Use front-facing camera for registration
- Check image quality
- Verify write permissions in server directory
- Check
DATABASE_URLconfiguration - For PostgreSQL:
DATABASE_URL=postgresql://user:pass@host:5432/db
Important: Change default admin credentials!
- Location:
frontend/src/config.js - Default:
admin/admin123
Best Practices:
- Use HTTPS in production
- Enable CORS only for trusted domains
- Implement rate limiting
- Regular security audits
- Follow biometric data regulations (GDPR, etc.)
Contributions welcome! Please:
- Fork the repository
- Create feature branch (
git checkout -b feature/name) - Commit changes (
git commit -m 'Add feature') - Push to branch (
git push origin feature/name) - Open Pull Request
Code Style:
- Frontend: ESLint rules (React hooks)
- Backend: PEP 8 Python style guide
- Commit messages: Conventional commits
MIT License - see LICENSE for details
Third-party licenses:
- DeepFace: MIT
- MediaPipe: Apache 2.0
- TensorFlow: Apache 2.0
- FastAPI: MIT
- React: MIT
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Built with:
- DeepFace - Face recognition
- MediaPipe - Face mesh & eye tracking
- FastAPI - Backend framework
- React - Frontend library
- Tailwind CSS - Styling