Commit
·
4abbbf6
1
Parent(s):
73b72bb
Update space
Browse files
app.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
import random
|
|
|
|
|
4 |
from diffusers import DiffusionPipeline, UNet2DConditionModel
|
5 |
import torch
|
6 |
|
@@ -28,17 +30,34 @@ def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance
|
|
28 |
|
29 |
generator = torch.Generator().manual_seed(seed)
|
30 |
|
31 |
-
image = pipe(
|
32 |
-
prompt = prompt,
|
33 |
-
negative_prompt = negative_prompt,
|
34 |
-
guidance_scale = guidance_scale,
|
35 |
-
num_inference_steps = num_inference_steps,
|
36 |
-
width = width,
|
37 |
-
height = height,
|
38 |
-
generator = generator
|
39 |
-
).images[0]
|
40 |
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
|
43 |
examples = [
|
44 |
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
import random
|
4 |
+
from utils import generation_sdxl
|
5 |
+
import functools
|
6 |
from diffusers import DiffusionPipeline, UNet2DConditionModel
|
7 |
import torch
|
8 |
|
|
|
30 |
|
31 |
generator = torch.Generator().manual_seed(seed)
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
+
prompt = ['Long-exposure night photography of a starry sky over a mountain range, with light trails.']
|
35 |
+
|
36 |
+
|
37 |
+
text_encoders = [pipe.text_encoder, pipe.text_encoder_2]
|
38 |
+
tokenizers = [pipe.tokenizer, pipe.tokenizer_2]
|
39 |
+
|
40 |
+
compute_embeddings_fn = functools.partial(
|
41 |
+
generation_sdxl.compute_embeddings,
|
42 |
+
proportion_empty_prompts=0,
|
43 |
+
text_encoders=text_encoders,
|
44 |
+
tokenizers=tokenizers,
|
45 |
+
)
|
46 |
+
images = generation_sdxl.sample_deterministic(
|
47 |
+
pipe,
|
48 |
+
prompt,
|
49 |
+
num_inference_steps=4,
|
50 |
+
generator=generator,
|
51 |
+
guidance_scale=7.0,
|
52 |
+
is_sdxl=True,
|
53 |
+
timesteps=[249, 499, 699, 999],
|
54 |
+
use_dynamic_guidance=False,
|
55 |
+
tau1=1.0,
|
56 |
+
tau2=1.0,
|
57 |
+
compute_embeddings_fn=compute_embeddings_fn
|
58 |
+
)[0]
|
59 |
+
|
60 |
+
return images
|
61 |
|
62 |
examples = [
|
63 |
"Astronaut in a jungle, cold color palette, muted colors, detailed, 8k",
|