--- license: mit tags: - pytorch - onnx - flow-matching - generative-art - face-generation pipeline_tag: image-to-image --- # 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](https://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 ```text . ├── 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 ```bash python run.py ``` ### 2. ONNX Runtime Demo ```bash python run_onnx.py ``` Once running, access `http://localhost:8000/` in a web browser or run: ```bash 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 1. **Scrape Training Dataset:** ```bash python scrape.py ``` 2. **Train Model:** ```bash python train.py ```