SusungHong / Self-Attention-Guidance

The implementation of the paper "Improving Sample Quality of Diffusion Models Using Self-Attention Guidance" (ICCV`23)
MIT License
105 stars 14 forks source link

TypeError: argument of type 'NoneType' is not iterable #5

Closed xinli2008 closed 10 months ago

xinli2008 commented 11 months ago

nice job! And i try to use the SAG as follows: ` from diffusers import DiffusionPipeline,StableDiffusionSAGPipeline

pipe = StableDiffusionSAGPipeline.from_pretrained("/mnt/xxx/result_diffusers", torch_dtype=torch.float16, use_safetensors=True, variant="bf16") pipe.to("cuda:0")

positive_prompt = 'sl_1234, man, long hair, wearing red sweater'

negative_prompt = 'text, worst quality'

image = pipe( positive_prompt, negative_prompt=negative_prompt, num_inference_steps=50, guidance_scale=7.5, num_images_per_prompt=batch_size, sag_scale=1.0 ).images ` the error is : File "demo.py", line 49, in image = pipe( File "/usr/local/lib/python3.8/dist-packages/torch/utils/_contextlib.py", line 115, in decorate_context return func(*args, *kwargs) File "/usr/local/lib/python3.8/dist-packages/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_sag.py", line 653, in call noise_pred = self.unet( File "/usr/local/lib/python3.8/dist-packages/torch/nn/modules/module.py", line 1501, in _call_impl return forward_call(args, **kwargs) File "/usr/local/lib/python3.8/dist-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

can you give me some advice? @SusungHong

deltheil commented 11 months ago

IIUC you are trying to use SAG with SDXL. But SDXL's UNet takes as input extra args (see here) and StableDiffusionSAGPipeline has not been expanded yet to support XL models (which is why you get this error: see here: the extra args are not passed to the UNet).

--

In the meanwhile you can test SAG with SDXL using Refiners (x) => I put some instructions here.

Hope that helps!

(x): an open source, PyTorch-based framework made to easily train and run adapters on top of foundational models. See also #4

xinli2008 commented 11 months ago

thank you very much, i will try that.