Forked from victormurcia/setup_StableDiffusionPipeline.py
Created
February 1, 2023 20:32
-
-
Save jochemstoel/6c7f80166f0cc40c8793379efc67bb1a to your computer and use it in GitHub Desktop.
code to setup Stable Diffusion pipeline
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
import mediapy as media | |
import torch | |
from diffusers import StableDiffusionPipeline | |
device = "cuda" | |
if model_id.startswith("stabilityai/"): | |
model_revision = "fp16" | |
else: | |
model_revision = None | |
if scheduler is None: | |
pipe = StableDiffusionPipeline.from_pretrained( | |
model_id, | |
torch_dtype=torch.float16, | |
revision=model_revision, | |
) | |
else: | |
pipe = StableDiffusionPipeline.from_pretrained( | |
model_id, | |
scheduler=scheduler, | |
torch_dtype=torch.float16, | |
revision=model_revision, | |
) | |
pipe = pipe.to(device) | |
pipe.enable_xformers_memory_efficient_attention() | |
if model_id.endswith('-base'): | |
image_length = 512 | |
else: | |
image_length = 768 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment