From 6bea45d495710fa30d0b024a9dbceaaee1d02ac6 Mon Sep 17 00:00:00 2001 From: AUTOMATIC <16777216c@gmail.com> Date: Wed, 14 Sep 2022 10:34:44 +0300 Subject: [PATCH] prevent making grid if there is no need for it #428 --- modules/processing.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/modules/processing.py b/modules/processing.py index ef25d43df..ca32c610c 100644 --- a/modules/processing.py +++ b/modules/processing.py @@ -312,16 +312,14 @@ def process_images(p: StableDiffusionProcessing) -> Processed: state.nextjob() unwanted_grid_because_of_img_count = len(output_images) < 2 and opts.grid_only_if_multiple - if not p.do_not_save_grid and not unwanted_grid_because_of_img_count: - return_grid = opts.return_grid - + if (opts.return_grid or opts.grid_save) and not p.do_not_save_grid and not unwanted_grid_because_of_img_count: grid = images.image_grid(output_images, p.batch_size) - if return_grid: + if opts.return_grid: output_images.insert(0, grid) if opts.grid_save: - images.save_image(grid, p.outpath_grids, "grid", all_seeds[0], all_prompts[0], opts.grid_format, info=infotext(), short_filename=not opts.grid_extended_filename, grid=True, p=p) + images.save_image(grid, p.outpath_grids, "grid", all_seeds[0], all_prompts[0], opts.grid_format, info=infotext(), short_filename=not opts.grid_extended_filename, p=p) devices.torch_gc() return Processed(p, output_images, all_seeds[0], infotext())