cleanup options

This commit is contained in:
Vladimir Mandic
2023-09-08 07:59:58 -04:00
parent 2a213e8e84
commit 0194620ec2
6 changed files with 8 additions and 11 deletions
+1 -4
View File
@@ -44,13 +44,10 @@ def image_grid(imgs, batch_size=1, rows=None):
rows = shared.opts.n_rows
elif shared.opts.n_rows == 0:
rows = batch_size
elif shared.opts.grid_prevent_empty_spots:
else:
rows = math.floor(math.sqrt(len(imgs)))
while len(imgs) % rows != 0:
rows -= 1
else:
rows = math.sqrt(len(imgs))
rows = round(rows)
if rows > len(imgs):
rows = len(imgs)
cols = math.ceil(len(imgs) / rows)
+1 -2
View File
@@ -853,8 +853,7 @@ def process_images_inner(p: StableDiffusionProcessing) -> Processed:
p.color_corrections = None
index_of_first_image = 0
unwanted_grid_because_of_img_count = len(output_images) < 2 and shared.opts.grid_only_if_multiple
if (shared.opts.return_grid or shared.opts.grid_save) and not p.do_not_save_grid and not unwanted_grid_because_of_img_count:
if (shared.opts.return_grid or shared.opts.grid_save) and not p.do_not_save_grid and len(output_images) > 2:
if images.check_grid_size(output_images):
grid = images.image_grid(output_images, p.batch_size)
if shared.opts.return_grid:
+1
View File
@@ -140,6 +140,7 @@ def checkpoint_tiles(use_short=False): # pylint: disable=unused-argument
return int(name) if name.isdigit() else name.lower()
def alphanumeric_key(key):
return [convert(c) for c in re.split('([0-9]+)', key)]
print('HERE', len(checkpoints_list.values()))
return sorted([x.title for x in checkpoints_list.values()], key=alphanumeric_key)
+1
View File
@@ -52,6 +52,7 @@ def get_filename(filepath):
def refresh_vae_list():
print('HERE')
global vae_path # pylint: disable=global-statement
vae_path = shared.opts.vae_dir
vae_dict.clear()
+2 -2
View File
@@ -475,8 +475,8 @@ options_templates.update(options_section(('saving-images', "Image Options"), {
"grid_save": OptionInfo(True, "Always save all generated image grids"),
"grid_format": OptionInfo('jpg', 'File format for grids', gr.Dropdown, lambda: {"choices": ["jpg", "png", "webp", "tiff", "jp2"]}),
"n_rows": OptionInfo(-1, "Grid row count", gr.Slider, {"minimum": -1, "maximum": 16, "step": 1}),
"grid_only_if_multiple": OptionInfo(True, "Do not save grids consisting of one picture"),
"grid_prevent_empty_spots": OptionInfo(True, "Prevent empty spots in grid (when set to autodetect)"),
# "grid_only_if_multiple": OptionInfo(True, "Do not save grids consisting of one picture"),
# "grid_prevent_empty_spots": OptionInfo(True, "Prevent empty spots in grid (when set to autodetect)"),
"save_sep_options": OptionInfo("<h2>Intermediate Image Saving</h2>", "", gr.HTML),
"save_init_img": OptionInfo(True, "Save copy of img2img init images (helps track workflow)"),
+2 -3
View File
@@ -264,8 +264,7 @@ class Script(scripts.Script):
all_images = all_processed_images
combined_grid_image = images.image_grid(all_processed_images)
unwanted_grid_because_of_img_count = len(all_processed_images) < 2 and opts.grid_only_if_multiple
if opts.return_grid and not unwanted_grid_because_of_img_count:
if opts.return_grid and len(all_processed_images) > 1:
all_images = [combined_grid_image] + all_processed_images
res = Processed(p, all_images, initial_seed_and_info[0], initial_seed_and_info[1])
@@ -274,7 +273,7 @@ class Script(scripts.Script):
for img in all_processed_images:
images.save_image(img, p.outpath_samples, "", res.seed, p.prompt, opts.samples_format, info=res.info, p=p)
if opts.grid_save and not unwanted_grid_because_of_img_count:
if opts.grid_save and len(all_processed_images) > 1:
images.save_image(combined_grid_image, p.outpath_grids, "grid", res.seed, p.prompt, opts.samples_format, info=res.info, short_filename=not opts.grid_extended_filename, grid=True, p=p)
return res