huggingface / huggingface/diffusers
Potential incorrect reshaping in 2D positional embedding
- 主要言語
- Python
- スター
- 34.5k
- フォーク
- 7.3k
- 平均マージ
- 3日 3時間
- マージ済み PR(30日)
- 91
説明
### 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
コントリビューションガイド
調査の方向性
src/diffusers/models/embeddings.py の、280 行目付近のグリッド構築と 549 行目付近の PatchEmbed 実装から始めてください。高さと幅が異なる場合の BCHW から B(H*W)C へのフラット化と位置グリッドの順序を比較し、その順序が一致しているか確認して、一致していない場合は回帰テストまたは修正を追加してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python, pytorch
- 領域
- machine-learning
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 35/100