wilsonHuggingFace commited on
Commit
63f47f9
·
verified ·
1 Parent(s): daf84fc

Delete SDXL_Lighting.py

Browse files
Files changed (1) hide show
  1. SDXL_Lighting.py +0 -39
SDXL_Lighting.py DELETED
@@ -1,39 +0,0 @@
1
- ## download
2
- # git clone https://hf-mirror.com/stabilityai/stable-diffusion-xl-base-1.0
3
- # wget -c hf-mirror.com/stabilityai/stable-diffusion-xl-base-1.0/resolve/main/unet/diffusion_pytorch_model.fp16.safetensors
4
- # wget -c https://hf-mirror.com/ByteDance/SDXL-Lightning/resolve/main/sdxl_lightning_4step_unet.safetensors
5
- # base = xxx/stable-diffusion-xl-base-1.0
6
- # ckpt = SDXL-Lightning/sdxl_lightning_4step_unet.safetensors
7
-
8
- import torch
9
- from diffusers import StableDiffusionXLPipeline, UNet2DConditionModel, EulerDiscreteScheduler
10
- from huggingface_hub import hf_hub_download
11
- from safetensors.torch import load_file
12
-
13
- base = "stabilityai/stable-diffusion-xl-base-1.0"
14
- repo = "ByteDance/SDXL-Lightning"
15
- ckpt = "sdxl_lightning_4step_unet.safetensors" # Use the correct ckpt for your step setting!
16
-
17
- def t2i(prompt):
18
-
19
- # Load model.
20
-
21
- # unet = UNet2DConditionModel.from_config(base, subfolder="unet").to("cuda", torch.float16)
22
- # unet.load_state_dict(load_file(hf_hub_download(repo, ckpt), device="cuda"))
23
- # pipe = StableDiffusionXLPipeline.from_pretrained(base, unet=unet, torch_dtype=torch.float16, variant="fp16").to("cuda")
24
-
25
- unet = UNet2DConditionModel.from_config(base, subfolder="unet").to("cuda", torch.float16)
26
- unet.load_state_dict(load_file(ckpt), device="cuda"))
27
- pipe = StableDiffusionXLPipeline.from_pretrained(base, unet=unet, torch_dtype=torch.float16, variant="fp16").to("cuda")
28
-
29
- # Ensure sampler uses "trailing" timesteps.
30
- pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing")
31
-
32
- # Ensure using the same inference steps as the loaded model and CFG set to 0.
33
- image = pipe(prompt, num_inference_steps=4, guidance_scale=0).images[0]
34
- return image
35
-
36
- if __name__ == "__main__":
37
- prompt = "a girl in beijing"
38
- image = t2i(prompt)
39
- image.save("sdxl_lighting_output.png")