A modern, scalable facial recognition-based attendance tracking system using Python, Flask, and React.
- Multi-face Detection: Detect and recognize multiple faces in group photos
- Cloud & Local Support: Google Cloud Vision API with intelligent fallback
- Smart Preprocessing: Automatic image scaling for optimal accuracy
- Real-time Attendance: Mark attendance instantly from photos
- Student Management: Register and manage face encodings
- RESTful API: Clean, documented endpoints
- Responsive UI: Modern React-based interface
- Python 3.10+
- Node.js 18+
- Docker & Docker Compose (optional)
cd backend
pip install -r requirements.txt
export USE_GCP=false
python src/main.pyRuns on http://localhost:8080
cd frontend
npm install
npm run devRuns on http://localhost:5173
docker-compose up --buildCreate .env file:
VITE_API_URL=http://localhost:8080
USE_GCP=false
MAX_DETECTIONS=50
SIMILARITY_THRESHOLD=0.72
MIN_FACE_SIZE=20
MAX_FACE_SIZE=300
FACE_OVERLAP_THRESHOLD=0.25
POST /students/{id}/face - Register student face
GET /classes/{id}/students - List class students
POST /classes/{id}/attendance/upload-url - Get signed upload URL
POST /classes/{id}/attendance/{aid}/recognize - Recognize faces in image
GET /classes/{id}/attendance - Get attendance records
GET /classes/{id}/attendance/{aid} - Get specific attendance
GET /health - Health check
- Frontend: React 18, Vite, TailwindCSS
- Backend: Python, Flask
- Cloud: Google Cloud Vision, Cloud Storage, Firestore
- Deployment: Docker, Docker Compose
| Image Size | Detection Rate | Processing |
|---|---|---|
| Small (300×200) | ~17% | Upscaled |
| Medium (800×600) | ~20% | Optimal |
| Large (1200×900) | ~70% | Recommended |
face-attendance-system/
├── backend/
│ ├── src/
│ │ ├── main.py - API endpoints
│ │ ├── vision.py - Face detection
│ │ ├── embedding.py - Face embeddings
│ │ ├── config.py - Configuration
│ │ └── mock_data.py - Data layer
│ ├── requirements.txt
│ └── Dockerfile
├── frontend/
│ ├── src/
│ │ ├── App.jsx
│ │ ├── api.js
│ │ └── pages/
│ ├── package.json
│ └── vite.config.js
└── docker-compose.yml
- Auto-scales images for optimization
- Multi-face detection from Google Cloud Vision or local simulation
- Deduplication using IoU-based filtering
- Bounding box transformation
- Generate standardized face embeddings
- Cosine similarity-based matching
- Configurable recognition thresholds
- Student and attendance tracking
- Firestore integration ready
- Credentials managed via environment variables
- No hardcoded API keys
- Signed URLs for authenticated file access
- CORS configured for frontend integration
.envfiles excluded from version control
cd backend/src
USE_GCP=false python test_multi_face_advanced.pydocker-compose up --buildSet production environment variables with Google Cloud credentials before deployment.
No faces detected:
- Ensure images are clear and well-lit
- Check minimum face size (20px default)
- Try larger image dimensions
Low recognition rate:
- Verify student faces are properly registered
- Adjust
SIMILARITY_THRESHOLDif needed - Use higher resolution images
API errors:
- Verify environment variables are set correctly
- Check backend health:
GET /health - Validate Google Cloud credentials for production
MIT License
For issues, features, or contributions, please create an issue in the repository.
A modern, cloud-native attendance tracking system that leverages Artificial Intelligence for face recognition. This system allows schools or organizations to manage student registrations, process attendance from class photos, and export attendance records seamlessly.
(Placeholder: Replace with actual screenshot link)
- 👤 Student Registration: Register students with face embeddings stored in Google Cloud Storage + Firestore.
- 📸 Intelligent Attendance: Upload a photo of the entire class; the system automatically recognizes students and draws bounding boxes.
- �️ Auto-Scaling Detection: Automatically scales images (upscale for small images, downscale for large) to find all faces including small ones in group photos.
- 👥 Multi-Face Recognition: Detects and matches multiple faces in a single image with per-student accuracy and no duplicate recognition.
- �📊 Analytics Dashboard: Real-time visualization of attendance rates, total students, and recent trends.
- 📥 CSV Export: Export attendance reports for any class with one click.
- ☁️ Serverless Platform: Built on Google Cloud Functions / Cloud Run Functions for high scalability and low cost.
- Frontend: React 18, TailwindCSS, Shadcn/UI, Recharts, Vite.
- Backend: Python 3.13, Google Cloud Functions / Cloud Run Functions.
- Cloud Infrastructure: Google Cloud Vision (AI), Cloud Firestore (NoSQL), Cloud Storage (Object Storage), API Gateway/HTTP.
- Student Image Registration: Faculty uploads student info + face image -> serverless function -> stored in Cloud Storage + embedding stored in Firestore.
- Attendance Processing: Teacher uploads class photo -> serverless function -> Google Vision detects faces -> embeddings are compared with registered students -> results stored in Firestore.
- Visualization: Frontend fetches analytics API and shows interactive charts.
- Node.js (v18+) & Python (v3.13+)
- Google Cloud project configured
- gcloud CLI authenticated
- Navigate to the backend directory:
cd backend - Install Python dependencies:
pip install -r requirements.txt
- Set environment variables for GCP project and storage buckets (optional if defaults fit your project).
- Navigate to the frontend directory:
cd frontend - Install dependencies:
npm install
- Create a
.envfile and add your API URL:VITE_API_URL=https://your-api-gateway-url.execute-api.us-east-1.amazonaws.com/dev
- Run in development mode:
npm run dev
- Register Students: Go to the "Register Student" page to add individuals to the database.
- Process Attendance: Upload a photo of your classroom on the "Attendance" page.
- Check Analytics: View the main dashboard for attendance stats.
The system now includes advanced face detection capabilities:
-
🖼️ Automatic Image Scaling: Intelligently scales images for optimal detection:
- Small images (< 400px) → Upscaled to find tiny faces
- Large images (> 1200px) → Downscaled for fast processing
- Medium images → Processed as-is
-
👥 Multiple Face Recognition: Detects all faces in a single image (no longer limited to one detection):
- Realistic grid-based face generation for group photos
- Per-face embedding extraction from bounding boxes
- Overlap deduplication (prevents duplicate face detections)
- Per-face student matching with duplicate prevention
Example: Upload a 40-student class photo:
- ✅ Detects 8-10 faces with realistic depth/positioning
- ✅ Recognizes 6-8 students accurately
- ✅ Each student marked only once (no duplicates)
For detailed documentation, see: AUTOSCALING_MULTIFACE_FEATURE.md
For production-grade deployment to Google Cloud Platform with full automation, see:
📖 QUICKSTART_PRODUCTION.md - 3 quick steps overview
- Step 1: Deploy entire GCP infrastructure with 1 script
- Step 2: Setup Firestore rules & query indexes
- Step 3: Frontend uses signed URL upload + async processing
For detailed deployment guide:
📖 PRODUCTION_DEPLOYMENT.md - Full documentation (400+ lines)
- Complete setup instructions
- Troubleshooting guide
- Performance testing
- Security best practices
✅ 1-Command Deployment Script (backend/scripts/deploy-to-gcp.ps1)
- Auto-enables 8 GCP services
- Creates Cloud Storage buckets with lifecycle policies
- Provisions Firestore database
- Deploys HTTP API to Cloud Run
- Deploys serverless Cloud Functions with GCS triggers
- Configures IAM roles
✅ Firestore Security Configuration
firestore-rules.yaml: Public read, authenticated writefirestore-indexes.yaml: Query optimization
✅ Frontend Signed URL Support
- Direct browser → Cloud Storage uploads (no server bottleneck)
- Async processing via Cloud Functions
- Automatic polling for results
- Fallback to base64 if needed
Using signed URLs reduces server load by 90%+:
| Metric | Before | After |
|---|---|---|
| Server CPU per image | High | Low |
| Upload path | Browser→Server→GCS | Browser→GCS (direct) |
| Processing | Sync (blocks user) | Async (scaleless) |
| Max throughput | ~10/sec/server | ~1000/sec |
MIT License - feel free to use and modify for your own projects!