CoolFace
Apppublic

noninjaml/lume-ai

sourceHugging Faceupdated 6mo agoView on Hugging Face
0likes
App README

Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference

Architecture

The service now runs in two modes from the same image:

  • —SERVICE_MODE=api: FastAPI app that enqueues indexing work and serves match-face
  • —SERVICE_MODE=worker: background worker that claims photo batches from Postgres and indexes them

Queue state lives in the photo_index_tasks table. The SQL setup is in `sql/queue_schema.sql`.

Environment

Create your own API key for this service. It is not provided by Supabase or this repo.

Generate one locally:

bash
python3 -c "import secrets; print(secrets.token_urlsafe(32))"

Copy the example env file and fill it in:

bash
cp .env.example .env
  • —SUPABASE_URL: your Supabase project URL
  • —SUPABASE_SERVICE_KEY: service role key used by this backend
  • —SERVICE_MODE: api or worker
  • —LUME_API_KEY: shared secret required by the protected API routes
  • —FACE_MATCH_THRESHOLD: optional cosine similarity threshold, defaults to 0.6
  • —INDEX_BATCH_SIZE: number of photos a worker claims at once, defaults to 20
  • —TASK_LEASE_SECONDS: worker lease timeout for claimed tasks, defaults to 1800
  • —WORKER_POLL_INTERVAL: idle sleep between worker polls, defaults to 2
  • —WORKER_MAX_ATTEMPTS: retry limit before a task is marked failed, defaults to 3

Queue Setup

Apply `sql/queue_schema.sql` to your Supabase Postgres database before starting workers. It creates:

  • —photo_index_tasks
  • —claim_photo_index_tasks(...)

Running

API mode:

bash
SERVICE_MODE=api sh start.sh

Worker mode:

bash
SERVICE_MODE=worker sh start.sh

Scale indexing by running multiple worker containers with SERVICE_MODE=worker.

Calling The API

Queue a moment for indexing:

bash
curl -X POST http://localhost:7860/moments/abc123/index \
  -H "x-api-key: your-generated-secret"

Check indexing status:

bash
curl http://localhost:7860/moments/abc123/index-status \
  -H "x-api-key: your-generated-secret"

Legacy clients can still call:

bash
curl -X POST http://localhost:7860/process-moment \
  -H "Content-Type: application/json" \
  -H "x-api-key: your-generated-secret" \
  -d '{"moment_id":"abc123"}'

For Hugging Face Spaces, store SUPABASE_URL, SUPABASE_SERVICE_KEY, and LUME_API_KEY in Space Secrets.