From 0c8fe5cd01e244b119264b11dbe4e227329c9ba2 Mon Sep 17 00:00:00 2001 From: WangCunzheng <113966965+WangCunzheng@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:52:27 +0800 Subject: [PATCH] Create demo.py --- demo.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 demo.py diff --git a/demo.py b/demo.py new file mode 100644 index 0000000..de0acef --- /dev/null +++ b/demo.py @@ -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]