afghan50002 commited on
Commit
fa3fdf1
·
verified ·
1 Parent(s): c31bcfd

Upload 8 files

Browse files
Files changed (8) hide show
  1. .env +39 -0
  2. .env.example +36 -0
  3. .gitignore +66 -0
  4. Dockerfile +44 -0
  5. README.md +31 -11
  6. render.yaml +31 -0
  7. requirements.txt +17 -0
  8. run.py +34 -0
.env ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ==================================================
2
+ # 🔧 FLASK CONFIGURATION
3
+ # ==================================================
4
+ FLASK_SECRET_KEY=super_secure_authentic_key_2026
5
+ FLASK_DEBUG=True
6
+
7
+ # ==================================================
8
+ # 💾 DATABASE CONFIGURATION (Local MariaDB)
9
+ # ==================================================
10
+ DB_HOST=localhost
11
+ DB_PORT=3306
12
+ DB_USER=root
13
+ DB_PASS=
14
+ DB_NAME=face_attendance_db
15
+
16
+ # ==================================================
17
+ # 🔑 ADMIN CREDENTIALS
18
+ # ==================================================
19
+ ADMIN_USER=admin
20
+ ADMIN_PASS=admin1122
21
+
22
+ # ==================================================
23
+ # 📧 EMAIL CONFIGURATION (Gmail SMTP)
24
+ # ==================================================
25
+ # To use Gmail:
26
+ # 1. Enable 2-Factor Authentication on your Google Account
27
+ # 2. Go to https://myaccount.google.com/apppasswords
28
+ # 3. Generate an "App Password" for "Mail"
29
+ # 4. Paste it below (no spaces)
30
+ MAIL_SERVER=smtp.gmail.com
31
+ MAIL_PORT=587
32
+ MAIL_USE_TLS=True
33
+ MAIL_USERNAME=kabeer50002@gmail.com
34
+ MAIL_PASSWORD=umky ybhg bzyq welz
35
+ MAIL_DEFAULT_SENDER=kabeer50002@gmail
36
+ # ==================================================
37
+ # 🌍 TIMEZONE (PKT = UTC+5)
38
+ # ==================================================
39
+ TIMEZONE_OFFSET=5
.env.example ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ==================================================
2
+ # 🔧 FLASK CONFIGURATION
3
+ # ==================================================
4
+ FLASK_SECRET_KEY=super_secure_authentic_key_2026
5
+ FLASK_DEBUG=True
6
+
7
+ # ==================================================
8
+ # 💾 DATABASE CONFIGURATION (TiDB Cloud)
9
+ # ==================================================
10
+ DB_HOST=gateway01.ap-southeast-1.prod.aws.tidbcloud.com
11
+ DB_PORT=4000
12
+ DB_USER=3WzY1RDss8u68mi.root
13
+ DB_PASS=lto0KuAikAJZ0AWy
14
+ DB_NAME=face_attendance_db
15
+ DB_SSL_CA=<CA_PATH>
16
+
17
+ # ==================================================
18
+ # 🔑 ADMIN CREDENTIALS
19
+ # ==================================================
20
+ ADMIN_USER=admin
21
+ ADMIN_PASS=admin123
22
+
23
+ # ==================================================
24
+ # 📧 EMAIL CONFIGURATION (Gmail SMTP)
25
+ # ==================================================
26
+ # To use Gmail:
27
+ # 1. Enable 2-Factor Authentication on your Google Account
28
+ # 2. Go to https://myaccount.google.com/apppasswords
29
+ # 3. Generate an "App Password" for "Mail"
30
+ # 4. Paste it below (no spaces)
31
+ MAIL_SERVER=smtp.gmail.com
32
+ MAIL_PORT=587
33
+ MAIL_USE_TLS=True
34
+ MAIL_USERNAME=your_email@gmail.com
35
+ MAIL_PASSWORD=your_app_password_here
36
+ MAIL_DEFAULT_SENDER=your_email@gmail.com
.gitignore ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ==================================================
2
+ # 🔒 SECRETS — NEVER PUSH THESE
3
+ # ==================================================
4
+ .env
5
+
6
+ # ==================================================
7
+ # 🐍 PYTHON
8
+ # ==================================================
9
+ venv/
10
+ .venv/
11
+ env/
12
+ __pycache__/
13
+ *.pyc
14
+ *.pyo
15
+ *.egg-info/
16
+ dist/
17
+ build/
18
+ *.egg
19
+
20
+ # ==================================================
21
+ # 💻 IDE / EDITOR
22
+ # ==================================================
23
+ .vscode/
24
+ .idea/
25
+ *.swp
26
+ *.swo
27
+ *.sublime-project
28
+ *.sublime-workspace
29
+ .project
30
+ .pydevproject
31
+ .code-workspace
32
+
33
+ # ==================================================
34
+ # 🖥️ OS FILES
35
+ # ==================================================
36
+ .DS_Store
37
+ Thumbs.db
38
+ desktop.ini
39
+ ehthumbs.db
40
+
41
+ # ==================================================
42
+ # 📦 JUNK / TEMP FILES
43
+ # ==================================================
44
+ # Archives that don't belong in the repo
45
+ *.rar
46
+ *.zip
47
+
48
+ # Large text dumps
49
+ face_attendance_web/project.txt
50
+ face_attendance_web/highlight_project.txt
51
+
52
+ # Junk files accidentally placed in templates/
53
+ face_attendance_web/templates/merge_sort.py
54
+ face_attendance_web/templates/new.zip.rar
55
+ face_attendance_web/templates/new.zip.txt
56
+
57
+ # ==================================================
58
+ # 📝 LOGS
59
+ # ==================================================
60
+ *.log
61
+ face_attendance_web/logs/
62
+
63
+ # ==================================================
64
+ # 🤖 CODE REVIEW GRAPH
65
+ # ==================================================
66
+ .code-review-graph/
Dockerfile ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ # Install system dependencies for dlib/face_recognition
4
+ # Install system dependencies for dlib/face_recognition
5
+ # Install system dependencies for dlib/face_recognition
6
+ RUN apt-get update && apt-get install -y --no-install-recommends \
7
+ cmake \
8
+ build-essential \
9
+ libopenblas-dev \
10
+ liblapack-dev \
11
+ libx11-dev \
12
+ libglib2.0-0 \
13
+ libgl1 \
14
+ git \
15
+ && rm -rf /var/lib/apt/lists/*
16
+ WORKDIR /app
17
+
18
+ # Speed up dlib C++ compilation with parallel build
19
+ ENV CMAKE_BUILD_PARALLEL_LEVEL=4
20
+
21
+ # Install dlib FIRST as separate layer (longest step, gets cached)
22
+ RUN pip install --no-cache-dir dlib==20.0.1
23
+
24
+ # Install face_recognition_models from GitHub (avoids pkg_resources issue)
25
+ RUN pip install --no-cache-dir git+https://github.com/ageitgey/face_recognition_models
26
+
27
+ # Install remaining Python dependencies
28
+ COPY requirements.txt .
29
+ RUN pip install --no-cache-dir -r requirements.txt
30
+
31
+ # Copy application code
32
+ COPY . .
33
+
34
+ # Set working directory to the Flask app
35
+ WORKDIR /app/face_attendance_web
36
+
37
+ # Create faces and logs directories
38
+ RUN mkdir -p faces logs
39
+
40
+ # Hugging Face Spaces uses port 7860
41
+ EXPOSE 7860
42
+
43
+ # Run with gunicorn on port 7860
44
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--timeout", "120", "app:app"]
README.md CHANGED
@@ -1,11 +1,31 @@
1
- ---
2
- title: Alam
3
- emoji: 📚
4
- colorFrom: indigo
5
- colorTo: indigo
6
- sdk: static
7
- pinned: false
8
- short_description: khan
9
- ---
10
-
11
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Face Attendance System
3
+ emoji: 🎓
4
+ colorFrom: green
5
+ colorTo: blue
6
+ sdk: docker
7
+ app_port: 7860
8
+ pinned: false
9
+ ---
10
+
11
+ # 🎓 Face Attendance System — Khushal Degree College
12
+
13
+ A Flask-based web application for automated face-recognition attendance.
14
+
15
+ ## Features
16
+ - 🤖 Real-time Face Recognition Attendance
17
+ - 📸 3-Angle Student Registration (Front, Left, Right)
18
+ - 👨‍🏫 Multi-Role System (Admin, Professor, Student)
19
+ - 📊 Analytics Dashboard with attendance stats
20
+ - 📧 Email Notifications via Gmail SMTP
21
+ - 📝 Leave Management System
22
+ - ⏰ Auto-Absent Scheduler
23
+
24
+ ## Tech Stack
25
+ - **Backend:** Flask + Python
26
+ - **Face Recognition:** dlib + face_recognition + OpenCV
27
+ - **Database:** MySQL (TiDB Serverless)
28
+ - **Email:** Gmail SMTP
29
+
30
+ ## Default Login
31
+ - **Admin:** `admin` / `admin123`
render.yaml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Render.com deployment configuration
2
+ # https://render.com/docs/yaml-spec
3
+
4
+ services:
5
+ - type: web
6
+ name: face-attendance-system
7
+ runtime: docker
8
+ plan: free
9
+ envVars:
10
+ - key: FLASK_SECRET_KEY
11
+ generateValue: true
12
+ - key: FLASK_DEBUG
13
+ value: "False"
14
+ - key: DB_HOST
15
+ sync: false # Set manually in Render dashboard
16
+ - key: DB_USER
17
+ sync: false
18
+ - key: DB_PASS
19
+ sync: false
20
+ - key: DB_NAME
21
+ value: face_attendance_db
22
+ - key: MAIL_SERVER
23
+ value: smtp.gmail.com
24
+ - key: MAIL_PORT
25
+ value: "587"
26
+ - key: MAIL_USE_TLS
27
+ value: "True"
28
+ - key: MAIL_USERNAME
29
+ sync: false
30
+ - key: MAIL_PASSWORD
31
+ sync: false
requirements.txt ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Flask==3.1.3
2
+ mysql-connector-python==9.7.0
3
+ numpy==2.4.4
4
+ opencv-python-headless==4.13.0.92
5
+ Werkzeug==3.1.8
6
+ Flask-Mail==0.10.0
7
+ APScheduler==3.11.2
8
+ python-dotenv==1.2.2
9
+ Pillow==12.2.0
10
+ setuptools<81
11
+ scipy
12
+ ultralytics
13
+ torch
14
+ onnxruntime
15
+ onnx
16
+ insightface
17
+ gunicorn
run.py ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ Face Attendance System - Startup Script
3
+ ========================================
4
+ Run this from the project root to start the Flask app.
5
+
6
+ Usage:
7
+ python run.py
8
+ """
9
+ import os
10
+ import sys
11
+
12
+ # Fix Windows console encoding for emoji characters
13
+ if sys.stdout and hasattr(sys.stdout, 'reconfigure'):
14
+ try:
15
+ sys.stdout.reconfigure(encoding='utf-8', errors='replace')
16
+ sys.stderr.reconfigure(encoding='utf-8', errors='replace')
17
+ except Exception:
18
+ pass
19
+
20
+ # Set the working directory to face_attendance_web BEFORE importing app
21
+ app_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'face_attendance_web')
22
+ os.chdir(app_dir)
23
+ sys.path.insert(0, app_dir)
24
+
25
+ from app import app # type: ignore[import-not-found] # noqa: E402 — path set dynamically above
26
+
27
+ if __name__ == '__main__':
28
+ # Use use_reloader=False to avoid the cwd/reloader conflict on Windows
29
+ app.run(
30
+ host='0.0.0.0',
31
+ port=int(os.environ.get('PORT', 5000)),
32
+ debug=os.environ.get('FLASK_DEBUG', 'True').lower() == 'true',
33
+ use_reloader=False
34
+ )