Menu

I put a diffusion model in a stylesheet. No JavaScript.
📰

I put a diffusion model in a stylesheet. No JavaScript.

DEV Community: css·sky·7 days ago
#PW8VCBxC
#devtocss#devto#dev#go#seed
Reading 0:00
15s threshold

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 .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.