Generate quick result with low number of steps, peek, then run for longer

#34
by m02ph3u5 - opened

Is there a way to generate like a sneak preview with a low number of inference steps and then plug the image back in again for some more inference? Or to make it spit out previews every so many steps?

Right now I engineer the prompt with like ten steps to find a good idea, grab the seed and then run 80 steps, a hundred steps etc. to find something that really shines. But it's a real waste of time and electric power to run the full 100 steps when you just ran 80 of them. It'd be great to pick up where you left off.

Hey @m02ph3u5 ,

I understand your use case! It's a bit specific IMo but it's totally possible to do exactly this with diffusers!

You should simply write out the loop of the Stable Diffusion Pipeline as is done here:
https://huggingface.co/blog/stable_diffusion#writing-your-own-inference-pipeline

And then make sure to set a breakpoint after 20 steps or some interactive code logic so that you can decide to either continue the loop or stop it

Have a look at torch.get_rng_state and torch.set_rng_state`. When you load the state of the initialization vector and load the rng state before the loop you should be able to skip the first 20 iterations.

Thanks for the quick replies. I'll give it a spin and report back once I got to it.

Sorry, but it will probably NOT work like this.

When you run it with 20 Steps, then 0-100% are stretched over 20 steps. When you would diffuse for 20 of 100 steps, then you would get a noisy image (that could then be improved by running another 80 steps).
You may have success using the image2image pipeline, but it will probably change your image more than running the pipeline again.

Thanks xalex, that's what I'd imagined. I'll play around with the pipeline anyway.

Sign up or log in to comment