Buckets:
DDIM
Jiaming Song、Chenlin Meng、Stefano Ermon による Denoising Diffusion Implicit Models (DDIM)。
論文の抄録は以下の通りです:
デノイジング拡散確率モデル(DDPM)は、敵対的学習なしで高品質な画像生成を実現していますが、サンプルを生成するには多くのステップでマルコフ連鎖をシミュレートする必要があります。サンプリングを高速化するために、DDPMと同じ訓練手順を持つ、より効率的な反復型暗黙的確率モデルのクラスであるデノイジング拡散暗黙的モデル(DDIM)を提案します。DDPMでは、生成過程はマルコフ拡散過程の逆過程として定義されます。我々は、同じ訓練目的関数に導く非マルコフ拡散過程のクラスを構築し、その逆過程からのサンプリングを大幅に高速化します。実験により、DDIMはDDPMと比較して実時間ベースで10倍から50倍高速に高品質なサンプルを生成でき、計算量とサンプル品質のトレードオフが可能であり、潜在空間内で意味のある画像補間を直接実行できることを示しました。
元のコードベースはermongroup/ddimで確認できます。
DDIMPipeline[[diffusers.DDIMPipeline]]
diffusers.DDIMPipeline[[diffusers.DDIMPipeline]]
diffusers.DDIMPipeline(unet: UNet2DModel, scheduler: DDIMScheduler)
パラメータ:
unet (UNet2DModel) : エンコードされた画像の潜在変数をノイズ除去するためのUNet2DModel。
scheduler (SchedulerMixin) : unet と組み合わせて、エンコードされた画像のノイズ除去に使用するスケジューラ。DDPMScheduler または DDIMScheduler のいずれかです。
画像生成用のPipeline。
このモデルは DiffusionPipeline を継承しています。すべてのパイプラインに実装されている汎用的なメソッド(ダウンロード、保存、特定のデバイスでの実行など)については、スーパークラスのドキュメントを参照してください。
call[[diffusers.DDIMPipeline.call]]
__call__(batch_size: int = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, eta: float = 0.0, num_inference_steps: int = 50, use_clipped_model_output: bool | None = None, output_type: str | None = 'pil', return_dict: bool = True)
パラメータ:
batch_size (int、任意、デフォルトは 1) : 生成する画像の数。
generator (torch.Generator, 任意) : 生成を決定論的にするための torch.Generator。
eta (float、任意、デフォルト値は 0.0) : DDIM論文のパラメータ eta (η) に相当します。DDIMSchedulerでのみ適用され、他のスケジューラーでは無視されます。0は DDIM に、1は DDPM に相当します。
num_inference_steps (int、任意、デフォルト値は 50) : デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。
use_clipped_model_output (bool、任意、デフォルトは None) : True または False の場合、DDIMScheduler.step() のドキュメントを参照してください。None の場合、スケジューラに何も渡されません(この引数をサポートしないスケジューラには None を使用してください)。
output_type (str、任意、デフォルトは"pil") : 生成された画像の出力形式。"pil" (PIL.Image)、"np" (np.array)、または"pt" (torch.Tensor) から選択します。
return_dict (bool、任意、デフォルトはTrue) : プレーンなタプルではなく、ImagePipelineOutputを返すかどうか。
戻り値: ImagePipelineOutput または tuple
return_dict が True の場合、ImagePipelineOutput が返され、それ以外の場合は、最初の要素が生成された画像のリストである tuple が返されます。
生成用の pipeline への呼び出し関数。
例:
>>> from diffusers import DDIMPipeline
>>> import PIL.Image
>>> import numpy as np
>>> # load model and scheduler
>>> pipe = DDIMPipeline.from_pretrained("fusing/ddim-lsun-bedroom")
>>> # run pipeline in inference (sample random noise and denoise)
>>> image = pipe(eta=0.0, num_inference_steps=50)
>>> # process image to PIL
>>> image_processed = image.cpu().permute(0, 2, 3, 1)
>>> image_processed = (image_processed + 1.0) * 127.5
>>> image_processed = image_processed.numpy().astype(np.uint8)
>>> image_pil = PIL.Image.fromarray(image_processed[0])
>>> # save image
>>> image_pil.save("test.png")
ImagePipelineOutput[[diffusers.ImagePipelineOutput]]
diffusers.ImagePipelineOutput[[diffusers.ImagePipelineOutput]]
diffusers.ImagePipelineOutput(images: list[PIL.Image.Image] | numpy.ndarray)
パラメータ:
images (List[PIL.Image.Image] または np.ndarray) : 長さ batch_size のデノイズ済み PIL 画像のリスト、または形状 (batch_size, height, width, num_channels) の NumPy 配列。
画像パイプライン用の出力クラス。
Xet Storage Details
- Size:
- 6.65 kB
- Xet hash:
- d8ee171718f5bcd1f1869a91265c5b0665f522afcecb30017c3b34dcee6fed22
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.