This commit is contained in:
parent
80ce0abf9a
commit
8bdb8f6889
|
|
@ -18,14 +18,14 @@ xl_refiner = core.load_model(xl_refiner_filename)
|
|||
|
||||
|
||||
@torch.no_grad()
|
||||
def process(positive_prompt, negative_prompt, width=1280, height=960, batch_size=1):
|
||||
def process(positive_prompt, negative_prompt, steps, switch, width, height, image_seed):
|
||||
positive_conditions = core.encode_prompt_condition(clip=xl_base.clip, prompt=positive_prompt)
|
||||
negative_conditions = core.encode_prompt_condition(clip=xl_base.clip, prompt=negative_prompt)
|
||||
|
||||
positive_conditions_refiner = core.encode_prompt_condition(clip=xl_refiner.clip, prompt=positive_prompt)
|
||||
negative_conditions_refiner = core.encode_prompt_condition(clip=xl_refiner.clip, prompt=negative_prompt)
|
||||
|
||||
empty_latent = core.generate_empty_latent(width=width, height=height, batch_size=batch_size)
|
||||
empty_latent = core.generate_empty_latent(width=width, height=height, batch_size=1)
|
||||
|
||||
sampled_latent = core.ksampler_with_refiner(
|
||||
model=xl_base.unet,
|
||||
|
|
@ -34,10 +34,10 @@ def process(positive_prompt, negative_prompt, width=1280, height=960, batch_size
|
|||
refiner=xl_refiner.unet,
|
||||
refiner_positive=positive_conditions_refiner,
|
||||
refiner_negative=negative_conditions_refiner,
|
||||
refiner_switch_step=20,
|
||||
refiner_switch_step=switch,
|
||||
latent=empty_latent,
|
||||
steps=30, start_step=0, last_step=30, disable_noise=False, force_full_denoise=True,
|
||||
seed=123456
|
||||
steps=steps, start_step=0, last_step=steps, disable_noise=False, force_full_denoise=True,
|
||||
seed=image_seed
|
||||
)
|
||||
|
||||
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
|
|||
|
||||
close_all_preview()
|
||||
|
||||
return images * 2
|
||||
return images
|
||||
|
|
|
|||
31
webui.py
31
webui.py
|
|
@ -1,18 +1,35 @@
|
|||
import gradio as gr
|
||||
import random
|
||||
|
||||
from modules.sdxl_styles import apply_style, style_keys, aspect_ratios
|
||||
# from modules.default_pipeline import process
|
||||
from modules.default_pipeline import process
|
||||
|
||||
|
||||
def generate_clicked(positive_prompt):
|
||||
def generate_clicked(prompt, negative_prompt, style_selction, performance_selction,
|
||||
aspect_ratios_selction, image_number, image_seed):
|
||||
|
||||
p, n = apply_style('cinematic-default', positive_prompt, '')
|
||||
p_txt, n_txt = apply_style(style_selction, prompt, negative_prompt)
|
||||
|
||||
print(p)
|
||||
print(n)
|
||||
if performance_selction == 'Speed':
|
||||
steps = 30
|
||||
switch = 20
|
||||
else:
|
||||
steps = 60
|
||||
switch = 40
|
||||
|
||||
return process(positive_prompt=p,
|
||||
negative_prompt=n)
|
||||
width, height = aspect_ratios[aspect_ratios_selction]
|
||||
|
||||
results = []
|
||||
seed = image_seed
|
||||
if not isinstance(seed, int) or seed < 0 or seed > 65535:
|
||||
seed = random.randint(1, 65535)
|
||||
|
||||
for i in range(image_number):
|
||||
imgs = process(p_txt, n_txt, steps, switch, width, height, seed)
|
||||
seed += 1
|
||||
results += imgs
|
||||
|
||||
return results
|
||||
|
||||
|
||||
block = gr.Blocks()
|
||||
|
|
|
|||
Loading…
Reference in New Issue