“Diffusers SDXL” 错误类型:”TypeError: argument of type ‘NoneType’ is not iterable”

huangapple go评论121阅读模式
英文:

Diffusers SDXL "TypeError: argument of type 'NoneType' is not iterable"

问题

刚刚获得了SDXL模型的访问权限,希望测试它以备将来发布...不幸的是,我们目前用于我们的服务的代码似乎与stabilityai/stable-diffusion-xl-base-0.9不兼容,我不太确定SDXL有何不同以及我需要做哪些更改。

我们正在使用不同的管道来生成图像的预览,所以这不是SDXL模型自述文件中提供的典型模板。
错误似乎发生在unet_2d_condition.py(在diffusers库中)

Traceback (most recent call last):
  File "C:\Users\myalt\Desktop\testing image grid\main.py", line 159, in <module>
    socker_listener.generate_image()
  File "C:\Users\myalt\Desktop\testing image grid\main.py", line 154, in generate_image
    foo = self.blocking_code()
  File "C:\Users\myalt\Desktop\testing image grid\main.py", line 109, in blocking_code
    noise_pred = self.unet(latent_model_input, t,
  File "C:\Users\myalt\Desktop\testing image grid\venv\lib\site-packages\torch\nn\modules\module.py", line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Users\myalt\Desktop\testing image grid\venv\lib\site-packages\diffusers\models\unet_2d_condition.py", line 839, in forward
    if "text_embeds" not in added_cond_kwargs:
TypeError: argument of type 'NoneType' is not iterable

我已经升级到diffusers==0.18.2

以下是一个示例代码,它生成了大量图像并将它们放入网格中,使用了一个自定义管道
https://hatebin.com/tqppqfsehk

英文:

Just got access to SDXL model, looking to test it for its upcoming release... Unfortunately, the code we currently use for our service seems to not work with stabilityai/stable-diffusion-xl-base-0.9, and I'm not entirely sure what is different with SDXL and what I need to change.

We are using a different pipeline so we can generate previews of the images, so its not the typical template that is provided on the SDXL model readme.
The error seems to be happening in unet_2d_condition.py (in diffusers lib)

Traceback (most recent call last):
  File &quot;C:\Users\myalt\Desktop\testing image grid\main.py&quot;, line 159, in &lt;module&gt;
    socker_listener.generate_image()
  File &quot;C:\Users\myalt\Desktop\testing image grid\main.py&quot;, line 154, in generate_image
    foo = self.blocking_code()
  File &quot;C:\Users\myalt\Desktop\testing image grid\main.py&quot;, line 109, in blocking_code
    noise_pred = self.unet(latent_model_input, t,
  File &quot;C:\Users\myalt\Desktop\testing image grid\venv\lib\site-packages\torch\nn\modules\module.py&quot;, line 1501, in _call_impl
    return forward_call(*args, **kwargs)
  File &quot;C:\Users\myalt\Desktop\testing image grid\venv\lib\site-packages\diffusers\models\unet_2d_condition.py&quot;, line 839, in forward
    if &quot;text_embeds&quot; not in added_cond_kwargs:
TypeError: argument of type &#39;NoneType&#39; is not iterable

I've updated to diffusers==0.18.2.

Here is a example code which makes a bunch of images and puts them into a grid, using this a custom pipeline
https://hatebin.com/tqppqfsehk

答案1

得分: 1

有趣的是,这似乎是扩散器中的一个错误。 added_cond_kwargs 被指定为可选的,并且函数签名明确将其默认为 None。但是,随后的代码没有检查 None 情况,将其视为字典。如果还没有报告,值得向 diffusers 提交一个问题。他们可能可以通过将 added_cond_kwargs 设置为 {} 来修复它,如果它被传递为 None 的话。

与此同时,您可以通过明确传递 added_cond_kwargs={} 给 unet 函数来解决此问题。

英文:

Interesting, this looks like a bug in diffusers. added_cond_kwargs is specified as being optional, and the function signature explicitly defaults it to None. However, the subsequent code does not check for the None case, treating it as if it is a dictionary. It's worth filing an issue with diffusers if it hasn't already been reported. They can probably fix it by simply setting added_cond_kwargs to {} if it's passed as None.

In the meantime, you should be able to work around this by explicitly passing added_cond_kwargs={} to the unet function.

答案2

得分: 1

我假设你正在使用StableDiffusionPipeline。尝试使用StableDiffusionXLPipeline代替。这应该解决你的问题。

https://huggingface.co/docs/diffusers/v0.20.0/en/api/pipelines/stable_diffusion/stable_diffusion_xl#diffusers.StableDiffusionXLPipeline

英文:

I'm assuming you're using the StableDiffusionPipeline. Try using the StableDiffusionXLPipeline instead. This should solve your issue.

https://huggingface.co/docs/diffusers/v0.20.0/en/api/pipelines/stable_diffusion/stable_diffusion_xl#diffusers.StableDiffusionXLPipeline

huangapple
  • 本文由 发表于 2023年7月18日 02:23:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/76707159.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定