Skip to content

Stable Diffusion img2img Pipeline does not check image type #1872

@tsunrise

Description

@tsunrise

It would be better if img2img pipeline checks if the type of image is valid. Currently, this pipeline only supports tensor, PIL.Image, or a list of PIL.Image, but this type check is missing in https://github.com/huggingface/diffusers/blob/62608a9102e423ad0fe79f12a8ceb1710d2027b2/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_img2img.py#LL378C10-L378C10

As a result, if the user gives incorrectly typed image (for example, an numpy array), some unhelpful message will appear such as

 File "path\to\diffusers\pipelines\stable_diffusion\pipeline_stable_diffusion_img2img.py", line 403, in prepare_latents
    image = image.to(device=device, dtype=dtype)
AttributeError: 'numpy.ndarray' object has no attribute 'to'

We can also add this check in

as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions