Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -18,12 +18,13 @@ opts = {
|
|
18 |
step_loaded = 4
|
19 |
unet = UNet2DConditionModel.from_config(base, subfolder="unet").to(device, torch.float16)
|
20 |
unet.load_state_dict(load_file(hf_hub_download(repo, opts["4 Steps"][0]), device=device))
|
21 |
-
pipe = StableDiffusionXLPipeline.from_pretrained(base, torch_dtype=torch.float16, variant="fp16").to(device)
|
22 |
|
23 |
@spaces.GPU(enable_queue=True)
|
24 |
def generate_image(prompt, option):
|
|
|
25 |
ckpt, step = opts[option]
|
26 |
-
if
|
27 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing", prediction_type="sample" if step == 1 else "epsilon")
|
28 |
pipe.unet.load_state_dict(load_file(hf_hub_download(repo, ckpt), device=device))
|
29 |
step_loaded = step
|
|
|
18 |
step_loaded = 4
|
19 |
unet = UNet2DConditionModel.from_config(base, subfolder="unet").to(device, torch.float16)
|
20 |
unet.load_state_dict(load_file(hf_hub_download(repo, opts["4 Steps"][0]), device=device))
|
21 |
+
pipe = StableDiffusionXLPipeline.from_pretrained(base, unet=unet, torch_dtype=torch.float16, variant="fp16").to(device)
|
22 |
|
23 |
@spaces.GPU(enable_queue=True)
|
24 |
def generate_image(prompt, option):
|
25 |
+
global step_loaded
|
26 |
ckpt, step = opts[option]
|
27 |
+
if step != step_loaded:
|
28 |
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing", prediction_type="sample" if step == 1 else "epsilon")
|
29 |
pipe.unet.load_state_dict(load_file(hf_hub_download(repo, ckpt), device=device))
|
30 |
step_loaded = step
|