I've been playing around with stable diffusion on Google colab, and I've been having some trouble getting a grid to work. Every time I run my image generator block, it gets through the generation but can't display the images, it gives me the error stated in the title.
def image_grid(imgs, rows, cols):
assert len(imgs) == rows*cols
w, h = imgs[0].size
grid = Image.new('RGB', size=(cols*w, rows*h))
grid_w, grid_h = grid.size
for i, img in enumerate(imgs):
grid.paste(img, box=(i%cols*w, i//cols*h))
return grid
This runs fine, but this next part is what screws me over.
from torch import autocast
num_images = 4
prompt = ["Astronaut riding a horse"] * num_images
with autocast("cuda"):
images = pipe(prompt, width=512, height=512, num_inference_steps=10)["sample"]
grid = image_grid(images, rows=2, cols=2)
grid
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-30-ec9ce225f081> in <module>
16 images = pipe(prompt, width=512, height=512, num_inference_steps=10)["sample"]
17
---> 18 grid = image_grid(images, rows=2, cols=2)
19 grid
<ipython-input-28-2e81f9e2985a> in image_grid(imgs, rows, cols)
10 for i, img in enumerate(imgs):
11 grid.paste(img, box=(i%cols*w, i//cols*h))
---> 12 return grid()
TypeError: 'Image' object is not callable