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