Skip to content
Haroon966Public

About

Face detection & recognition API: count heads, crop faces, enroll people (ArcFace), recognize names, and log attendance. FastAPI + simple UI.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Whozit

Standalone face attendance: enroll students by name, scan a class photo, save the daily register — no external app required.

HTTP API + teacher UI + dashboard. Own SCRFD + ArcFace under whozit/ (adapted from UniFace, MIT).

Architecture: docs/architecture.html · full proposal: docs/proposal-by-shoaib.md

Website: https://haroon966.github.io/Whozit/ (GitHub Pages from /docs).

Self-host vs hosted mode: everything below is self-host — one deployment, one tenant. Hosted mode (ADR 0001) adds Programme-scoped multi-tenancy on the same API; see CONTEXT.md for vocabulary and docs/adr/0001-programme-tenant-and-generic-org-tree.md for the design. GET /org/countries etc. below is the older, self-host-only fixed country/province/school/class hierarchy — hosted mode's org-nodes tree (table further down) is a separate, unrelated concept despite the similar name.

Surface Purpose
POST /detect Stateless face count + crops
POST /enroll (scope_key or country+province+emis+grade, name, image) → stable student_id
GET /students/{id} Other apps: name, school, class, face sample count
GET /org/countries Self-host fixed org hierarchy, for pickers
POST /recognize Match faces in one scope; returns name, score, margin, candidates
GET /refs Roster for a scope
POST/GET /attendance/day Daily present + on-leave lists
GET /attendance/day/status Counts + present / absent / leave for a date
POST /admin/reembed Re-embed all stored crops after model bump
POST /admin/wipe Wipe all program data (confirm body)
GET /internal/rec_log Support/debug recognition log
PATCH /refs/{ref_id} Rename without new photo

Hosted mode adds (org_node_id replaces scope_key on /enroll, /recognize, /refs, /refs/{id}/crop, /attendance/day* for hosted-mode callers — self-host is unaffected):

Surface Purpose
POST /programmes/register Self-service; creates a pending programme, no key needed
POST /admin/programmes/{id}/approve platform_admin only; activates, mints the first key
POST /org-nodes Create a child node under the caller's own subtree
GET /org-nodes/{id}/children | /ancestry Read the caller's own subtree
POST /keys Self-service: mint a key scoped to your own subtree or narrower
GET /attendance/day/rollup?org_node_id= Recursive attendance rollup across a subtree, any depth

Migrate v3 DB:

python -m app.migrate_v3 --source data/whozit_v3.db --dest data/whozit.db
# or set WHOZIT_MIGRATE_V3_PATH on first startup

Map existing roll-* refs into org rows + stable IDs (pk+province+emis+seq):

python -m app.migrate_org --db data/whozit.db

Docker + Litestream:

docker compose up --build

Teacher UI: http://localhost:8088/teacher
Dashboard: http://localhost:8088/dashboard
Integration guide: http://localhost:8088/guide


Identity contract

  • scope_key — opaque class path, e.g. pk/punjab/rawalpindi/sch-10482/sec-5a
  • ref_id — unique identity key (caller-supplied or minted UUID). Names are not unique — two "Ayesha"s are two ref_ids.
  • Enrolment crops retained indefinitely by default (encrypted at rest with WHOZIT_CROP_KEY). See consent wording in your deployment policy.
  • Threshold WHOZIT_MATCH_THRESH defaults to 0.35. On Class 5a demo scans, true matches scored about 0.37–0.68. Keep 0.35 unless you see false presents (raise toward 0.40) or missed faces (lower slightly). Always verify on your classroom photos.

Setup

cd Whozit

python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# optional: cp .env.example .env

First run downloads SCRFD + ArcFace weights into ~/.whozit/models. Runtime data (not in git):

  • data/whozit.db — refs, samples, daily register, internal rec_log

Run

source .venv/bin/activate
uvicorn app.main:app --host 0.0.0.0 --port 8088

Auth

Set WHOZIT_API_KEY. Browser UI calls POST /session with the key once to get an httpOnly cookie — the key never ships in page JS.

Docker (CPU)

docker build -t whozit .
docker run --rm -p 8088:8088 \
  -v whozit-data:/data \
  -v whozit-models:/models \
  -e WHOZIT_SQLITE_PATH=/data/whozit.db \
  -e WHOZIT_CROP_KEY=change-me-in-production \
  -e WHOZIT_CACHE_DIR=/models \
  whozit

Optional SQLite replication: docs/litestream.md

Tests

pip install pytest httpx cryptography
python -m pytest tests/ -q

Example

# Enrol (ref_id optional — minted if omitted)
curl -s -X POST http://localhost:8088/enroll \
  -F scope_key=pk/demo/class-5a \
  -F name="Ali Khan" \
  -F [email protected] | jq .

# Recognize
curl -s -X POST http://localhost:8088/recognize \
  -F scope_key=pk/demo/class-5a \
  -F [email protected] | jq '.faces[] | {name, ref_id, score, margin, matched}'

# Save daily roll (present + optional on-leave)
curl -s -X POST http://localhost:8088/attendance/day \
  -H 'Content-Type: application/json' \
  -d '{"scope_key":"pk/demo/class-5a","date":"2026-08-18","present_ref_ids":["<ref_id>"],"leave_ref_ids":[]}' | jq .

Students still missing a face photo (no Slack image) can be filled later:

# List who needs a photo
python scripts/enroll_missing.py --list --base http://localhost:8088

# Drop JPEGs named like fakhar_abbas.jpg into a folder, then:
python scripts/enroll_missing.py --dir ./photos --base http://localhost:8088

Layout

Whozit/
├── app/
│   ├── main.py          # FastAPI routes
│   ├── org_store.py     # Country / school / class / stable student_id
│   ├── ref_store.py     # SQLite refs / samples / register
│   ├── recognizer.py    # Match + greedy assignment
│   ├── crop_crypto.py   # Encrypted enrolment crops
│   └── db.py            # Schema
├── whozit/              # SCRFD + ArcFace library
├── static/              # Teacher + dashboard + guide UI
├── docs/
│   ├── architecture.html
│   ├── integrate.html   # Public integration guide (GitHub Pages)
│   └── litestream.md
└── tests/

Product requirements: PRD.md

About

Face detection & recognition API: count heads, crop faces, enroll people (ArcFace), recognize names, and log attendance. FastAPI + simple UI.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages