title: Attendr UTM Smart Attendance
emoji: π
colorFrom: red
colorTo: yellow
sdk: docker
pinned: false
Attendr - Smart Attendance System π
An AI-powered smart attendance system for Universiti Teknologi Malaysia (UTM) that combines facial recognition, geolocation verification, and auto-refresh attendance codes to eliminate proxy attendance and streamline the attendance process.
β¨ Features
For Students
- π Biometric Face Recognition - Secure identity verification using AI
- π GPS Location Validation - Confirms physical presence in classroom
- π Auto-Refresh Codes - Time-limited codes prevent sharing
- β‘ Real-time Feedback - Instant attendance confirmation
- π± Mobile Friendly - Works on smartphones and tablets
For Lecturers
- π― One-Click Session Creation - Quick setup for any class
- π Auto-Refreshing Codes - New code every 2 minutes
- π Real-time Monitoring - Live attendance updates
- π₯ Export Reports - Download CSV for record-keeping
- π Attendance Analytics - View statistics at a glance
Security Features
- β Prevents proxy attendance through face + location verification
- β Time-limited codes expire automatically
- β All verifications logged with timestamps
- β Distance tracking from classroom center
π§ AI Logic & Knowledge Representation
Attendr implements 5 Knowledge Representation (KR) rules using First-Order Logic:
- Face Recognition:
βx ((CapturedFace(x) β§ MatchStored(x)) β FaceMatch(x)) - Location Verification:
βx[(Student(x) β§ IsWithinAllowedArea(x)) β VerifiedLocation(x)] - Device Readiness:
βd ((CameraOn(d) β§ GPSOn(d)) β StartVerification(d)) - Attendance Validation:
βx ((FaceMatch(x) β§ LocationValid(x)) β GrantCodeAccess(x)) - Code Confirmation:
βx ((ValidCodeEntry(User,x) β§ WithinCycle(Code,x)) β MarkPresent(System,x))
π Installation
Prerequisites
- Python 3.8 or higher
- Webcam for face capture
- GPS-enabled device (or browser location services)
Step 1: Clone Repository
git clone <repository-url>
cd smartAttandence
Step 2: Install Dependencies
Windows (Recommended Method)
# Install Visual C++ Build Tools first (required for dlib)
# Download from: https://visualstudio.microsoft.com/visual-cpp-build-tools/
# Create virtual environment
python -m venv venv
venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
Alternative: Use Pre-compiled Wheels
If you encounter issues installing face_recognition, use pre-compiled wheels:
pip install https://github.com/jloh02/dlib/releases/download/v19.22/dlib-19.22.99-cp38-cp38-win_amd64.whl
pip install face_recognition
Step 3: Initialize Database
python init_db.py
This creates:
- SQLite database with all tables
- Sample UTM classrooms (N28, V01, C22)
- Test student account
Step 4: Run Application
python app.py
The application will be available at: http://localhost:5000
π Usage Guide
For Students
Register Your Face
- Visit
/register - Enter Student ID and Name
- Capture your face using webcam
- System stores your biometric encoding
- Visit
Mark Attendance
- Visit
/student - Enter Student ID and select active session
- Enable camera and GPS permissions
- System verifies your face and location
- Enter attendance code displayed by lecturer
- Attendance marked instantly!
- Visit
For Lecturers
Create Session
- Visit
/lecturer - Enter course name and your name
- Select classroom location
- Click "Create Session"
- Visit
Display Code
- Large attendance code appears on screen
- Code auto-refreshes every 2 minutes
- Show this code to students in class
Monitor Attendance
- View real-time attendance list
- See verification details (distance, time)
- Export CSV report when done
ποΈ Project Structure
smartAttandence/
βββ app.py # Main Flask application
βββ config.py # Configuration settings
βββ models.py # Database models
βββ init_db.py # Database initialization
βββ requirements.txt # Python dependencies
β
βββ face_recognition_module.py # Face recognition logic (KR Rule #1)
βββ geolocation_module.py # GPS verification (KR Rule #2)
βββ attendance_code_module.py # Auto-refresh codes (KR Rule #5)
βββ utils.py # Helper functions
β
βββ static/
β βββ css/
β β βββ style.css # Premium design system
β βββ js/
β βββ student.js # Student portal logic
β βββ lecturer.js # Lecturer dashboard logic
β
βββ templates/
βββ index.html # Landing page
βββ student.html # Student portal
βββ lecturer.html # Lecturer dashboard
βββ register.html # Face registration
π§ Configuration
Edit config.py to customize:
# Face recognition settings
FACE_RECOGNITION_TOLERANCE = 0.6 # Lower = more strict (0.4-0.6 recommended)
# Geolocation settings
GEOLOCATION_RADIUS_METERS = 50 # Classroom detection radius
# Attendance code settings
CODE_REFRESH_INTERVAL_SECONDS = 120 # Code refresh interval (2 minutes)
CODE_LENGTH = 6 # Length of attendance code
π API Endpoints
Student Endpoints
POST /api/register_face- Register student face encodingPOST /api/verify_face- Verify face against stored encodingPOST /api/verify_location- Validate GPS locationPOST /api/mark_attendance- Mark attendance with code
Lecturer Endpoints
POST /api/create_session- Create attendance sessionGET /api/get_session/<id>- Get session details with current codeGET /api/get_attendance/<id>- Get attendance recordsPOST /api/end_session/<id>- End session
General Endpoints
GET /api/get_active_sessions- List all active sessionsGET /api/classrooms- Get all classrooms
π§ͺ Testing
Manual Testing Checklist
Face Recognition:
- Register new student face
- Verify with same person (should succeed)
- Verify with different person (should fail)
- Test with poor lighting
- Test with glasses/mask
Geolocation:
- Mark attendance from inside classroom (should succeed)
- Mark attendance from outside radius (should fail)
- Verify distance calculation accuracy
Auto-Refresh Codes:
- Code refreshes every 2 minutes
- Expired code rejected
- Valid code accepted
- Code sharing prevented
End-to-End Flow:
- Complete student registration
- Lecturer creates session
- Student marks attendance successfully
- Attendance appears in real-time
- Export CSV works
π Troubleshooting
Face Recognition Issues
Problem: dlib installation fails on Windows
Solution:
- Install Visual C++ Build Tools
- Or use pre-compiled wheel:
pip install dlib-19.22.99-cp38-cp38-win_amd64.whl
Problem: "No face detected" Solution:
- Ensure good lighting
- Face camera directly
- Remove glasses/mask if possible
- Move closer to camera
GPS Issues
Problem: Location permission denied Solution:
- Enable location services in browser settings
- Use HTTPS (required for geolocation API)
- Check device GPS is enabled
Problem: "Location unavailable" Solution:
- Ensure GPS is enabled on device
- Try outdoors for better signal
- Check browser location permissions
Code Validation Issues
Problem: "Code has expired" Solution:
- Enter code within 2-minute window
- Check lecturer's displayed code
- Ensure system clocks are synchronized
π Database Schema
Students Table
id- Primary keystudent_id- Unique student identifiername- Student nameemail- Email addressface_encoding- Biometric data (JSON)registered_at- Registration timestamp
Classrooms Table
id- Primary keyname- Classroom name (e.g., N28-01-01)building- Building namelatitude- GPS latitudelongitude- GPS longituderadius_meters- Geofencing radius
AttendanceSessions Table
id- Primary keycourse_name- Course namelecturer_name- Lecturer nameclassroom_id- Foreign key to Classroomscurrent_code- Active attendance codecode_generated_at- Code generation timeis_active- Session status
AttendanceRecords Table
id- Primary keysession_id- Foreign key to AttendanceSessionsstudent_id- Foreign key to Studentsmarked_at- Attendance timestampface_verified- Face verification statuslocation_verified- Location verification statuscode_verified- Code verification statusdistance_from_classroom- Distance in meters
π¨ Design Philosophy
Attendr features a premium dark mode design with:
- π Vibrant gradient accents
- β¨ Glassmorphism effects
- π Smooth micro-animations
- π± Fully responsive layout
- π― Modern typography (Inter + Outfit fonts)
π€ Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
π License
This project is licensed under the MIT License.
π₯ Authors
Developed for Universiti Teknologi Malaysia (UTM) as part of an AI Smart Attendance System project.
π Acknowledgments
- OpenCV - Computer vision library
- face_recognition - Face recognition library by Adam Geitgey
- Flask - Web framework
- UTM - Project inspiration and requirements
π Support
For issues or questions:
- Check the Troubleshooting section
- Review API documentation
- Open an issue on GitHub
Made with β€οΈ for UTM Students and Lecturers