Buckets:

hf-doc-build/doc / diffusers /v0.43.0 /zh /using-diffusers /legacy_checkpoints.md
mishig's picture
|
download
raw
3.06 kB
# 旧版检查点
这些设置主要适用于较旧的 Stable Diffusion 系列检查点。
## 安全检查器
Diffusers 为较旧的 Stable Diffusion 检查点提供了 [安全检查器](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/safety_checker.py),以防止生成有害内容。它会针对一组硬编码的有害概念对生成的输出进行筛查。Qwen-Image 等较新的模型不包含此检查器。
如果要禁用安全检查器,请在 [from_pretrained()](/docs/diffusers/v0.43.0/zh/api/pipelines/overview#diffusers.DiffusionPipeline.from_pretrained) 中传入 `safety_checker=None`,如下所示。
```py
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)初始值为零。一些模型实际上并非从纯噪声开始,这使得生成极亮和极暗的极端值变得困难。
> [!TIP]
> 通过向训练脚本添加 `--prediction_type="v_prediction"` 标志,使用 `v_prediction` 训练你自己的模型。你还可以 [搜索](https://huggingface.co/search/full-text?q=v_prediction&type=model) 使用 `v_prediction` 训练的现有模型。
对于 `v_prediction` 模型,请启用以下调度器参数。
- 将 `rescale_betas_zero_snr=True` 设置为 True,可将噪声调度重新缩放至最后一个时间步,使其信噪比(SNR)恰好为零。
- 设置 `timestep_spacing="trailing"` 以强制从最后的时间步(纯噪声)进行采样
```py
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"
)
```
在 pipeline 中设置 `guidance_rescale` 以避免图像过曝。值越低,亮度越高,但部分细节可能会显得褪色。
```py
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]
```
无零信噪比
零信噪比和尾部间距

Xet Storage Details

Size:
3.06 kB
·
Xet hash:
626e119cb32444732f9ded221b6e9c883177685ff60ea163bf564fbe1b7a0a38

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.