diffusers icon indicating copy to clipboard operation
diffusers copied to clipboard

Add error-checking branch to catch lists of non-tensors being passed as `ip_adapter_image_embeds`

Open beyarkay opened this issue 1 year ago • 0 comments

What does this PR do?

This PR just adds an extra branch to the parameter checking (in self.check_inputs) which makes sure that the value being passed in as ip_adapter_image_embeds is indeed a list of items which have a ndim attribute. I mistakenly passed in a list of strings and got hit with:

  File "/Users/brk/projects/quick-ideas/.venv/lib/python3.10/site-packages/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py", line 681, in check_inputs
    elif ip_adapter_image_embeds[0].ndim not in [3, 4]:
AttributeError: 'str' object has no attribute 'ndim'

Which took looking into the source code to figure out. After this commit, the error is:

  File "/Users/brk/projects/quick-ideas/.venv/lib/python3.10/site-packages/diffusers/pipelines/stable_diffusion_xl/pipeline_stable_diffusion_xl.py", line 682, in check_inputs
    raise ValueError(
ValueError: `ip_adapter_image_embeds` must be a list of tensors, but is a list of <class 'str'>

Before submitting

  • [ ] This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • [x] Did you read the contributor guideline?
  • [x] Did you read our philosophy doc (important for complex PRs)?
  • [ ] Was this discussed/approved via a GitHub issue or the forum? Please add a link to it if that's the case.
  • [ ] Did you make sure to update the documentation with your changes? Here are the documentation guidelines, and here are tips on formatting docstrings.
  • [x] Did you write any new necessary tests?

Who can review?

Anyone in the community is free to review the PR once the tests have passed. Feel free to tag members/contributors who may be interested in your PR.

(tagging because pipelines: @sayakpaul @yiyixuxu)

beyarkay avatar Apr 23 '24 16:04 beyarkay