mirror of
https://github.com/AUTOMATIC1111/stable-diffusion-webui.git
synced 2026-02-07 16:20:56 -08:00
Merge remote-tracking branch 'upstream/master' into xy_grid_individual_images
This commit is contained in:
commit
9201662e3a
20 changed files with 705 additions and 221 deletions
|
|
@ -129,8 +129,6 @@ class Script(scripts.Script):
|
|||
return [original_prompt, original_negative_prompt, cfg, st, randomness, sigma_adjustment]
|
||||
|
||||
def run(self, p, original_prompt, original_negative_prompt, cfg, st, randomness, sigma_adjustment):
|
||||
p.batch_size = 1
|
||||
p.batch_count = 1
|
||||
|
||||
|
||||
def sample_extra(conditioning, unconditional_conditioning, seeds, subseeds, subseed_strength):
|
||||
|
|
@ -154,7 +152,7 @@ class Script(scripts.Script):
|
|||
rec_noise = find_noise_for_image(p, cond, uncond, cfg, st)
|
||||
self.cache = Cached(rec_noise, cfg, st, lat, original_prompt, original_negative_prompt, sigma_adjustment)
|
||||
|
||||
rand_noise = processing.create_random_tensors(p.init_latent.shape[1:], [p.seed + x + 1 for x in range(p.init_latent.shape[0])])
|
||||
rand_noise = processing.create_random_tensors(p.init_latent.shape[1:], seeds=seeds, subseeds=subseeds, subseed_strength=p.subseed_strength, seed_resize_from_h=p.seed_resize_from_h, seed_resize_from_w=p.seed_resize_from_w, p=p)
|
||||
|
||||
combined_noise = ((1 - randomness) * rec_noise + randomness * rand_noise) / ((randomness**2 + (1-randomness)**2) ** 0.5)
|
||||
|
||||
|
|
|
|||
|
|
@ -77,14 +77,42 @@ def apply_sampler(p, x, xs):
|
|||
p.sampler_index = sampler_index
|
||||
|
||||
|
||||
def confirm_samplers(p, xs):
|
||||
samplers_dict = build_samplers_dict(p)
|
||||
for x in xs:
|
||||
if x.lower() not in samplers_dict.keys():
|
||||
raise RuntimeError(f"Unknown sampler: {x}")
|
||||
|
||||
|
||||
def apply_checkpoint(p, x, xs):
|
||||
info = modules.sd_models.get_closet_checkpoint_match(x)
|
||||
assert info is not None, f'Checkpoint for {x} not found'
|
||||
if info is None:
|
||||
raise RuntimeError(f"Unknown checkpoint: {x}")
|
||||
modules.sd_models.reload_model_weights(shared.sd_model, info)
|
||||
|
||||
|
||||
def confirm_checkpoints(p, xs):
|
||||
for x in xs:
|
||||
if modules.sd_models.get_closet_checkpoint_match(x) is None:
|
||||
raise RuntimeError(f"Unknown checkpoint: {x}")
|
||||
|
||||
|
||||
def apply_hypernetwork(p, x, xs):
|
||||
hypernetwork.load_hypernetwork(x)
|
||||
if x.lower() in ["", "none"]:
|
||||
name = None
|
||||
else:
|
||||
name = hypernetwork.find_closest_hypernetwork_name(x)
|
||||
if not name:
|
||||
raise RuntimeError(f"Unknown hypernetwork: {x}")
|
||||
hypernetwork.load_hypernetwork(name)
|
||||
|
||||
|
||||
def confirm_hypernetworks(p, xs):
|
||||
for x in xs:
|
||||
if x.lower() in ["", "none"]:
|
||||
continue
|
||||
if not hypernetwork.find_closest_hypernetwork_name(x):
|
||||
raise RuntimeError(f"Unknown hypernetwork: {x}")
|
||||
|
||||
|
||||
def apply_clip_skip(p, x, xs):
|
||||
|
|
@ -121,29 +149,29 @@ def str_permutations(x):
|
|||
return x
|
||||
|
||||
|
||||
AxisOption = namedtuple("AxisOption", ["label", "type", "apply", "format_value"])
|
||||
AxisOptionImg2Img = namedtuple("AxisOptionImg2Img", ["label", "type", "apply", "format_value"])
|
||||
AxisOption = namedtuple("AxisOption", ["label", "type", "apply", "format_value", "confirm"])
|
||||
AxisOptionImg2Img = namedtuple("AxisOptionImg2Img", ["label", "type", "apply", "format_value", "confirm"])
|
||||
|
||||
|
||||
axis_options = [
|
||||
AxisOption("Nothing", str, do_nothing, format_nothing),
|
||||
AxisOption("Seed", int, apply_field("seed"), format_value_add_label),
|
||||
AxisOption("Var. seed", int, apply_field("subseed"), format_value_add_label),
|
||||
AxisOption("Var. strength", float, apply_field("subseed_strength"), format_value_add_label),
|
||||
AxisOption("Steps", int, apply_field("steps"), format_value_add_label),
|
||||
AxisOption("CFG Scale", float, apply_field("cfg_scale"), format_value_add_label),
|
||||
AxisOption("Prompt S/R", str, apply_prompt, format_value),
|
||||
AxisOption("Prompt order", str_permutations, apply_order, format_value_join_list),
|
||||
AxisOption("Sampler", str, apply_sampler, format_value),
|
||||
AxisOption("Checkpoint name", str, apply_checkpoint, format_value),
|
||||
AxisOption("Hypernetwork", str, apply_hypernetwork, format_value),
|
||||
AxisOption("Sigma Churn", float, apply_field("s_churn"), format_value_add_label),
|
||||
AxisOption("Sigma min", float, apply_field("s_tmin"), format_value_add_label),
|
||||
AxisOption("Sigma max", float, apply_field("s_tmax"), format_value_add_label),
|
||||
AxisOption("Sigma noise", float, apply_field("s_noise"), format_value_add_label),
|
||||
AxisOption("Eta", float, apply_field("eta"), format_value_add_label),
|
||||
AxisOption("Clip skip", int, apply_clip_skip, format_value_add_label),
|
||||
AxisOptionImg2Img("Denoising", float, apply_field("denoising_strength"), format_value_add_label), # as it is now all AxisOptionImg2Img items must go after AxisOption ones
|
||||
AxisOption("Nothing", str, do_nothing, format_nothing, None),
|
||||
AxisOption("Seed", int, apply_field("seed"), format_value_add_label, None),
|
||||
AxisOption("Var. seed", int, apply_field("subseed"), format_value_add_label, None),
|
||||
AxisOption("Var. strength", float, apply_field("subseed_strength"), format_value_add_label, None),
|
||||
AxisOption("Steps", int, apply_field("steps"), format_value_add_label, None),
|
||||
AxisOption("CFG Scale", float, apply_field("cfg_scale"), format_value_add_label, None),
|
||||
AxisOption("Prompt S/R", str, apply_prompt, format_value, None),
|
||||
AxisOption("Prompt order", str_permutations, apply_order, format_value_join_list, None),
|
||||
AxisOption("Sampler", str, apply_sampler, format_value, confirm_samplers),
|
||||
AxisOption("Checkpoint name", str, apply_checkpoint, format_value, confirm_checkpoints),
|
||||
AxisOption("Hypernetwork", str, apply_hypernetwork, format_value, confirm_hypernetworks),
|
||||
AxisOption("Sigma Churn", float, apply_field("s_churn"), format_value_add_label, None),
|
||||
AxisOption("Sigma min", float, apply_field("s_tmin"), format_value_add_label, None),
|
||||
AxisOption("Sigma max", float, apply_field("s_tmax"), format_value_add_label, None),
|
||||
AxisOption("Sigma noise", float, apply_field("s_noise"), format_value_add_label, None),
|
||||
AxisOption("Eta", float, apply_field("eta"), format_value_add_label, None),
|
||||
AxisOption("Clip skip", int, apply_clip_skip, format_value_add_label, None),
|
||||
AxisOptionImg2Img("Denoising", float, apply_field("denoising_strength"), format_value_add_label, None), # as it is now all AxisOptionImg2Img items must go after AxisOption ones
|
||||
]
|
||||
|
||||
|
||||
|
|
@ -275,17 +303,10 @@ class Script(scripts.Script):
|
|||
valslist = list(permutations(valslist))
|
||||
|
||||
valslist = [opt.type(x) for x in valslist]
|
||||
|
||||
|
||||
# Confirm options are valid before starting
|
||||
if opt.label == "Sampler":
|
||||
samplers_dict = build_samplers_dict(p)
|
||||
for sampler_val in valslist:
|
||||
if sampler_val.lower() not in samplers_dict.keys():
|
||||
raise RuntimeError(f"Unknown sampler: {sampler_val}")
|
||||
elif opt.label == "Checkpoint name":
|
||||
for ckpt_val in valslist:
|
||||
if modules.sd_models.get_closet_checkpoint_match(ckpt_val) is None:
|
||||
raise RuntimeError(f"Checkpoint for {ckpt_val} not found")
|
||||
if opt.confirm:
|
||||
opt.confirm(p, valslist)
|
||||
|
||||
return valslist
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue