Skip to content
 
 

Latest commit

 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PhotoGen

PhotoGen

Your passport photo, done right. For free.

AI-powered face detection, background removal, and auto-cropping
for 10+ countries. No signup. No watermarks. No data stored.


License: MIT Python Next.js FastAPI


Demo · Features · Getting Started · Supported Countries · Tech Stack · API · Deployment · License


Demo

photogen.mov

✨ Features

AI Processing

  • Face Detection via MediaPipe BlazeFace with Haar cascade fallback
  • Background Removal using BiRefNet-portrait + alpha matting
  • Auto-Crop to exact government specs (head %, eye position, dimensions)
  • Enhancement with white balance + adaptive CLAHE contrast

User Tools

  • Post-Processing sliders for brightness, contrast, saturation
  • Manual Crop with oval face template and alignment guides
  • Before / After side-by-side comparison slider
  • Print Sheet 4-up grid ready for photo center printing

Output Quality

  • 300 DPI publication-quality JPEG export
  • Compliance Validation for dimensions, head size, eye position, file size
  • 10+ Country Specs including US, EU, UK, Canada, Australia, India, China, Japan

Zero Friction

  • Wide Format Support for HEIC, AVIF, JPEG, PNG, WebP, BMP
  • 100% Free with no accounts or watermarks
  • Privacy First with no data stored on server

🔄 Processing Pipeline

graph LR
    A[📷 Upload] --> B[🎯 Face Detection]
    B --> C[✂️ Background Removal]
    C --> D[📐 Auto-Crop]
    D --> E[🎨 Enhancement]
    E --> F[💎 300 DPI Output]
Loading

🚀 Getting Started

Prerequisites

Requirement Version
Python 3.11+
Node.js 18+

Backend

cd backend
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000

The ML model (~170MB BiRefNet) downloads automatically on first request.

URL
API http://localhost:8000
Docs http://localhost:8000/docs

Frontend

cd frontend
npm install
npm run dev

Open http://localhost:3000


🌍 Supported Documents

Document Country Size Head Height Background
US Passport 🇺🇸 United States 2x2" (600x600px) 50-69% White
US Visa 🇺🇸 United States 2x2" (600x600px) 50-69% White
EU Passport 🇪🇺 EU / Schengen 35x45mm (413x531px) 70-80% Light Gray
UK Passport 🇬🇧 United Kingdom 35x45mm (413x531px) 70-80% Light Gray
Canada Passport 🇨🇦 Canada 35x45mm (420x540px) 71% White
Australia Passport 🇦🇺 Australia 35x45mm (413x531px) 75% White
India Passport 🇮🇳 India 35x45mm (413x531px) 75% White
China Visa 🇨🇳 China 33x48mm (390x567px) 70% White
Japan Passport 🇯🇵 Japan 35x45mm (413x531px) 70% White
Germany Passport 🇩🇪 Germany 35x45mm (413x531px) 75% Light Gray

🛠 Tech Stack

BackendFrontend
Library Purpose
FastAPI + Uvicorn API server
MediaPipe Face detection
OpenCV Haar cascade fallback
rembg (BiRefNet) Background removal
PyMatting Alpha matting
Pillow + pillow-heif Image I/O
scikit-image CLAHE enhancement
Library Purpose
Next.js 16 + React 19 App framework
TypeScript Type safety
Tailwind CSS 4 Styling
react-easy-crop Manual crop
Axios HTTP client

📡 API

Method Endpoint Description
POST /api/process Full processing pipeline
POST /api/detect-face Face detection only
POST /api/remove-background Background removal only
GET /api/requirements All country photo specs
GET /api/requirements/{code} Single country spec
GET /api/health Health check

📁 Project Structure

Click to expand
photogen/
├── backend/
│   ├── app/
│   │   ├── api/routes/
│   │   ├── core/
│   │   ├── services/
│   │   ├── models/
│   │   └── data/
│   ├── Dockerfile
│   └── requirements.txt
├── frontend/
│   ├── app/
│   └── src/
│       ├── components/
│       ├── hooks/
│       ├── lib/
│       └── constants/
└── shared/
    └── photo_requirements.json

🚢 Deployment

Service Platform Notes
Frontend Vercel Edge CDN, auto-deploy from main
Backend HuggingFace Spaces Docker, 16GB RAM, 2 vCPU

The backend Dockerfile is configured for HuggingFace Spaces with pre-downloaded models.


📄 License

MIT

Back to Top

About

Free, open-source passport photo maker powered by AI

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages