Spaces:
Paused
Paused
lllyasviel
commited on
Commit
·
01497eb
1
Parent(s):
e848396
- modules/default_pipeline.py +6 -6
- webui.py +24 -7
modules/default_pipeline.py
CHANGED
@@ -18,14 +18,14 @@ xl_refiner = core.load_model(xl_refiner_filename)
|
|
18 |
|
19 |
|
20 |
@torch.no_grad()
|
21 |
-
def process(positive_prompt, negative_prompt, width
|
22 |
positive_conditions = core.encode_prompt_condition(clip=xl_base.clip, prompt=positive_prompt)
|
23 |
negative_conditions = core.encode_prompt_condition(clip=xl_base.clip, prompt=negative_prompt)
|
24 |
|
25 |
positive_conditions_refiner = core.encode_prompt_condition(clip=xl_refiner.clip, prompt=positive_prompt)
|
26 |
negative_conditions_refiner = core.encode_prompt_condition(clip=xl_refiner.clip, prompt=negative_prompt)
|
27 |
|
28 |
-
empty_latent = core.generate_empty_latent(width=width, height=height, batch_size=
|
29 |
|
30 |
sampled_latent = core.ksampler_with_refiner(
|
31 |
model=xl_base.unet,
|
@@ -34,10 +34,10 @@ def process(positive_prompt, negative_prompt, width=1280, height=960, batch_size
|
|
34 |
refiner=xl_refiner.unet,
|
35 |
refiner_positive=positive_conditions_refiner,
|
36 |
refiner_negative=negative_conditions_refiner,
|
37 |
-
refiner_switch_step=
|
38 |
latent=empty_latent,
|
39 |
-
steps=
|
40 |
-
seed=
|
41 |
)
|
42 |
|
43 |
decoded_latent = core.decode_vae(vae=xl_refiner.vae, latent_image=sampled_latent)
|
@@ -46,4 +46,4 @@ def process(positive_prompt, negative_prompt, width=1280, height=960, batch_size
|
|
46 |
|
47 |
close_all_preview()
|
48 |
|
49 |
-
return images
|
|
|
18 |
|
19 |
|
20 |
@torch.no_grad()
|
21 |
+
def process(positive_prompt, negative_prompt, steps, switch, width, height, image_seed):
|
22 |
positive_conditions = core.encode_prompt_condition(clip=xl_base.clip, prompt=positive_prompt)
|
23 |
negative_conditions = core.encode_prompt_condition(clip=xl_base.clip, prompt=negative_prompt)
|
24 |
|
25 |
positive_conditions_refiner = core.encode_prompt_condition(clip=xl_refiner.clip, prompt=positive_prompt)
|
26 |
negative_conditions_refiner = core.encode_prompt_condition(clip=xl_refiner.clip, prompt=negative_prompt)
|
27 |
|
28 |
+
empty_latent = core.generate_empty_latent(width=width, height=height, batch_size=1)
|
29 |
|
30 |
sampled_latent = core.ksampler_with_refiner(
|
31 |
model=xl_base.unet,
|
|
|
34 |
refiner=xl_refiner.unet,
|
35 |
refiner_positive=positive_conditions_refiner,
|
36 |
refiner_negative=negative_conditions_refiner,
|
37 |
+
refiner_switch_step=switch,
|
38 |
latent=empty_latent,
|
39 |
+
steps=steps, start_step=0, last_step=steps, disable_noise=False, force_full_denoise=True,
|
40 |
+
seed=image_seed
|
41 |
)
|
42 |
|
43 |
decoded_latent = core.decode_vae(vae=xl_refiner.vae, latent_image=sampled_latent)
|
|
|
46 |
|
47 |
close_all_preview()
|
48 |
|
49 |
+
return images
|
webui.py
CHANGED
@@ -1,18 +1,35 @@
|
|
1 |
import gradio as gr
|
|
|
2 |
|
3 |
from modules.sdxl_styles import apply_style, style_keys, aspect_ratios
|
4 |
-
|
5 |
|
6 |
|
7 |
-
def generate_clicked(
|
|
|
8 |
|
9 |
-
|
10 |
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
|
18 |
block = gr.Blocks()
|
|
|
1 |
import gradio as gr
|
2 |
+
import random
|
3 |
|
4 |
from modules.sdxl_styles import apply_style, style_keys, aspect_ratios
|
5 |
+
from modules.default_pipeline import process
|
6 |
|
7 |
|
8 |
+
def generate_clicked(prompt, negative_prompt, style_selction, performance_selction,
|
9 |
+
aspect_ratios_selction, image_number, image_seed):
|
10 |
|
11 |
+
p_txt, n_txt = apply_style(style_selction, prompt, negative_prompt)
|
12 |
|
13 |
+
if performance_selction == 'Speed':
|
14 |
+
steps = 30
|
15 |
+
switch = 20
|
16 |
+
else:
|
17 |
+
steps = 60
|
18 |
+
switch = 40
|
19 |
|
20 |
+
width, height = aspect_ratios[aspect_ratios_selction]
|
21 |
+
|
22 |
+
results = []
|
23 |
+
seed = image_seed
|
24 |
+
if not isinstance(seed, int) or seed < 0 or seed > 65535:
|
25 |
+
seed = random.randint(1, 65535)
|
26 |
+
|
27 |
+
for i in range(image_number):
|
28 |
+
imgs = process(p_txt, n_txt, steps, switch, width, height, seed)
|
29 |
+
seed += 1
|
30 |
+
results += imgs
|
31 |
+
|
32 |
+
return results
|
33 |
|
34 |
|
35 |
block = gr.Blocks()
|