Diffusers documentation

Checkpoint lama

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

Checkpoint lama

Pengaturan ini terutama berlaku untuk checkpoint keluarga Stable Diffusion yang lebih lama.

Pemeriksa keamanan

Diffusers menyediakan safety checker untuk checkpoint Stable Diffusion yang lebih lama untuk mencegah pembuatan konten yang berbahaya. Alat ini menyaring output yang dihasilkan berdasarkan seperangkat konsep berbahaya yang di-hardcode. Model-model yang lebih baru seperti Qwen-Image tidak memiliki checker ini.

Jika Anda ingin menonaktifkan safety checker, berikan safety_checker=None di from_pretrained() seperti yang ditunjukkan di bawah ini.

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 .
"""

Jadwal penskalaan ulang

Denoising dimulai dari noise murni, sehingga rasio sinyal-terhadap-noise (SNR) dimulai dari nol. Beberapa model sebenarnya tidak dimulai dari noise murni, yang membuat ekstrem terang dan gelap sulit dihasilkan.

Latih model Anda sendiri dengan v_prediction dengan menambahkan flag --prediction_type="v_prediction" ke skrip pelatihan Anda. Anda juga dapat mencari model yang sudah ada yang dilatih dengan v_prediction.

Untuk model v_prediction, aktifkan argumen scheduler ini.

  • Set rescale_betas_zero_snr=True untuk menskalakan ulang jadwal noise ke langkah waktu terakhir dengan SNR yang benar-benar nol
  • Set timestep_spacing="trailing" untuk memaksa pengambilan sampel dari timestep terakhir dengan noise murni
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"
)

Set guidance_rescale di pipeline untuk menghindari gambar yang terlalu terang. Nilai yang lebih rendah meningkatkan kecerahan, tetapi beberapa detail mungkin tampak pudar.

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]
tanpa SNR nol
dengan SNR nol dan spasi di belakang
Update on GitHub