diff --git a/modules/images.py b/modules/images.py index 5d7684285..a4b1e1b3b 100644 --- a/modules/images.py +++ b/modules/images.py @@ -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) diff --git a/modules/processing.py b/modules/processing.py index 50870d405..f1ccc4901 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -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: diff --git a/modules/sd_models.py b/modules/sd_models.py index 72422b498..88a058acb 100644 --- a/modules/sd_models.py +++ b/modules/sd_models.py @@ -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) diff --git a/modules/sd_vae.py b/modules/sd_vae.py index 0360d83b3..e979666e2 100644 --- a/modules/sd_vae.py +++ b/modules/sd_vae.py @@ -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() diff --git a/modules/shared.py b/modules/shared.py index c9e3c49ea..c876cf076 100644 --- a/modules/shared.py +++ b/modules/shared.py @@ -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("

Intermediate Image Saving

", "", gr.HTML), "save_init_img": OptionInfo(True, "Save copy of img2img init images (helps track workflow)"), diff --git a/scripts/outpainting_mk_2.py b/scripts/outpainting_mk_2.py index 4b0af3053..bbf7aa537 100644 --- a/scripts/outpainting_mk_2.py +++ b/scripts/outpainting_mk_2.py @@ -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