Merge pull request #7231 from EllangoK/master
Fixes X/Y/Z Plot parameters not being restored from images
This commit is contained in:
commit
91c8d0dcfc
@ -13,7 +13,6 @@ from PIL import Image
|
|||||||
|
|
||||||
re_param_code = r'\s*([\w ]+):\s*("(?:\\"[^,]|\\"|\\|[^\"])+"|[^,]*)(?:,|$)'
|
re_param_code = r'\s*([\w ]+):\s*("(?:\\"[^,]|\\"|\\|[^\"])+"|[^,]*)(?:,|$)'
|
||||||
re_param = re.compile(re_param_code)
|
re_param = re.compile(re_param_code)
|
||||||
re_params = re.compile(r"^(?:" + re_param_code + "){3,}$")
|
|
||||||
re_imagesize = re.compile(r"^(\d+)x(\d+)$")
|
re_imagesize = re.compile(r"^(\d+)x(\d+)$")
|
||||||
re_hypernet_hash = re.compile("\(([0-9a-f]+)\)$")
|
re_hypernet_hash = re.compile("\(([0-9a-f]+)\)$")
|
||||||
type_of_gr_update = type(gr.update())
|
type_of_gr_update = type(gr.update())
|
||||||
@ -243,7 +242,7 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model
|
|||||||
done_with_prompt = False
|
done_with_prompt = False
|
||||||
|
|
||||||
*lines, lastline = x.strip().split("\n")
|
*lines, lastline = x.strip().split("\n")
|
||||||
if not re_params.match(lastline):
|
if len(re_param.findall(lastline)) < 3:
|
||||||
lines.append(lastline)
|
lines.append(lastline)
|
||||||
lastline = ''
|
lastline = ''
|
||||||
|
|
||||||
@ -262,6 +261,7 @@ Steps: 20, Sampler: Euler a, CFG scale: 7, Seed: 965400086, Size: 512x512, Model
|
|||||||
res["Negative prompt"] = negative_prompt
|
res["Negative prompt"] = negative_prompt
|
||||||
|
|
||||||
for k, v in re_param.findall(lastline):
|
for k, v in re_param.findall(lastline):
|
||||||
|
v = v[1:-1] if v[0] == '"' and v[-1] == '"' else v
|
||||||
m = re_imagesize.match(v)
|
m = re_imagesize.match(v)
|
||||||
if m is not None:
|
if m is not None:
|
||||||
res[k+"-1"] = m.group(1)
|
res[k+"-1"] = m.group(1)
|
||||||
|
@ -345,6 +345,20 @@ class ScriptRunner:
|
|||||||
outputs=[script.group for script in self.selectable_scripts]
|
outputs=[script.group for script in self.selectable_scripts]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.script_load_ctr = 0
|
||||||
|
def onload_script_visibility(params):
|
||||||
|
title = params.get('Script', None)
|
||||||
|
if title:
|
||||||
|
title_index = self.titles.index(title)
|
||||||
|
visibility = title_index == self.script_load_ctr
|
||||||
|
self.script_load_ctr = (self.script_load_ctr + 1) % len(self.titles)
|
||||||
|
return gr.update(visible=visibility)
|
||||||
|
else:
|
||||||
|
return gr.update(visible=False)
|
||||||
|
|
||||||
|
self.infotext_fields.append( (dropdown, lambda x: gr.update(value=x.get('Script', 'None'))) )
|
||||||
|
self.infotext_fields.extend( [(script.group, onload_script_visibility) for script in self.selectable_scripts] )
|
||||||
|
|
||||||
return inputs
|
return inputs
|
||||||
|
|
||||||
def run(self, p, *args):
|
def run(self, p, *args):
|
||||||
|
@ -383,6 +383,15 @@ class Script(scripts.Script):
|
|||||||
y_type.change(fn=select_axis, inputs=[y_type], outputs=[fill_y_button])
|
y_type.change(fn=select_axis, inputs=[y_type], outputs=[fill_y_button])
|
||||||
z_type.change(fn=select_axis, inputs=[z_type], outputs=[fill_z_button])
|
z_type.change(fn=select_axis, inputs=[z_type], outputs=[fill_z_button])
|
||||||
|
|
||||||
|
self.infotext_fields = (
|
||||||
|
(x_type, "X Type"),
|
||||||
|
(x_values, "X Values"),
|
||||||
|
(y_type, "Y Type"),
|
||||||
|
(y_values, "Y Values"),
|
||||||
|
(z_type, "Z Type"),
|
||||||
|
(z_values, "Z Values"),
|
||||||
|
)
|
||||||
|
|
||||||
return [x_type, x_values, y_type, y_values, z_type, z_values, draw_legend, include_lone_images, include_sub_grids, no_fixed_seeds]
|
return [x_type, x_values, y_type, y_values, z_type, z_values, draw_legend, include_lone_images, include_sub_grids, no_fixed_seeds]
|
||||||
|
|
||||||
def run(self, p, x_type, x_values, y_type, y_values, z_type, z_values, draw_legend, include_lone_images, include_sub_grids, no_fixed_seeds):
|
def run(self, p, x_type, x_values, y_type, y_values, z_type, z_values, draw_legend, include_lone_images, include_sub_grids, no_fixed_seeds):
|
||||||
@ -542,6 +551,7 @@ class Script(scripts.Script):
|
|||||||
|
|
||||||
if grid_infotext[0] is None:
|
if grid_infotext[0] is None:
|
||||||
pc.extra_generation_params = copy(pc.extra_generation_params)
|
pc.extra_generation_params = copy(pc.extra_generation_params)
|
||||||
|
pc.extra_generation_params['Script'] = self.title()
|
||||||
|
|
||||||
if x_opt.label != 'Nothing':
|
if x_opt.label != 'Nothing':
|
||||||
pc.extra_generation_params["X Type"] = x_opt.label
|
pc.extra_generation_params["X Type"] = x_opt.label
|
||||||
|
Loading…
Reference in New Issue
Block a user