Skip to content

KeyError: 'sample' #889

@ProgramerSalar

Description

@ProgramerSalar

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions