Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -13,6 +13,7 @@ repo = "ByteDance/SDXL-Lightning"
|
|
13 |
ckpt = "sdxl_lightning_4step_unet.safetensors" # Use the correct ckpt for your step setting!
|
14 |
|
15 |
# Load model.
|
|
|
16 |
unet = UNet2DConditionModel.from_config(base, subfolder="unet").to("cuda", torch.float16)
|
17 |
unet.load_state_dict(load_file(hf_hub_download(repo, ckpt), device="cuda"))
|
18 |
pipe = StableDiffusionXLPipeline.from_pretrained(base, unet=unet, torch_dtype=torch.float16, variant="fp16").to("cuda")
|
@@ -20,7 +21,6 @@ pipe = StableDiffusionXLPipeline.from_pretrained(base, unet=unet, torch_dtype=to
|
|
20 |
# Ensure sampler uses "trailing" timesteps.
|
21 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing")
|
22 |
|
23 |
-
@spaces.GPU
|
24 |
def run():
|
25 |
# Ensure using the same inference steps as the loaded model and CFG set to 0.
|
26 |
return pipe("A cat", num_inference_steps=4, guidance_scale=0).images[0].save("output.png")
|
|
|
13 |
ckpt = "sdxl_lightning_4step_unet.safetensors" # Use the correct ckpt for your step setting!
|
14 |
|
15 |
# Load model.
|
16 |
+
@spaces.GPU
|
17 |
unet = UNet2DConditionModel.from_config(base, subfolder="unet").to("cuda", torch.float16)
|
18 |
unet.load_state_dict(load_file(hf_hub_download(repo, ckpt), device="cuda"))
|
19 |
pipe = StableDiffusionXLPipeline.from_pretrained(base, unet=unet, torch_dtype=torch.float16, variant="fp16").to("cuda")
|
|
|
21 |
# Ensure sampler uses "trailing" timesteps.
|
22 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing")
|
23 |
|
|
|
24 |
def run():
|
25 |
# Ensure using the same inference steps as the loaded model and CFG set to 0.
|
26 |
return pipe("A cat", num_inference_steps=4, guidance_scale=0).images[0].save("output.png")
|