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

レガシーチェックポイント

これらの設定は、主に旧型のStable Diffusionファミリーのチェックポイントに適用されます。

セーフティチェッカー

Diffusers は、有害なコンテンツの生成を防ぐために、旧型の Stable Diffusion チェックポイント用にセーフティチェッカーを提供しています。これは、生成された出力をハードコードされた有害な概念のセットに対してスクリーニングします。Qwen-Image などの新しいモデルには、このチェッカーは付属していません。

セーフティチェッカーを無効にする場合は、以下に示すようにsafety_checker=Noneをfrom_pretrained()に渡します。

from diffusers import DiffusionPipeline

pipeline = DiffusionPipeline.from_pretrained(
  "stable-diffusion-v1-5/stable-diffusion-v1-5", safety_checker=None
)
"""
You have disabled the safety checker for <class 'diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline'> by passing `safety_checker=None`. Ensure that you abide by the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend keeping the safety filter enabled in all public-facing circumstances, disabling it only for use cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .
"""

スケジュールの再スケーリング

Denoisingは純粋なノイズから始まるため、信号対雑音比(SNR)はゼロから始まります。一部のモデルは実際には純粋なノイズから開始せず、そのため明るすぎる部分や暗すぎる部分の生成が困難になる場合があります。

v_prediction を使用して独自のモデルをトレーニングするには、トレーニングスクリプトに --prediction_type="v_prediction" フラグを追加します。また、v_prediction でトレーニングされた既存のモデルを 検索 することもできます。

v_predictionモデルの場合、これらのスケジューラー引数を有効にしてください。

  • rescale_betas_zero_snr=True を設定すると、ノイズスケジュールが、SNR がちょうどゼロになる最後のタイムステップまでリスケールされます。
  • timestep_spacing="trailing" を設定すると、純粋なノイズから最後のタイムステップでサンプリングが強制されます。
from diffusers import DiffusionPipeline, DDIMScheduler

pipeline = DiffusionPipeline.from_pretrained("ptx0/pseudo-journey-v2", device_map="cuda")  # or "mps", "xpu", "cpu"

pipeline.scheduler = DDIMScheduler.from_config(
    pipeline.scheduler.config, rescale_betas_zero_snr=True, timestep_spacing="trailing"
)

パイプラインでguidance_rescaleを設定し、露出過多の画像を回避してください。値を下げると明るさが増しますが、一部のディテールが薄く見える可能性があります。

prompt = """
cinematic photo of a snowy mountain at night with the northern lights aurora borealis
overhead, 35mm photograph, film, professional, 4k, highly detailed
"""
image = pipeline(prompt, guidance_rescale=0.7).images[0]
zero SNRなし
SNRがゼロで、末尾にスペースがある
Update on GitHub