Skip to content

Commit

Permalink
Create demo.py
Browse files Browse the repository at this point in the history
  • Loading branch information
WangCunzheng authored Aug 26, 2024
1 parent 39c95dc commit 0c8fe5c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# !pip install opencv-python transformers accelerate
import torch
import diffusers
from diffusers import StableDiffusionXLPipeline
from tdd_scheduler import TDDScheduler

device = "cuda"
tdd_lora_path = "tdd_lora/sdxl_tdd_lora_weights.safetensors"

pipe = StableDiffusionXLPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16").to(device)

pipe.scheduler = TDDScheduler.from_config(pipe.scheduler.config)
pipe.load_lora_weights(tdd_lora_path, adapter_name="accelerate")
pipe.fuse_lora()

prompt="A photo of a cat made of water."

image = pipe(
prompt=prompt,
num_inference_steps=4,
guidance_scale=1.7,
eta=0.2,
generator=torch.Generator(device=device).manual_seed(546237),
).images[0]

0 comments on commit 0c8fe5c

Please sign in to comment.