Case index
Case File 001Favorite ProjectPersonal ProjectStatus: Closed2024

GrabPic — Asynchronous AI Facial Recognition & Photo Tagging

An asynchronous ML pipeline using FastAPI, DeepFace, & DBSCAN clustering for batch event photo tagging and instant selfie matching.

Latency fix
< 10s async

Decoupled photo extraction from HTTP request threads.

Clustering
DBSCAN

Unsupervised face grouping via cosine distance.

Matching engine
UUID Token

High-speed selfie embedding lookup against PostgreSQL.

Opening brief

Processing high-resolution event photo uploads synchronously timed out serverless gateway limits (10s limit), and event attendees lacked an automated way to retrieve their unlabelled photos.

Outcome on record

Bypassed HTTP timeouts using FastAPI BackgroundTasks, clustered unlabelled facial embeddings via DBSCAN on cosine distance, and enabled instant selfie-matching via PostgreSQL cluster embeddings and UUID share tokens.

Exhibit A

Project description

Filed statement

GrabPic processes high-resolution event photo uploads asynchronously using FastAPI BackgroundTasks, preventing gateway timeouts on batch workloads.

Utilizes DeepFace for facial embedding extraction and DBSCAN clustering on cosine distance metrics to group face embeddings into distinct unlabelled attendee personas without pre-trained classes.

Includes OpenCV image preprocessing for EXIF orientation and small face upscaling, plus instant selfie matching with UUID share tokens against averaged cluster vectors in PostgreSQL.

Exhibit B

Why I built this

Filed statement

Event photographers and attendees needed a fast, automated way to group photos by face without manual tagging or rigid pre-trained classifiers.

Architected to demonstrate how async ML queues can handle heavy computer vision workloads on serverless/containerized environments.

Exhibit C

Process and execution

Approach

How the work moved

  • Architected an asynchronous background ML pipeline using FastAPI BackgroundTasks to process batches of high-resolution event photos without blocking HTTP threads, bypassing 10-second serverless gateway limits.
  • Implemented face detection and embedding extraction using the DeepFace framework, utilizing DBSCAN clustering on cosine distance metrics to group face embeddings into distinct personas without pre-trained classes.
  • Built robust preprocessing utilities in OpenCV (cv2) to fix image orientation using EXIF data and dynamically upscaled small/distant face crops to improve detection rate accuracy.
  • Developed a high-speed selfie matching endpoint that extracts a selfie's facial embedding, computes its cosine similarity against averaged cluster embeddings stored in PostgreSQL, and redirects users using a secure UUID-based share token.
Responsibilities

What I owned

  • Led the work as ML & Backend Architect.
  • Turned messy context into a clearer operating model, interaction direction, and rollout shape.
  • Worked across stakeholders to move the project from framing into execution.
Exhibit D

Notable decisions

Decision

Unsupervised DBSCAN clustering

Clustered facial embeddings into attendee groups dynamically without pre-trained classes, enabling flexible photo retrieval across arbitrary events.

Decision

Async ML background task pipeline

Decoupled heavy DeepFace extraction from request threads, preventing gateway timeouts on batch photo uploads.

Decision

EXIF & landmark preprocessing

Corrected image orientation and upscaled distant face crops before running embeddings to significantly boost facial detection rates.

Exhibit E

What I learned from this

Filed statement

Unsupervised DBSCAN clustering on cosine distance outperforms supervised classification when grouping unlabelled face embeddings.

EXIF orientation normalization and facial crop upscaling are critical prior to facial landmark detection.