huggingface / huggingface/diffusers

Make the sampling loop of pipelines modular, with designated inputs that can be handled iteratively with functions and a default sampler step function

オープン
#7,808 コメント 3 件 リアクション 2 件 担当者 0 名 GitHub で見る
stale
主要言語
Python
スター
34.5k
フォーク
7.3k
平均マージ
3日 3時間
マージ済み PR(30日)
91

説明

### Model/Pipeline/Scheduler description

Related to #7761 .

This is an effective replacement for the existing sampling loop function and the many, many kwargs that were made to allow the user to control it or inject callbacks into it.

```py
class SamplingInput:
def __init__(self, img, text_embedding, unet, timestep=None, **kwargs):
self.img = img
self.text_embedding = text_embedding
self.unet = unet
self.timestep = timestep

# ... lots of other code ...

inp = SamplingInput(img, text_embedding, unet)
with self.progress_bar(total=num_inference_steps) as progress_bar:
for i, t in enumerate(timesteps):
inp.timestep = t
for sampling_function in self.sampling_functions:
inp = sampling_function(inp)

output_img = inp.img
```

This will give the end user complete control of the sampling loop, allow the repo to add "official inline sampling functions" like report an image to an endpoint so that the user can view intermediate steps, etc.

We can add an argument sampling_functions: `list[Callable]=[default_sampling_function]` into the `__call__` as a new, backwards compatible kwarg.

This requires a rewrite of all of the pipelines, but as it is a backwards compatible change it can be introduced to any of the more popular pipelines first.

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

パイプライン内の既存の sampling ループとその __call__ エントリポイントを確認し、sampling 関連の kwargs とコールバックがどのように処理されているかを比較します。提案された例に基づいて、SamplingInput、sampling_functions、default_sampling_function のインターフェースを定義します。モジュール化されたループが互換性を保って導入され、影響を受ける主要なパイプラインが既存の動作を変更せずに更新されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
machine-learning
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。