KeyError: 'sample'

#11
by ProgramerSalar - opened

if you get this error

File "<stdin>", line 2, in <module>
  File "/usr/local/lib/python3.11/dist-packages/diffusers/utils/outputs.py", line 110, in __getitem__
    return inner_dict[k]
           ~~~~~~~~~~^^^
KeyError: 'sample'

then
you should modify the image pipe

##Before

with autocast("cuda"):
...     image = pipe(prompt)["sample"][0]  

##After

with autocast("cuda"):
...     image = pipe(prompt)[0]  
...     image[0].save("astronaut_rides_horse.png")

Note: before image pipe have the sample in the string format but in the after code i will remove

Your need to confirm your account before you can post a new comment.

Sign up or log in to comment