Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
from diffusers import StableDiffusionXLPipeline, UNet2DConditionModel,
|
2 |
from huggingface_hub import hf_hub_download
|
3 |
from safetensors.torch import load_file
|
4 |
import spaces
|
@@ -37,8 +37,8 @@ def generate_image(prompt, ckpt):
|
|
37 |
num_inference_steps = checkpoints[ckpt][1]
|
38 |
|
39 |
if loaded != num_inference_steps:
|
40 |
-
unet.load_state_dict(torch.load(hf_hub_download(repo, checkpoint), map_location="cuda"))
|
41 |
-
pipe.scheduler =
|
42 |
loaded = num_inference_steps
|
43 |
|
44 |
results = pipe(prompt, num_inference_steps=num_inference_steps, guidance_scale=0)
|
|
|
1 |
+
from diffusers import StableDiffusionXLPipeline, UNet2DConditionModel, EulerDiscreteScheduler
|
2 |
from huggingface_hub import hf_hub_download
|
3 |
from safetensors.torch import load_file
|
4 |
import spaces
|
|
|
37 |
num_inference_steps = checkpoints[ckpt][1]
|
38 |
|
39 |
if loaded != num_inference_steps:
|
40 |
+
pipe.unet.load_state_dict(torch.load(hf_hub_download(repo, checkpoint), map_location="cuda"))
|
41 |
+
pipe.scheduler = EulerDiscreteScheduler.from_config(pipe.scheduler.config, timestep_spacing="trailing", prediction_type="sample" if num_inference_steps==1 else "epsilon")
|
42 |
loaded = num_inference_steps
|
43 |
|
44 |
results = pipe(prompt, num_inference_steps=num_inference_steps, guidance_scale=0)
|