Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,10 @@
|
|
|
|
|
|
|
|
1 |
import torch
|
2 |
from diffusers import StableDiffusionXLPipeline, UNet2DConditionModel, EulerDiscreteScheduler
|
3 |
from huggingface_hub import hf_hub_download
|
4 |
from safetensors.torch import load_file
|
5 |
-
import gradio as gr
|
6 |
-
import spaces
|
7 |
|
8 |
base = "stabilityai/stable-diffusion-xl-base-1.0"
|
9 |
repo = "ByteDance/SDXL-Lightning"
|
@@ -14,7 +15,7 @@ unet = UNet2DConditionModel.from_config(base, subfolder="unet").to("cuda", torch
|
|
14 |
unet.load_state_dict(load_file(hf_hub_download(repo, ckpt), device="cuda"))
|
15 |
pipe = StableDiffusionXLPipeline.from_pretrained(base, unet=unet, torch_dtype=torch.float16, variant="fp16").to("cuda")
|
16 |
|
17 |
-
# Ensure sampler uses "trailing" timesteps
|
18 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing")
|
19 |
|
20 |
# Load model.
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import spaces
|
3 |
+
|
4 |
import torch
|
5 |
from diffusers import StableDiffusionXLPipeline, UNet2DConditionModel, EulerDiscreteScheduler
|
6 |
from huggingface_hub import hf_hub_download
|
7 |
from safetensors.torch import load_file
|
|
|
|
|
8 |
|
9 |
base = "stabilityai/stable-diffusion-xl-base-1.0"
|
10 |
repo = "ByteDance/SDXL-Lightning"
|
|
|
15 |
unet.load_state_dict(load_file(hf_hub_download(repo, ckpt), device="cuda"))
|
16 |
pipe = StableDiffusionXLPipeline.from_pretrained(base, unet=unet, torch_dtype=torch.float16, variant="fp16").to("cuda")
|
17 |
|
18 |
+
# Ensure sampler uses "trailing" timesteps.
|
19 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing")
|
20 |
|
21 |
# Load model.
|