Real-time attention monitoring system that uses multiple AI models to detect and analyze student behavior in classroom settings.
- Quick Start
- Development Setup
- Features
- Models
- API Endpoints
- Project Structure
- Running Tests
- Linting & Formatting
Important
The backend must be running before you start the frontend.
# Terminal 1 — backend
uv sync && uv run server.py
# Terminal 2 — frontend
cd frontend && pnpm run build && pnpm run startThen open http://localhost:3000 — sign up with a STU-XXXXXX or TCH-XXXXXX ID.
uv is a modern Python package manager used instead of pip.
macOS / Linux:
curl -LsSf https://astral.sh/uv/install.sh | shWindows (PowerShell):
irm https://astral.sh/uv/install.ps1 | iexuv synccp .env.example .env
# Edit .env with your settingsDatabase options:
- SQLite (default): No configuration needed, creates
app.dbautomatically. - PostgreSQL: Set
DATABASE_TYPE=postgresqlandDATABASE_URLin.env.
uv run server.pyBackend starts on http://localhost:5000. On first run it creates app/app.db and all tables automatically.
cd frontend
pnpm install # only needed once
pnpm run build
pnpm run startFrontend starts on http://localhost:3000.
Use
pnpm run devinstead ofbuild+startfor hot-reload during development.
| Feature | Description | Status |
|---|---|---|
| Gaze Estimation | Tracks eye direction using Gaze360 LSTM model to detect when students look away | ✅ Implemented |
| Phone Detection | Detects mobile phone usage via YOLOv11 object detection | ✅ Implemented |
| Facial Landmarks | 68-point facial landmark detection using STAR Loss model | ✅ Implemented |
| Activity Recognition | Classifies 10 classroom activities using SE-ResNet (95% accuracy) | ✅ Implemented |
| Session Reports | Auto-generates PDF reports with stats, event breakdown, and event log | ✅ Implemented |
| Email Reports | Sends session PDF reports via email (SMTP) | ✅ Implemented |
| Multi-Student Tracking | Tracks multiple students with persistent IDs using YOLO + ByteTrack | 🧪 Prototype |
| Real-Time Alerts | Sends alerts via Telegram, Discord, and Email on distraction events | ✅ Implemented |
| Model | File | Purpose |
|---|---|---|
| Gaze360 (L2CS) | models/gaze360_model.pth.tar |
Gaze direction estimation |
| STAR Loss | models/star_loss.pth |
68-point facial landmarks |
| YOLOv11s | models/yolo11s.pt |
Phone detection + person tracking |
| ResEmoteNet | models/activity_model.pth |
10-class activity recognition |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/health |
Server health + loaded models |
POST |
/api/predict?model=l2cs |
Gaze estimation |
POST |
/api/predict?model=star |
Facial landmarks |
POST |
/api/predict?model=yolo |
Phone detection |
POST |
/api/predict?model=activity |
Activity recognition |
POST |
/api/session/end |
End session + generate PDF report |
GET |
/api/session/<id>/report |
Download session PDF |
app/
├── api/ # Flask routes + API gateway
├── events/ # Observer pattern (Subject/Observer)
├── models/ # SQLAlchemy DB models (Session, Event)
├── services/
│ ├── inference.py # Model loading + prediction
│ ├── monitor.py # Attention analysis + alerting
│ ├── tracker.py # Multi-student tracking (ByteTrack)
│ ├── report.py # PDF report generation + email
│ ├── store.py # Database event logging
│ └── notification.py
│ └── notifications/connectors.py # Email, Discord, Telegram
├── utils/ # Constants, logger, decorators
├── model.py # PyTorch model architectures
└── config.py # App configuration
bin/ # Test scripts
models/ # Trained model weights
notebook/ # Training notebooks (Colab)
reports/ # Generated PDF reports
uv run python bin/test_api.py # API gateway test
uv run python bin/test_report.py # PDF report generation
uv run python bin/test_tracker.py # Multi-student tracking (webcam)
uv run python bin/test_activity.py # Activity recognition (webcam)uv run ruff check . # Lint
uv run ruff format . # Format (Black-compatible)