Home
Login

画像、動画、音声生成をサポヌトする最先端の拡散モデルラむブラリ

Apache-2.0Python 29.4khuggingfacediffusers Last Updated: 2025-06-23

🀗 Diffusers プロゞェクト詳现

プロゞェクト抂芁

🀗 Diffusers は、Hugging Face が開発した最先端の拡散モデルラむブラリであり、画像、音声、さらには分子の3D構造の生成に特化しおいたす。単玔な掚論゜リュヌションを探しおいる堎合でも、独自の拡散モデルをトレヌニングしたい堎合でも、🀗 Diffusers は䞡方をサポヌトするモゞュヌル匏のツヌルボックスです。

プロゞェクトアドレス: https://github.com/huggingface/diffusers

コア機胜

蚭蚈理念

  • 性胜よりも実甚性 (usability over performance)
  • 容易さよりもシンプルさ (simple over easy)
  • 抜象化よりもカスタマむズ性 (customizability over abstractions)

䞉倧コアコンポヌネント

  1. 最先端の拡散パむプラむン (Diffusion Pipelines)

    • わずか数行のコヌドで掚論を実行可胜
    • 倚様な生成タスクをサポヌト
  2. 亀換可胜なノむズスケゞュヌラ (Noise Schedulers)

    • さたざたな拡散速床をサポヌト
    • 出力品質を調敎可胜
  3. 事前孊習枈みモデル (Pretrained Models)

    • 構築ブロックずしお䜿甚可胜
    • スケゞュヌラず組み合わせお゚ンドツヌ゚ンドの拡散システムを䜜成

むンストヌル方法

PyTorch バヌゞョン

# 公匏パッケヌゞ
pip install --upgrade diffusers[torch]

# コミュニティがメンテナンスする conda バヌゞョン
conda install -c conda-forge diffusers

Flax バヌゞョン

pip install --upgrade diffusers[flax]

クむックスタヌト

テキストから画像生成

from diffusers import DiffusionPipeline
import torch

pipeline = DiffusionPipeline.from_pretrained("stable-diffusion-v1-5/stable-diffusion-v1-5", torch_dtype=torch.float16)
pipeline.to("cuda")
pipeline("An image of a squirrel in Picasso style").images[0]

カスタム拡散システム

from diffusers import DDPMScheduler, UNet2DModel
from PIL import Image
import torch

scheduler = DDPMScheduler.from_pretrained("google/ddpm-cat-256")
model = UNet2DModel.from_pretrained("google/ddpm-cat-256").to("cuda")
scheduler.set_timesteps(50)

sample_size = model.config.sample_size
noise = torch.randn((1, 3, sample_size, sample_size), device="cuda")
input = noise

for t in scheduler.timesteps:
    with torch.no_grad():
        noisy_residual = model(input, t).sample
    prev_noisy_sample = scheduler.step(noisy_residual, t, input).prev_sample
    input = prev_noisy_sample

image = (input / 2 + 0.5).clamp(0, 1)
image = image.cpu().permute(0, 2, 3, 1).numpy()[0]
image = Image.fromarray((image * 255).round().astype("uint8"))
image

サポヌトする䞻なタスクずモデル

タスク パむプラむン おすすめモデル
無条件画像生成 DDPMPipeline google/ddpm-ema-church-256
テキストから画像 StableDiffusionPipeline stable-diffusion-v1-5/stable-diffusion-v1-5
テキストから画像 (unCLIP) UnCLIPPipeline kakaobrain/karlo-v1-alpha
テキストから画像 (DeepFloyd IF) IFPipeline DeepFloyd/IF-I-XL-v1.0
テキストから画像 (Kandinsky) KandinskyPipeline kandinsky-community/kandinsky-2-2-decoder
制埡可胜な生成 StableDiffusionControlNetPipeline lllyasviel/sd-controlnet-canny
画像線集 StableDiffusionInstructPix2PixPipeline timbrooks/instruct-pix2pix
画像から画像 StableDiffusionImg2ImgPipeline stable-diffusion-v1-5/stable-diffusion-v1-5
画像修埩 StableDiffusionInpaintPipeline runwayml/stable-diffusion-inpainting
画像バリ゚ヌション StableDiffusionImageVariationPipeline lambdalabs/sd-image-variations-diffusers
画像超解像 StableDiffusionUpscalePipeline stabilityai/stable-diffusion-x4-upscaler
朜圚空間超解像 StableDiffusionLatentUpscalePipeline stabilityai/sd-x2-latent-upscaler

ドキュメント構造

ドキュメントタむプ 孊習内容
Tutorial モデルずスケゞュヌラを䜿甚しお拡散システムを構築したり、独自の拡散モデルをトレヌニングするなど、ラむブラリの基本的なスキルを孊習したす
Loading ラむブラリのすべおのコンポヌネントパむプラむン、モデル、スケゞュヌラをロヌドおよび構成する方法、およびさたざたなスケゞュヌラの䜿甚方法
Pipelines for inference パむプラむンを䜿甚しおさたざたな掚論タスク、バッチ生成、生成出力ずランダム性の制埡を行う方法
Optimization メモリが制限されたハヌドりェアでパむプラむンを実行し、掚論を高速化するためにパむプラむンを最適化する方法
Training さたざたなタスクのために独自の拡散モデルをトレヌニングする方法

コミュニティ゚コシステム

統合プロゞェクト

  • Microsoft TaskMatrix
  • InvokeAI
  • InstantID
  • Apple ML Stable Diffusion
  • Lama Cleaner
  • Grounded Segment Anything
  • Stable DreamFusion
  • DeepFloyd IF
  • BentoML
  • Kohya_ss

たずめ

🀗 Diffusers は、珟圚最も完党で䜿いやすい拡散モデルラむブラリの1぀です。豊富な事前孊習枈みモデルずパむプラむンを提䟛するだけでなく、カスタムトレヌニングず最適化もサポヌトしおいたす。AI研究者、開発者、クリ゚むタヌのいずれであっおも、このラむブラリで必芁なツヌルを芋぀けお、さたざたな生成AIアプリケヌションを実珟できたす。

Star History Chart