# StableDiffusionInpaintPipeline 'NoneType' is not iterable

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fstablediffusioninpaintpipeline-nonetype-is-not-iterable%2F152054%3E%5C
**Category:** 🧨 Diffusers\
**Created:** [April 24, 2025, 1:19am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fstablediffusioninpaintpipeline-nonetype-is-not-iterable%2F152054 "2025-04-24T01:19:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![realredowl](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/realredowl/32/46204_2.png) [@realredowl](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Frealredowl)%5C
**Post date:** [April 24, 2025, 1:19am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fstablediffusioninpaintpipeline-nonetype-is-not-iterable%2F152054%2F1 "2025-04-24T01:19:15Z")

</div>

```auto
from diffusers import StableDiffusionInpaintPipeline
import torch
from PIL import Image

# Configurazione dispositivo
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")

# Configurazione modello
model_path = "D:/ai/stable-diffusion-xl/stable-diffusion-xl-1.0-inpainting-0.1"

pipe = StableDiffusionInpaintPipeline.from_pretrained(
    model_path,
    torch_dtype=torch.float16,
    use_safetensors=True,
    variant="fp16",
    safety_checker=None
).to(device)

# Crea un'immagine vuota e una maschera per il test
init_image = Image.new("RGB", (768, 768), (255, 255, 255)) # Immagine bianca
mask = Image.new("L", (768, 768), 255) # Maschera tutta bianca (genera tutto)

# Parametri
prompt = "donna realistica che guarda la luna riflessa in uno stagno, scena notturna, atmosfera onirica"
negative_prompt = "bassa qualità, sfocato, artefatti, distorsioni"

# Test generazione senza embedding personalizzati
image = pipe(
    prompt=prompt,
    negative_prompt=negative_prompt,
    image=init_image,
    mask_image=mask,
    height=768,
    width=768,
    num_inference_steps=30,
    guidance_scale=7.5,
    generator=torch.Generator(device=device).manual_seed(42)
).images[0]
image.save("test.png")

# Libera memoria
torch.cuda.empty_cache()

```

```auto
Traceback (most recent call last):
  File "D:\ai\stable-diffusion-xl\outpaint\test.py", line 118, in <module>
    image = pipe(
  File "c:\program files\python310\lib\site-packages\torch\utils\_contextlib.py", line 116, in decorate_context
    return func(*args, **kwargs)
  File "c:\program files\python310\lib\site-packages\diffusers\pipelines\stable_diffusion\pipeline_stable_diffusion_inpaint.py", line 1384, in __call__
    noise_pred = self.unet(
  File "c:\program files\python310\lib\site-packages\torch\nn\modules\module.py", line 1739, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "c:\program files\python310\lib\site-packages\torch\nn\modules\module.py", line 1750, in _call_impl
    return forward_call(*args, **kwargs)
  File "c:\program files\python310\lib\site-packages\diffusers\models\unets\unet_2d_condition.py", line 1145, in forward
    aug_emb = self.get_aug_embed(
  File "c:\program files\python310\lib\site-packages\diffusers\models\unets\unet_2d_condition.py", line 966, in get_aug_embed
    if "text_embeds" not in added_cond_kwargs:
TypeError: argument of type 'NoneType' is not iterable

```

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FJohn6666)%5C
**Post date:** [April 24, 2025, 4:17am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fstablediffusioninpaintpipeline-nonetype-is-not-iterable%2F152054%2F2 "2025-04-24T04:17:44Z")

</div>

It seems to be a more complicated issue than expected.

