Diffusers documentation

無条件画像生成

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.42.1).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

無条件画像生成

無条件画像生成では、テキストや画像などの追加のコンテキストによるガイドがないため、デノイジングプロセスがモデルの学習に使用されたトレーニングデータからのランダムなサンプルに似た画像を生成します。

まずはじめに、DiffusionPipeline を使用して anton-l/ddpm-butterflies-128 チェックポイントをロードし、蝶の画像を生成します。DiffusionPipeline は、画像生成に必要なすべてのモデルコンポーネントをダウンロードしてキャッシュします。

from diffusers import DiffusionPipeline

generator = DiffusionPipeline.from_pretrained("anton-l/ddpm-butterflies-128").to("cuda")  # or "mps", "xpu", "cpu"
image = generator().images[0]
image

別のものの画像を生成したい場合は、ガイドを参照して、独自の画像を生成するモデルの学習方法について学びましょう。

出力画像は、保存可能なPIL.Imageオブジェクトです。

image.save("generated_image.png")

num_inference_steps パラメータを調整して実験することもできます。このパラメータは、デノイジングのステップ数を制御します。デノイジングのステップ数が多いほど、通常はより高品質な画像が生成されますが、生成に時間がかかります。画像品質への影響を確認するために、このパラメータを自由に調整してみてください。

image = generator(num_inference_steps=100).images[0]
image

下のSpaceを試して、蝶の画像を生成してみてください!

Update on GitHub