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

جدولة إعادة التحجيم

تبدأ عملية إزالة الضوضاء من ضوضاء نقية، لذا فإن نسبة الإشارة إلى الضوضاء (SNR) تبدأ من الصفر. بعض النماذج لا تبدأ فعليًا من ضوضاء نقية، مما يجعل توليد القيم القصوى الساطعة والداكنة أمرًا صعبًا.

درّب نموذجك الخاص باستخدام v_prediction عن طريق إضافة علم --prediction_type="v_prediction" إلى سكربت التدريب الخاص بك. يمكنك أيضًا البحث عن نماذج موجودة تم تدريبها باستخدام v_prediction.

لنموذج v_prediction، فعّل هذه الحجج الخاصة بمجدول التدرج.

  • اضبط rescale_betas_zero_snr=True لإعادة مقياس جدول الضوضاء إلى الخطوة الزمنية الأخيرة تماماً مع نسبة إشارة إلى ضوضاء صفرية تماماً
  • اضبط 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]
بدون SNR صفري
بصفر نسبة الإشارة إلى الضوضاء ومسافة لاحقة
Update on GitHub