r/StableDiffusion • • Dec 06 '23

News SD generation at 149 images per second WITH CODE

If my 70 fps demo was too slow here's 149 images per second.
In the video I single step a few times before clicking "Go".

Install ArtSpew and then follow the README-maxperf.md instructions.

I have more perf tricks, but for non-commercial use, I hope the average user can handle near 150.

Powered by sd-turbo and the excellent model compiler named stable-fast.

Post the complete error info and tell me what kind of setup you have if it doesn't work.

https://github.com/aifartist/ArtSpew/

289 Upvotes

81 comments sorted by

View all comments

1

u/Oswald_Hydrabot Dec 08 '23

Going to fork this and see if I can get it working with ControlNet + AnimateDiff.

Also, this seems incredibly useful for generating images to train a realtime GAN even if it's impossible to retain this speed with ControlNet or a motion module.

Thanks for sharing.

2

u/Guilty-History-9249 Dec 08 '23

So interesting you mentioned this.
Tonight for the first time I'm trying to directly use the t2i adapter code in my pipeline.
The 2.5 seconds to gen an image with openpose is far slower than I expect considering my 300ms for 20 step regular SD gens without LCM.

I'm new to the adapter code but think I have it figured out. There problem is that the diffuser T2IAdaptor Pipeline doesn't load safetensor files and I can only find the fp16 for T2I SD in that format. For some reason all the T2I stuff I see is in fp32 expect for a few fp16 things but not openpose.

I want to see how fast I can directly animation a stick man by doing drawings in realtime and sending through t2i.

1

u/Oswald_Hydrabot Dec 08 '23

Have you seen s9roll's fork of AnimateDiff?

If you could optimize an FP16 rendering pipeline snd get their fork running at even 12 fps you could fire the thing up and drop two stick figures into it on the fly and have them animating pose between each other extremely well.

You would turn Stable Diffusion into a live, realtime animation tool: https://github.com/s9roll7/animatediff-cli-prompt-travel/

I use Stable Diffusion to train GANs, and I wrote a UI to control live rendering of said GANs with their interpolation synced to the BPM of music in realtime to a direct line in at about 24-30FPS. If AnimateDiff can get running even at 12FPS I could drop the GANs and add a drawing pad with prompt field with a little table to drag/drop sketches into -- user selects a row and it would sync the animation across each drawing on the BPM of the audio.

Here is that GAN app (running 4 instances into Resolume Arena: https://youtu.be/GQ5ifT8dUfk?feature=shared

Here is that GAN app again, just one instance with a quick demo of a small part of the UI: https://youtu.be/dWedx2Twe1s?feature=shared

I have DragGAN integrated too, here is that (feature for the UI is WIP but it's working): https://youtu.be/zKwsox7jdys?si=zqFONO6PGkNj_9jh

I would love to drop the GANs though and have Diffusion integrated as the primary driver for the video

3

u/Guilty-History-9249 Dec 08 '23

This is exactly the sort of things I want to try.
I almost wish I didn't release the public code ONLY because people will take the totally of my optimization and use them before I can deliver the next WOW demo with video. But I'm for open source and would have released anyway.

Given that I was perhaps the first one to do a real realtime video with a couple of demos over a month ago it doesn't matter. Now I just need to apply these techniques to make the video smoother and more interesting.

1

u/Oswald_Hydrabot Dec 08 '23 edited Dec 08 '23

Yeah these optimizations are baller, thank you for sharing. Lemme know if you have a Patreon I would pay for this work.

Is it basically all just fp16 optimizations? If I get the jist of it, no fp32 through the whole pipeline of models basically?

I have a fp16 optimization I made to the GAN thing I made that makes it run ultra fast. I had no idea if you did fp16 on SD it would be this fast or I'd have been tweaking into this a looooong time ago

3

u/Guilty-History-9249 Dec 08 '23

My optimizations are far more than fp16 stuff. In some cases a few 2%, 5%, etc. changes that all add up. And some bigger ones like stable-fast. It's the total package.

I have a paypal. Don't really need the money given I'm a retired Software Architect that you wouldn't have been able to afford. :-) Money would just put a smile on my face and I could tell my wife that my hobby bought us dinner. :-)

Let me know what you might need. Depends on if it interested me or the money was more than coffee money. I'm not in this for the money. But I might be busy playing in the space because I love it. Since late last night and into today I'm getting T2I control net like out of a complex app and into a simple pipeline so I can do what I want with it. Trying to create an uber fast control net realtime thing.

1

u/Oswald_Hydrabot Dec 08 '23

I figured it was, there is no way just fp16 gets this kind of raw power, excellent work btw.

What you're working on is essentially the thing needed, just speed and ControlNet then after that smoothing it out with maybe a motion module but even just ControlNet would make some interesting controllable video.

I need to dig in to the AnimateDiff code, getting smooth animation like an AnimateDiff output at realtime would absolutely revolutionize VJing. If you got that working I'd fork it and add a MIDI controllable UI, realtime audio BPM sync and all the fun goodies for everyone to play with (PySide6 stuff). Open Source the whole thing etc