huggingface / huggingface/diffusers

RuntimeError: torch.cat(): expected a non-empty list of Tensors

Abierto
#8,826 6 comentarios 0 reacciones 0 asignados Ver en GitHub
bug stale
Lenguaje dominante
Python
Estrellas
34.5k
Forks
7.3k
Merge medio
3 d 3 h
PR fusionados (30 d)
91

Descripción

### Describe the bug

**Problem:**
When the "officially provided" example (see https://github.com/huggingface/diffusers/blob/a785992c1d6fcb1ff66f8a0d68d09a0a81b909e8/src/diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion.py#L34) is executed, the error occurs.

**Expected behaviour:**
The example should work without any error.

### Reproduction

**The Code:**
~~~
import torch
from diffusers import LEditsPPPipelineStableDiffusion
from diffusers.utils import load_image

if __name__ == "__main__":
pipe = LEditsPPPipelineStableDiffusion.from_pretrained(
"runwayml/stable-diffusion-v1-5",
torch_dtype=torch.float16)
pipe = pipe.to("mps")
img_url = "https://www.aiml.informatik.tu-darmstadt.de/people/mbrack/cherry_blossom.png"
image = load_image(img_url).convert("RGB")

_ = pipe.invert(image=image, num_inversion_steps=50, skip=0.1)
edited_image = pipe(
editing_prompt=["cherry blossom"],
edit_guidance_scale=10.0,
edit_threshold=0.75).images[0]
~~~

**The Error:**
~~~
Traceback (most recent call last):
File "/Users/burakbayrak/folder-to-del/leditsplusplus_example.py", line 16, in
edited_image = pipe(
^^^^^
File "/Users/burakbayrak/anaconda3/envs/ledits-plus-plus/lib/python3.11/site-packages/torch/utils/_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "/Users/burakbayrak/anaconda3/envs/ledits-plus-plus/lib/python3.11/site-packages/diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion.py", line 1010, in __call__
out = self.attention_store.aggregate_attention(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/burakbayrak/anaconda3/envs/ledits-plus-plus/lib/python3.11/site-packages/diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion.py", line 128, in aggregate_attention
out = torch.stack([torch.cat(x, dim=0) for x in out])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/burakbayrak/anaconda3/envs/ledits-plus-plus/lib/python3.11/site-packages/diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion.py", line 128, in
out = torch.stack([torch.cat(x, dim=0) for x in out])
^^^^^^^^^^^^^^^^^^^
RuntimeError: torch.cat(): expected a non-empty list of Tensors

~~~

### Logs

_No response_

### System Info

- 🤗 Diffusers version: 0.29.2
- Platform: macOS-14.5-arm64-arm-64bit
- Running on a notebook?: No
- Running on Google Colab?: No
- Python version: 3.11.9
- PyTorch version (GPU?): 2.3.1 (False)
- Flax version (CPU?/GPU?/TPU?): not installed (NA)
- Jax version: not installed
- JaxLib version: not installed
- Huggingface_hub version: 0.23.4
- Transformers version: 4.42.3
- Accelerate version: 0.32.1
- PEFT version: not installed
- Bitsandbytes version: not installed
- Safetensors version: 0.4.3
- xFormers version: not installed
- Accelerator: Apple M2
- Using GPU in script?: True
- Using distributed or parallel set-up in script?: False

### Who can help?

@yiyixuxu

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza con src/diffusers/pipelines/ledits_pp/pipeline_leditspp_stable_diffusion.py, especialmente con aggregate_attention y la ruta __call__ mostrada en el traceback. Ejecuta la reproducción proporcionada de LEdits++ en el entorno indicado y verifica que el ejemplo oficial se complete sin el error de lista vacía de torch.cat.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python, pytorch
Área
machine-learning
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.