A face-similarity search service using embeddings, with a Python/SQLAlchemy/PostgreSQL + pgvector backend and a Next.js frontend.
- Description
- Prerequisites
- Installation
- Database Configuration
- Alembic Migrations
- Quick Reset
- Running the Backend
- Running the Auth DB (Docker)
- Prisma Setup (Next.js)
- Running the Frontend
- Environment Files
- Contributing
- Extract face embeddings from images
- Store them in PostgreSQL with the pgvector extension
- Perform ANN searches via SQL
- Provide a simple Next.js UI for upload and search
- Linux/macOS/Windows WSL
- Git
- Python 3.8+
- Node.js 16+ and npm/yarn
- Docker (for the NextAuth DB)
- PostgreSQL 14+ (backend Python)
pgvectorPostgreSQL extension
-
Clone the repo
git clone https://github.com/your-username/FindMyPix.git cd FindMyPix -
Backend (Python)
cd python-backend python3 -m venv .venv source .venv/bin/activate pip install --upgrade pip pip install -r requirements.txt
You will also need to install PyTorch, you can find the install command on their site. Make sure that you donwload the proper version that match your cuda toolkit version ;)
-
Install PostgreSQL & pgvector
sudo apt update sudo apt install -y postgresql postgresql-contrib build-essential git clone https://github.com/pgvector/pgvector.git cd pgvector && make && sudo make install && cd ..
-
Create role, database & extension line by line
sudo -u postgres psql
In the
psqlprompt:CREATE ROLE face_user WITH LOGIN PASSWORD 'your_password'; CREATE DATABASE face_db OWNER face_user; \c face_db CREATE EXTENSION IF NOT EXISTS vector; \q
-
Export the connection URL
Before running the application, you'll need to set up your environment variables. Create a
.env.localfile in the root directory and populate it with your configuration. You can use the provided.env.local.examplefile as a reference for the required variables.
-
Initialize (if needed)
alembic init migrations
-
In
migrations/env.py, point to yourBase:from your_module import Base target_metadata = Base.metadata
-
Generate & apply
alembic revision --autogenerate -m "create faces schema" alembic upgrade head
# Option A: drop & recreate
dropdb face_db
createdb face_db
psql -d face_db -c "CREATE EXTENSION IF NOT EXISTS vector;"
alembic upgrade head
# Option B: alembic downgrade & upgrade
alembic downgrade base
alembic upgrade headcd python-backend
source .venv/bin/activate
uvicorn app.main:app \
--reload \
--host 0.0.0.0 \
--port 8000NextAuth needs its own PostgreSQL. Launch it with Docker:
docker compose up -d-
In the Next.js folder:
cd event-photo-finder npm install prisma @prisma/client -
Initialize Prisma (if not already done):
npx prisma init
-
Make sure your existing
prisma/schema.prismadefines the required models for NextAuth (e.g. User, Account, Session, VerificationToken). -
Run migration & generate the client:
npx prisma migrate dev --name init npx prisma generate
-
Setup environement On the frontend there is also 2 env files that you need to have. the .env and .env.local, there are respectievely .{env}.example and .{env}.local.example that are starting point for you.
docker compose up -d
cd event-photo-finder
npm install # or yarn
npm run devHigh priority
- Create the procesing queue also in the backend so that reloading the page does not make you lose the whole state. store in cookies and give additional data fetch via polling
- Add optimization features to support large galleries
Mid priority
- Bulk-folder upload support
- Multi-image search / Video from our face from left to right
- If input image as multiple detected visage prompt to choose a specific one
Low priority
- Better delete confirmation on manage page
- More upload status info (pending, progress bar, face count…)
- Draw bounding boxes around detected faces
