Submitted by crowwork t3_11u8uk6 in MachineLearning

Most of the existing stable diffusion demos rely on a server behind to run the image generation. It means you need to host your own GPU server to support these workloads. It is hard to have the demo run purely on web browser, because stable diffusion usually has heavy computation and memory consumption. The web stable diffusion directly puts stable diffusion model in your browser, and it runs directly through client GPU on users’ laptop.

This means there is no queueing time for the server’s response, more opportunities for client server co-optimizations, and friendly for personalization and privacy.

​

Github page: https://github.com/mlc-ai/web-stable-diffusion

Also comes with a online demo: https://mlc.ai/web-stable-diffusion/

106

Comments

You must log in or register to comment.

Educational_Ice151 t1_jcn7818 wrote

Wow! 🤯 this is so useful

Shared to r/aipromptprogramming

9

kalakau t1_jcn6q2v wrote

absolutely amazing, thanks for doing this!

8

WASDx t1_jcogs0j wrote

How does it store the model? I assume it's not re-downloaded every time you visit the page, and I would not expect my browser to allow caching multiple gigabytes from a single domain.

5

crowwork OP t1_jcourze wrote

models are stored in the browser cache via an explicit browser cache api. So the model is cached once.

3

remghoost7 t1_jcnvpqh wrote

Very interesting....

Reminds me of how some VR apps can run natively in browsers, using hardware acceleration I believe. I'm guessing this is something sort of similar to that....? Could be entirely wrong though.

Cool stuff though. Would be need to make an extension of this for A1111.... Not to diminish the work you've done, but it would probably get more exposure that way (since it's the most used Stable Diffusion front end out there).

3

LetMeGuessYourAlts t1_jcq33nb wrote

The Unreal Engine let's you compile to browser with basically a few clicks so that might be how they're doing it and abstracts away a lot of the hard parts.

1

remghoost7 t1_jcq8emm wrote

Ah, it was made with unreal.....? I didn't see that.

I always love adaptations of video game engines. One of the reasons I've been a huge fan of Unity for years. It's essentially just a wrapper for C# code with a pretty interface.

1

shadowknight094 t1_jco3sjk wrote

When I click generate button in Chrome on my desktop nothing happens? Is this a service worker or a network call? I don't see anything in Chrome dev tools

3

asdf3011 t1_jcnz5d2 wrote

Going to send this to people when someone shows curiosity to trying image generation. Thanks you!

1

race2tb t1_jcops9d wrote

I think there is a need for a p2p torrent backend for models that needs to exist now.

1

marcus_hk t1_jcrdufd wrote

For weights, yes, and for inference. If you can decompose and distribute a model across enough nodes, then you can get meaningful compute out of CPUs too — for instance for tokenization and smaller models.

1

marcus_hk t1_jcrgwqm wrote

Just browsing on my phone and haven’t dug deep yet, but in the notebook it says that build.py targets M2 by default but can also target CUDA. What about CPU?

I’d love to see a super minimal example, like running a small nn.Linear layer, for pedagogical purposes and to abstract away the complexity of a larger model like Stable Diffusion.

1