Type anything. Watch it paint.

Try it in your browser β†’  Β·  Compact model  Β·  MiniT2I paper

MiniT2I compact for WebGPU

lox9973/MiniT2I-B-16-MF-compact as one ONNX graph for onnxruntime-web on WebGPU. A prompt and a noise tensor go in, a finished 512 Γ— 512 picture comes out: the text encoder and all four Mean Flow steps are inside the graph. About 0.55 s per picture in Chrome on an Apple M3 Max.

import * as ort from "onnxruntime-web/webgpu";

const base = "https://huggingface.co/cfahlgren1/MiniT2I-B-16-MF-compact-webgpu-int8/resolve/main/";
const session = await ort.InferenceSession.create(base + "minit2i.onnx", {
  executionProviders: ["webgpu"],
  externalData: [{ path: "minit2i.onnx.data", data: base + "minit2i.onnx.data" }],
});

const { image } = await session.run({
  input_ids: new ort.Tensor("int64", ids, [1, 256]),        // T5 ids from tokenizer.ts, padded with 0
  attention_mask: new ort.Tensor("int64", mask, [1, 256]),
  noise: new ort.Tensor("float32", noise, [1, 3, 512, 512]), // standard normal Γ— 2
});
// pixel = clamp(image, -1, 1) Γ— 127.5 + 128

int8 weights

Weights are stored as int8 and turned back into fp16 inside the graph, so the download halves and the speed stays the same. Same prompts, same seeds:

fp16 and int8 outputs side by side

How it was converted
  • Int8 weights (quant.py): every matmul weight and the T5 embedding table get one scale per output column, followed by DequantizeLinear and a cast to fp16.
  • Mixed precision (export.py): T5 runs in fp32 because its hidden states reach about 286,000, past fp16's 65,504 limit. The image transformer runs in fp16 with an overflow-safe RMSNorm.
  • Precomputed tables: RoPE angles, position embeddings, the T5 position bias and the fixed timestep and guidance tokens are baked in as constants.
  • Fixed settings: guidance scale 12, guidance interval [0.2, 0.8], four steps, matching upstream.
  • Accuracy: Chrome WebGPU differs from the fp32 PyTorch pipeline by 8–13 out of 255 per pixel. Int8 adds 2.9 on average.

Credits

The model is MiniT2I by Xianbang Wang, Hanhong Zhao, Yiyang Lu, Kangyang Zhou, Linrui Ma and Kaiming He, made compact by lox9973. This conversion is MIT licensed like the original; its notice is in LICENSE-MiniT2I.txt.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for cfahlgren1/MiniT2I-B-16-MF-compact-webgpu-int8

Quantized
(2)
this model

Space using cfahlgren1/MiniT2I-B-16-MF-compact-webgpu-int8 1