Update app.py
Browse files
app.py
CHANGED
|
@@ -11,9 +11,9 @@ def generate_image(prompt, num_inference_steps):
|
|
| 11 |
ckpt = "sdxl_lightning_2step_unet.safetensors" # Use the correct ckpt for your step setting!
|
| 12 |
|
| 13 |
# Load model.
|
| 14 |
-
unet = UNet2DConditionModel.from_config(base, subfolder="unet").to("
|
| 15 |
-
unet.load_state_dict(load_file(hf_hub_download(repo, ckpt), device="
|
| 16 |
-
pipe = StableDiffusionXLPipeline.from_pretrained(base, unet=unet, torch_dtype=torch.float16, variant="fp16").to("
|
| 17 |
|
| 18 |
# Ensure sampler uses "trailing" timesteps.
|
| 19 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing")
|
|
|
|
| 11 |
ckpt = "sdxl_lightning_2step_unet.safetensors" # Use the correct ckpt for your step setting!
|
| 12 |
|
| 13 |
# Load model.
|
| 14 |
+
unet = UNet2DConditionModel.from_config(base, subfolder="unet").to(torch.device("cpu"), torch.float16)
|
| 15 |
+
unet.load_state_dict(load_file(hf_hub_download(repo, ckpt), device=torch.device("cpu")))
|
| 16 |
+
pipe = StableDiffusionXLPipeline.from_pretrained(base, unet=unet, torch_dtype=torch.float16, variant="fp16").to(torch.device("cpu"))
|
| 17 |
|
| 18 |
# Ensure sampler uses "trailing" timesteps.
|
| 19 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing")
|