fix images not displayed when not saving

fix lack of left padding for grids with 1 row
This commit is contained in:
AUTOMATIC 2022-09-01 22:38:25 +03:00
parent 5a6c0740ab
commit 63a3ae2b4c
1 changed files with 26 additions and 26 deletions

View File

@ -548,7 +548,7 @@ def draw_grid_annotations(im, width, height, hor_texts, ver_texts):
color_active = (0, 0, 0) color_active = (0, 0, 0)
color_inactive = (153, 153, 153) color_inactive = (153, 153, 153)
pad_left = width * 3 // 4 if len(ver_texts) > 1 else 0 pad_left = width * 3 // 4 if len(ver_texts) > 0 else 0
cols = im.width // width cols = im.width // width
rows = im.height // height rows = im.height // height
@ -1145,7 +1145,6 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
x_samples_ddim = model.decode_first_stage(samples_ddim) x_samples_ddim = model.decode_first_stage(samples_ddim)
x_samples_ddim = torch.clamp((x_samples_ddim + 1.0) / 2.0, min=0.0, max=1.0) x_samples_ddim = torch.clamp((x_samples_ddim + 1.0) / 2.0, min=0.0, max=1.0)
if p.prompt_matrix or opts.samples_save or opts.grid_save:
for i, x_sample in enumerate(x_samples_ddim): for i, x_sample in enumerate(x_samples_ddim):
x_sample = 255. * np.moveaxis(x_sample.cpu().numpy(), 0, 2) x_sample = 255. * np.moveaxis(x_sample.cpu().numpy(), 0, 2)
x_sample = x_sample.astype(np.uint8) x_sample = x_sample.astype(np.uint8)
@ -1172,13 +1171,13 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
image.alpha_composite(overlay) image.alpha_composite(overlay)
image = image.convert('RGB') image = image.convert('RGB')
if not p.do_not_save_samples: if opts.samples_save and not p.do_not_save_samples:
save_image(image, p.outpath_samples, "", seeds[i], prompts[i], opts.samples_format, info=infotext()) save_image(image, p.outpath_samples, "", seeds[i], prompts[i], opts.samples_format, info=infotext())
output_images.append(image) output_images.append(image)
unwanted_grid_because_of_img_count = len(output_images) < 2 and opts.grid_only_if_multiple unwanted_grid_because_of_img_count = len(output_images) < 2 and opts.grid_only_if_multiple
if (p.prompt_matrix or opts.grid_save) and not p.do_not_save_grid and not unwanted_grid_because_of_img_count: if not p.do_not_save_grid and not unwanted_grid_because_of_img_count:
return_grid = opts.return_grid return_grid = opts.return_grid
if p.prompt_matrix: if p.prompt_matrix:
@ -1198,6 +1197,7 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
if return_grid: if return_grid:
output_images.insert(0, grid) output_images.insert(0, grid)
if opts.grid_save:
save_image(grid, p.outpath_grids, "grid", seed, prompt, opts.grid_format, info=infotext(), short_filename=not opts.grid_extended_filename) save_image(grid, p.outpath_grids, "grid", seed, prompt, opts.grid_format, info=infotext(), short_filename=not opts.grid_extended_filename)
torch_gc() torch_gc()