from diffusers import StableDiffusionPipeline
from torch import autocast
pipe = StableDiffusionPipeline.from_pretrained(
"CompVis/stable-diffusion-v1-4",
revision="fp16",
torch_dtype=torch.float16,
use_auth_token=True
)
pipe = pipe.to("cuda")
pipe.enable_attention_slicing()
prompt = "a photo of an astronaut riding a horse on mars"
with autocast("cuda"):
image = pipe(prompt).images[0]
[1] https://github.com/huggingface/diffusersThat fork released around when SD released, I've been wondering if anyone's integrated those optimizations into some of the more prominent forks that are floating around
You can do it in around 4 hours on Colab, using HuggingFace's notebook. https://colab.research.google.com/github/huggingface/noteboo...
Then you should be able to take the result (a single text token embedding) and use that locally.
(I didn't realise you were talking about textual inversion in your original post.)
This one charges but gives pretty good results at 512x512 - and in only a couple of seconds at that resolution. For more logo/cartoony stuff you can generally get a 10 step done in less than a second.
When I signed up a few weeks ago they gave 200 credits free (IIRC). After that it is $10 for another 1,000 credits (a credit gives 5 images at 10 step 512x512 or 1 image at 50 step 512x512).
Only thing to note is that after a while it slows down, but I realised that is because every image generated is going into an array in local storage in the browser. Using the browser's Inspect -> Application area to clear that array every 100 images or so sorted that out.