Try it: metrix187.github.io/diffusion.css · Code: github.com/Metrix187/diffusion.css
Press the button and the stylesheet freezes a seed, turns it into noise, and denoises that into a 16×16 sprite in 12 steps. There is no <script> on the page. View source and check.
Why
People have already put a CPU , digit classifiers and, a few days ago, GPT-2 into CSS. I went looking for a diffusion model and couldn't find one, so this is my attempt.
The problem: CSS has no loops
Denoising is a loop. Each step needs the previous step's output, and a custom property can't refer to itself.
So the sampler is unrolled. Every step gets its own copy of the arithmetic, and every intermediate value gets its own registered custom property. A hidden unit looks like this:
@property --Ba0 { syntax : "<integer>" ; inherits : true ; initial-value : 0 }
/* first unit of the network used by step 2 */ --Ba0 : max ( 0 , ( 51096 .…