happylittlecat2333 / Auffusion

Official codes and models of the paper "Auffusion: Leveraging the Power of Diffusion and Large Language Models for Text-to-Audio Generation"
https://auffusion.github.io/
Other
160 stars 13 forks source link

`AttributeError: 'NoneType' object has no attribute 'shape'` when giving negative_prompt #8

Closed lingchuL closed 8 months ago

lingchuL commented 8 months ago

Thanks for this great work Auffusion! I opened a PR for this issue. Be free to merge it or resolve it more officially in your ways.

Copied from PR: For now when giving negative_prompt to pipeline, an error would be raised:

Traceback (most recent call last): File "D:\path\Auffusion\test.py", line 8, in output = pipeline(prompt=prompt, negative_prompt="Low quality, average quality.") File "D:\path\Auffusion\venv\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "D:\path\Auffusion\auffusion_pipeline.py", line 934, in call prompt_embeds = self._encode_prompt( File "D:\path\Auffusion\auffusion_pipeline.py", line 757, in _encode_prompt seq_len = negative_prompt_embeds.shape[1] AttributeError: 'NoneType' object has no attribute 'shape' It seems like the negative_prompt_embeds hasn't been inited when elif isinstance(negative_prompt, str) in auffusion_pipeline.py:

... if negative_prompt is None: negative_prompt_embeds = torch.zeros_like(prompt_embeds).to(dtype=prompt_embeds.dtype, device=device) elif isinstance(negative_prompt, str): negative_prompt = [negative_prompt]

negative_prompt_embeds remains None here.

... else: negative_prompt_embeds = get_prompt_embeds(negative_prompt, device)

happylittlecat2333 commented 8 months ago

Thanks for your inspection and PR!