huggingface / huggingface/diffusers
Potential incorrect reshaping in 2D positional embedding
- 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
Hi there,
I have concerns with this line of code (https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/embeddings.py#L282).
Specifically, `grid_size` is the tuple consisting of the height `H` and width `W` of the image. `grid` computed in L280 should have the shape `2*H*W`, and L282 reshapes it into `2*1*W*H`. The dimensions `W*H` will be later flattened to match the dimensions of the latent.
However, if you continue to `PatchEmbed` (https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/embeddings.py#L549), you will notice that the latent with shape `BCHW` is flattened into `B(H*W)C`, this flattening operation does not seem to match with `grid` in L282. I think this reordering will mess up the ordering of dimensions when being flattened in case `H` and `W` are not equal.
### Reproduction
This potential bug is conceptual and no need for reproduction.
### Logs
```shell
```
### System Info
Current `diffusers` implementation.
### Who can help?
@yiyixuxu @sayakpaul
Guía de contribución
Línea de trabajo
Comienza en src/diffusers/models/embeddings.py, en la construcción de la cuadrícula alrededor de la línea 280 y en la implementación de PatchEmbed alrededor de la línea 549. Compara el orden de la cuadrícula posicional con el aplanado de BCHW a B(H*W)C para alturas y anchuras desiguales; después, confirma si el orden coincide y añade una prueba de regresión o una corrección si no es así.
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
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100