Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/diffusers/image_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def is_valid_image(image) -> bool:
`bool`:
`True` if the input is a valid image, `False` otherwise.
"""
return isinstance(image, PIL.Image.Image) or isinstance(image, (np.ndarray, torch.Tensor)) and image.ndim in (2, 3)
Copy link
Collaborator

@yiyixuxu yiyixuxu Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but if it is a PIL.Image, isinstance(image, PIL.Image.Image) will evaluate to True and whole thing will just return True without check the dimension , no?
can you show an example that this fails?

isinstance(image, PIL.Image.Image) or isinstance(image, (np.ndarray, torch.Tensor)) and image.ndim in (2, 3)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's true... I tried it locally and you were right.
I seem to have misunderstood the cause and made a false assumption. I will withdraw the PR. I apologize.

return (isinstance(image, (np.ndarray, torch.Tensor)) and image.ndim in (2, 3)) or isinstance(image, PIL.Image.Image)


def is_valid_image_imagelist(images):
Expand Down