Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Saving images didn't work for me without changes. #94

Open
nmcbride opened this issue Oct 5, 2022 · 0 comments
Open

Saving images didn't work for me without changes. #94

nmcbride opened this issue Oct 5, 2022 · 0 comments

Comments

@nmcbride
Copy link

nmcbride commented Oct 5, 2022

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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant