Last active
March 25, 2023 06:13
-
-
Save offchan42/e0b4169000fdbaf018d96bdcc05ae1c9 to your computer and use it in GitHub Desktop.
Load stable diffusion pipeline with model cache in google drive. Use in Colab
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cache_dir = "/root/.cache/huggingface/hub" | |
!ln -fs /content/drive/MyDrive/huggingface_hub_cache $cache_dir | |
from diffusers import StableDiffusionPipeline | |
import torch | |
model_id = "runwayml/stable-diffusion-v1-5" | |
pipe = StableDiffusionPipeline.from_pretrained(model_id, cache_dir=cache_dir, torch_dtype=torch.float16) | |
pipe = pipe.to("cuda") | |
prompt = "a photo of an astronaut riding a horse on mars" | |
image = pipe(prompt).images[0] | |
image.save("astronaut_rides_horse.png") | |
image |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment