Spaces:
Runtime error
Download README.md from MusinguziBenard/face-recognition-api: direct link, hf CLI and curl.
- Browser
- Download file 2.67 kB
-
https://huggingface.co/spaces/MusinguziBenard/face-recognition-api/resolve/main/README.md
- Command line
-
hf download hf://spaces/MusinguziBenard/face-recognition-api/README.md
-
curl -L -o README.md https://huggingface.co/spaces/MusinguziBenard/face-recognition-api/resolve/main/README.md
A newer version of the Gradio SDK is available: 6.30.0
title: Face Recognition API
emoji: π§
colorFrom: yellow
colorTo: blue
sdk: gradio
app_file: app.py
pinned: false
Face Recognition API
InsightFace buffalo_l face recognition service for SchoolMaster attendance.
Stateless β it only extracts/compares face embeddings. All student data
(including embeddings) lives in your MySQL database, not on this Space.
Visiting the Space shows a small status page (Gradio) β that's just a
health-check UI. Your PHP backend talks directly to the /api/* endpoints
below, not to that page.
Required setup: add your API key as a Secret
Do not put your API key in this README or in any committed file.
- On this Space, go to Settings β Repository secrets (or Variables and secrets, depending on your account).
- Add a secret named
API_KEYwith your real key as the value β the same value your PHP.envuses to call this service. - Restart the Space.
config.py reads it via os.environ β it is never written into the repo.
Endpoints (same contract as your local version β no PHP changes needed)
| Endpoint | Method | Description |
|---|---|---|
/api/health |
GET | Health check |
/api/extract |
POST | Extract embedding from 1+ photos (multipart files) |
/api/enroll |
POST | Extract + average embedding from 3-10 photos (multipart files) |
/api/recognize |
POST | Match one photo against embeddings you pass in |
All POST endpoints require an X-API-Key header matching your API_KEY
secret, and accept multipart/form-data file uploads β identical to your
local FastAPI service, so your existing PHP integration works unchanged
(just point it at this Space's URL instead of 127.0.0.1:8000).
What was actually wrong before
The previous version tried to run a second uvicorn server in a background
thread on the same port Gradio also wanted to use, and never blocked the
main thread β so the process exited right after a successful model load,
crash-looping the Space. This version runs everything (the API routes and
a small Gradio status page) as one process on one port, which is what
Spaces actually needs.
A tradeoff to know about before relying on this for production
Free-tier Spaces:
- Sleep after inactivity. The first request after a sleep can take 1-2 minutes while the container restarts and re-downloads the model.
- CPU-only, similar to or slower than a typical laptop β this may not
fix the "too slow" complaint that prompted looking at this in the first
place. Worth timing actual
/api/recognizecalls here vs. your local setup before switching your kiosk over to it.