Alosha Painter
Alosha Painter is a generative computer vision model designed to draw and generate human faces using a custom Flow Matching UNet (FlowMatchingUNet). The model was trained on synthetic facial datasets collected by scraping ThisPersonDoesNotExist.com.
This repository contains the full model definition, training scripts, PyTorch EMA checkpoints, optimized ONNX exports (FP32, FP16, and INT8), and a local FastAPI demo server for quick image generation testing.
Repository Structure
.
βββ run.py # FastAPI demo server (PyTorch runtime)
βββ run_onnx.py # FastAPI demo server (ONNX Runtime)
βββ scrape.py # Data collection script for ThisPersonDoesNotExist
βββ train.py # FlowMatchingUNet architecture & training pipeline
βββ data/
β βββ faces/ # Scraped training dataset
βββ weights/
βββ checkpoint_latest.pth # PyTorch EMA model checkpoint
βββ unface.onnx # Standard FP32 ONNX export
βββ unface_fp16.onnx # FP16 precision ONNX model (GPU)
βββ unface_int8.onnx # Quantized INT8 ONNX model (CPU)
Running the Demo Server
A lightweight FastAPI server is provided in run.py and run_onnx.py as a demo to test generation outputs via HTTP GET requests.
1. PyTorch Runtime Demo
python run.py
2. ONNX Runtime Demo
python run_onnx.py
Once running, access http://localhost:8000/ in a web browser or run:
curl http://localhost:8000/ --output generated_face.png
Each request runs the flow-matching ODE sampler (steps=20), applies 2x bicubic upsampling, and returns a PNG image.
Technical Details
- Architecture: Custom Flow Matching UNet (
FlowMatchingUNet) - Sampling: ODE vector-field integration
- Checkpointing: Exponential Moving Average (EMA) weights (
ckpt["ema"]) - ONNX Exports: Pre-compiled FP32, FP16, and INT8 quantized binaries for fast CPU/GPU deployment without PyTorch overhead.
Dataset & Training
- Scrape Training Dataset:
python scrape.py - Train Model:
python train.py