> <https://github.com/huggingface/diffusers/issues/4649>
>
> \### Describe the bug
> 
> \`\`\`
> if "text\_embeds" not in added\_cond\_kwargs:
> TypeError…: argument of type 'NoneType' is not iterable
> \`\`\`
> I think I'm getting this error if I feed an image or a video which differs in resolution with the resolution a model was trained on, but I'm not sure exactly what is causing it. Maybe this description and solution might be a faster way to locate that bug: https://stackoverflow.com/questions/76707159/diffusers-sdxl-typeerror-argument-of-type-nonetype-is-not-iterable
> 
> \### Reproduction
> 
> There is code linked here for reproduction: 
> https://stackoverflow.com/questions/76707159/diffusers-sdxl-typeerror-argument-of-type-nonetype-is-not-iterable
> 
> \### Logs
> 
> \`\`\`shell
> My log: 
> Traceback (most recent call last):
> File "C:\\Users\\45239\\AppData\\Roaming\\Blender Foundation\\Blender\\3.5\\scripts\\addons\\Generative\_AI-main\\\_\_init\_\_.py", line 1224, in execute
> video\_frames = upscale(
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\torch\\utils\\\_contextlib.py", line 115, in decorate\_context
> return func(\*args, \*\*kwargs)
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\diffusers\\pipelines\\text\_to\_video\_synthesis\\pipeline\_text\_to\_video\_synth\_img2img.py", line 670, in \_\_call\_\_
> noise\_pred = self.unet(
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\torch\\nn\\modules\\module.py", line 1501, in \_call\_impl
> return forward\_call(\*args, \*\*kwargs)
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\accelerate\\hooks.py", line 165, in new\_forward
> output = old\_forward(\*args, \*\*kwargs)
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\diffusers\\models\\unet\_2d\_condition.py", line 840, in forward
> if "text\_embeds" not in added\_cond\_kwargs:
> TypeError: argument of type 'NoneType' is not iterable
> Error: Python: Traceback (most recent call last):
> File "C:\\Users\\45239\\AppData\\Roaming\\Blender Foundation\\Blender\\3.5\\scripts\\addons\\Generative\_AI-main\\\_\_init\_\_.py", line 1224, in execute
> video\_frames = upscale(
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\torch\\utils\\\_contextlib.py", line 115, in decorate\_context
> return func(\*args, \*\*kwargs)
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\diffusers\\pipelines\\text\_to\_video\_synthesis\\pipeline\_text\_to\_video\_synth\_img2img.py", line 670, in \_\_call\_\_
> noise\_pred = self.unet(
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\torch\\nn\\modules\\module.py", line 1501, in \_call\_impl
> return forward\_call(\*args, \*\*kwargs)
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\accelerate\\hooks.py", line 165, in new\_forward
> output = old\_forward(\*args, \*\*kwargs)
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\diffusers\\models\\uneTraceback (most recent call last):
> File "C:\\Users\\45239\\AppData\\Roaming\\Blender Foundation\\Blender\\3.5\\scripts\\addons\\Generative\_AI-main\\\_\_init\_\_.py", line 1962, in execute
> sequencer.generate\_movie()
> File "C:\\Program Files\\Blender Foundation\\Blender 3.5\\3.5\\scripts\\modules\\bpy\\ops.py", line 113, in \_\_call\_\_
> ret = \_op\_call(self.idname\_py(), None, kw)
> RuntimeError: Error: Python: Traceback (most recent call last):
> File "C:\\Users\\45239\\AppData\\Roaming\\Blender Foundation\\Blender\\3.5\\scripts\\addons\\Generative\_AI-main\\\_\_init\_\_.py", line 1224, in execute
> video\_frames = upscale(
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\torch\\utils\\\_contextlib.py", line 115, in decorate\_context
> return func(\*args, \*\*kwargs)
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\diffusers\\pipelines\\text\_to\_video\_synthesis\\pipeline\_text\_to\_video\_synth\_img2img.py", line 670, in \_\_call\_\_
> noise\_pred = self.unet(
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\torch\\nn\\modules\\module.py", line 1501, in \_call\_impl
> return forward\_call(\*args, \*\*kwargs)
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\accelerate\\hooks.py", line 165, in new\_forward
> output = old\_forward(\*args, \*\*kwargs)
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\diffusers\\models\\unet\_2d\_condition.py", line 840, in forward
> if "text\_embeds" not in added\_cond\_kwargs:
> TypeError: argument of type 'NoneType' is not iterable
> Location: C:\\Program Files\\Blender Foundation\\Blender 3.5\\3.5\\scripts\\modules\\bpy\\ops.py:113
> 
> Error: Python: Traceback (most recent call last):
> File "C:\\Users\\45239\\AppData\\Roaming\\Blender Foundation\\Blender\\3.5\\scripts\\addons\\Generative\_AI-main\\\_\_init\_\_.py", line 1962, in execute
> sequencer.generate\_movie()
> File "C:\\Program Files\\Blender Foundation\\Blender 3.5\\3.5\\scripts\\modules\\bpy\\ops.py", line 113, in \_\_call\_\_
> ret = \_op\_call(self.idname\_py(), None, kw)
> RuntimeError: Error: Python: Traceback (most recent call last):
> File "C:\\Users\\45239\\AppData\\Roaming\\Blender Foundation\\Blender\\3.5\\scripts\\addons\\Generative\_AI-main\\\_\_init\_\_.py", line 1224, in execute
> video\_frames = upscale(
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\torch\\utils\\\_contextlib.py", line 115, in decorate\_context
> return func(\*args, \*\*kwargs)
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\diffusers\\pipelines\\text\_to\_video\_synthesis\\pipeline\_text\_to\_video\_synth\_img2img.py", line 670, in \_\_call\_\_
> noise\_pred = self.unet(
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\torch\\nn\\modules\\module.py", line 1501, in \_call\_impl
> return forward\_call(\*args, \*\*kwargs)
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\accelerate\\hooks.py", line 165, in new\_forward
> output = old\_forward(\*args, \*\*kwargs)
> File "C:\\Users\\45239\\AppData\\Roaming\\Python\\Python310\\site-packages\\diffusers\\models\\unet\_2d\_condition.py", line 840, in forward
> if "text\_embeds" not in added\_cond\_kwargs:
> TypeError: argument of type 'NoneType' is not iterable
> Location: C:\\Program Files\\Blender Foundation\\Blender 3.5\\3.5\\scripts\\modules\\bpy\\ops.py:113
> \`\`\`
> 
> 
> \### System Info
> 
> Win 11
> Diffusers 19.3
> 
> \### Who can help?
> 
> \_No response\_

> <https://github.com/huggingface/diffusers/issues/5471>
>
> \### Describe the bug
> 
> Hello,
> 
> I am trying to utilize the UNet2DConditionModel …from diffusers and when I pass the parameters needed it throws an error. From my understanding StabilityAI uses the same unet for "stabilityai/stable-diffusion-2-inpainting" and when I call the UNet2DConditionModel using the equivalent code it works.
> Does it make any difference if I am using SDXL or SD2in this scenario? But even if it doesnt matter, why does it raises the error?
> 
> Thank you in advance!
> 
> \### Reproduction
> 
> inpaint\_unet = UNet2DConditionModel.from\_pretrained("diffusers/stable-diffusion-xl-1.0-inpainting-0.1",
> subfolder="unet", 
> use\_auth\_token=token).to('cuda')
> 
> latent\_model\_input\_inpaint = torch.rand(\[2, 9, 64, 64\])
> t = torch.Tensor(\[781\])
> encoder\_hidden\_states = torch.rand(\[2, 77, 1024\])
> 
> output\_xl = inpaint\_unet(latent\_model\_input\_inpaint, t, encoder\_hidden\_states)
> 
> \### Logs
> 
> \`\`\`shell
> 873 aug\_emb = self.add\_embedding(text\_embs, image\_embs)
> 874 elif self.config.addition\_embed\_type == "text\_time":
> 875 # SDXL - style
> \--\> 876 if "text\_embeds" not in added\_cond\_kwargs:
> 877 raise ValueError(
> 878 f"{self.\_\_class\_\_} has the config param \`addition\_embed\_type\` set to 'text\_time' which requires the keyword argument \`text\_embeds\` to be passed in \`added\_cond\_kwargs\`"
> 879 )
> 880 text\_embeds = added\_cond\_kwargs.get("text\_embeds")
> 
> TypeError: argument of type 'NoneType' is not iterable
> \`\`\`
> 
> 
> \### System Info
> 
> diffusers: 0.21.4
> python:: 3.10
> sagemaker
> 
> \### Who can help?
> 
> @yiyixuxu @sayakpaul @DN6 @patrickvonplaten @DN6 @yiyixuxu @sayakpaul @patrickvonplaten

And / or maybe you need SDXL instead of SD.

```py
#from diffusers import StableDiffusionInpaintPipeline
from diffusers import StableDiffusionXLInpaintPipeline

#pipe = StableDiffusionInpaintPipeline.from_pretrained(
pipe = StableDiffusionXLInpaintPipeline.from_pretrained(

model_path = "D:/ai/stable-diffusion-xl/stable-diffusion-xl-1.0-inpainting-0.1" # <= SDXL

#pipe = StableDiffusionInpaintPipeline.from_pretrained(
pipe = StableDiffusionXLInpaintPipeline.from_pretrained(

```
