huggingface / huggingface/diffusers

Potential incorrect reshaping in 2D positional embedding

Aperta
#11,309 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
bug stale
Lingua principale
Python
Stelle
34.5k
Fork
7.3k
Merge medio
3g 3h
PR unite (30g)
91

Descrizione

### 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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Inizia in src/diffusers/models/embeddings.py, nella costruzione della griglia intorno alla riga 280 e nell’implementazione di PatchEmbed intorno alla riga 549. Confronta l’ordinamento della griglia posizionale con l’appiattimento da BCHW a B(H*W)C per altezza e larghezza diverse, quindi verifica se l’ordinamento corrisponde e aggiungi un test di regressione o una correzione se non corrisponde.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python, pytorch
Ambito
machine-learning
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.