diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

JAX / Flax: avoid recompilation on params change: guidance scale, size, number of steps

Open pcuenca opened this issue 3 years ago โ€ข 10 comments

This is required to improve the demo(s), we currently have the sliders disabled.

Some users are also requesting it in discord and the forums. Our demo notebook is very fast on TPU hardware but users can't quickly explore different parameters.

pcuenca avatar Oct 27 '22 09:10 pcuenca

Please make a script that can convert original stable diffusion to flax ๐Ÿš€

camenduru avatar Oct 28 '22 00:10 camenduru

and please make an auto-converter if someone publishes it like this https://huggingface.co/nitrosocke/modern-disney-diffusion it will automatically convert to all different models ๐Ÿค–๐Ÿงจ

camenduru avatar Oct 28 '22 00:10 camenduru

Hey @camenduru it should be as easy as doing:

from diffusers import FlaxStableDiffusionPipeline

pipeline, params = FlaxStableDiffusionPipeline.from_pretrained("<path-to-stable-diffusion-checkpoint>", from_pt=True)
pipeline.save_pretrained("<path/to/hub/repo/with/flax/branch>", params=params)

patrickvonplaten avatar Oct 31 '22 18:10 patrickvonplaten

We should add better docs for this though and an automated converter tool sounds like a great idea indeed!

patrickvonplaten avatar Oct 31 '22 18:10 patrickvonplaten

@patrickvonplaten โœจ thanks I converted https://huggingface.co/nitrosocke/mo-di-diffusion to flax but how to push to flax branch I opened PR but PR going to main branch ๐Ÿ†˜

camenduru avatar Oct 31 '22 21:10 camenduru

and I converted like this

pipeline, params = FlaxStableDiffusionPipeline.from_pretrained("nitrosocke/mo-di-diffusion", from_pt=True)
pipeline.save_pretrained("/home/camenduru/mo-di-flax", params=params)

should I put this to bf16 branch or flax branch ?

camenduru avatar Oct 31 '22 22:10 camenduru

I also converted waifu-diffusion โœจ haru will add here ๐ŸŽ‰

camenduru avatar Nov 01 '22 00:11 camenduru

and I converted like this

pipeline, params = FlaxStableDiffusionPipeline.from_pretrained("nitrosocke/mo-di-diffusion", from_pt=True)
pipeline.save_pretrained("/home/camenduru/mo-di-flax", params=params)

should I put this to bf16 branch or flax branch ?

I'd put it on a flax branch :-)

patrickvonplaten avatar Nov 02 '22 16:11 patrickvonplaten

Hey @camenduru,

Thanks for opening the issue on the Hub. I answered there: https://huggingface.co/nitrosocke/mo-di-diffusion/discussions/8#6362a3672c0bb59ecc191a07 . Please ping me if you need my help going forward :-) If ok for the author of the repo, I'd open a branch directly on main actually. Flax and PyTorch weights can live in the same repo branch side-by-side.

patrickvonplaten avatar Nov 02 '22 17:11 patrickvonplaten

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the contributing guidelines are likely to be ignored.

github-actions[bot] avatar Nov 27 '22 15:11 github-actions[bot]