A 64×64 anime-face generator conditioned on a face layout (face, eyes and mouth masks). A flow-matching U-Net was distilled into a two-jump flow map: one image costs two network evaluations, about 30–70 ms on a laptop CPU. It is shipped as ONNX in two forms: fp32, and int8 with the convolutions quantized.
Code, training recipe and write-ups: nikhilr612/tinyflow.
Eight samples picked by eye from 60 random draws; fp32 and int8 use the same noise and layout.
demo.py is a marimo notebook that downloads this repository's files and times the sampler live: one face with layout sliders, a rotating layout at fixed noise, 64 faces, and an int8-against-fp32 benchmark. Its only dependencies are ONNX Runtime, NumPy, Pillow and huggingface_hub. Run it straight from the Hub:
uvx marimo edit --sandbox https://huggingface.co/nikhilr01/animefaces-distil-0.03b/resolve/main/demo.py
| file | what | size |
|---|---|---|
fp32/sampler_2jump.onnx (+ .onnx.data) |
full-precision sampler | 148 MB |
int8/sampler_2jump.onnx |
int8 convolutions, fp32 elsewhere | 38 MB |
layouts.py, landmark_prior.npz |
the layout prior: sample a face layout and rasterise it to masks (NumPy only) | 0.2 MB |
Keep the .onnx.data file beside the fp32 .onnx.
Each ONNX file is the whole sampler for one image (no batch axis):
noise: float32 (64, 64, 3), standard normal;masks: float32 (64, 64, 3), channels face / eyes / mouth in [0, 1]
(LayoutPrior.sample_masks in layouts.py draws them from the prior; hand-edited
layouts work the same way);image: float32 (64, 64, 3) in [-1, 1]; display with (x + 1) * 127.5.Set ONNX Runtime's intra_op_num_threads explicitly. Its default sizes the thread
pool from the host's visible CPUs, which badly oversubscribes a container with a CPU
quota (about 7x slower in a 16-core-quota container).
FID of 5,000 samples on layouts drawn from the prior (tinyflow's evaluation, Inception features on CPU; comparable within this card, not with FIDs from other pipelines):
| FID | latency, 1 / 2 / 4 threads (i9-14900, batch 1) | RAM at run time | |
|---|---|---|---|
| fp32 | 40.3 | 180 / 100 / 56 ms | 225 MB |
| int8 | 40.8 | 72 / 45 / 32 ms | 161 MB |
The int8 model costs about 0.5 FID. Before the equalization step below it cost 2–3,
and the mean pixel difference from fp32 is about 0.01 on the [-1, 1] scale.
huggan/anime-faces (21,551 images). That dataset's licence is not
clearly stated, so treat the weights accordingly; the license above covers the code
and files in this repository, and does not settle the data.int8/sampler_2jump.onnx 36 MiBfp32/sampler_2jump.onnx 6 MiBlandmark_prior.npz 175.6 KiB