Saving images didn't work for me without changes.
nmcbride opened this issue · comments
Nathan McBride commented
I'm not really sure as to what is going on, but I'm also a bit new to this.
Since I got stuck for a bit I thought I'd post here in case someone else gets stuck also.
So while trying to save images, it was not working. I was just getting an error: TypeError: Cannot handle this data type: (1, 1, 3), <f4
.
I was following the instructions and did things like this:
images = model.generate_images(
text='Nuclear explosion broccoli',
seed=-1,
grid_size=3,
is_seamless=False,
temperature=1,
top_k=256,
supercondition_factor=16,
is_verbose=False
)
images = images.to('cpu').numpy()
for i, _ in enumerate(images):
img = Image.fromarray(images[i])
img.save('image_{}.png'.format(i))
TypeError: Cannot handle this data type: (1, 1, 3), <f4
To get this to work I had to do:
for i, _ in enumerate(images):
img = Image.fromarray(images[i].astype(np.uint8))
img.save('image_{}.png'.format(i))