Merge pull request #1187 from cheald/enable-batch-preview

When running a batch with preview turned on, produce a grid of previe…
This commit is contained in:
ZeroCool 2022-09-16 16:27:43 -07:00 committed by GitHub
commit ac99b657d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -809,7 +809,11 @@ def generation_callback(img, i=0):
x_samples_ddim = torch.clamp((x_samples_ddim + 1.0) / 2.0, min=0.0, max=1.0)
pil_image = transforms.ToPILImage()(x_samples_ddim.squeeze_(0))
if x_samples_ddim.ndimension() == 4:
pil_images = [transforms.ToPILImage()(x.squeeze_(0)) for x in x_samples_ddim]
pil_image = image_grid(pil_images, 1)
else:
pil_image = transforms.ToPILImage()(x_samples_ddim.squeeze_(0))
# update image on the UI so we can see the progress
st.session_state["preview_image"].image(pil_image)