From 7c88c4765ce6ef8447bc2ac5d30c73365f5b25a9 Mon Sep 17 00:00:00 2001 From: Wagner Bruna Date: Fri, 19 Dec 2025 12:41:52 -0300 Subject: [PATCH] chore: give feedback about cfg values smaller than 1 (#1088) --- stable-diffusion.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/stable-diffusion.cpp b/stable-diffusion.cpp index 4485ac7..6446c41 100644 --- a/stable-diffusion.cpp +++ b/stable-diffusion.cpp @@ -1497,6 +1497,17 @@ public: std::vector skip_layers(guidance.slg.layers, guidance.slg.layers + guidance.slg.layer_count); float cfg_scale = guidance.txt_cfg; + if (cfg_scale < 1.f) { + if (cfg_scale == 0.f) { + // Diffusers follow the convention from the original paper + // (https://arxiv.org/abs/2207.12598v1), so many distilled model docs + // recommend 0 as guidance; warn the user that it'll disable prompt folowing + LOG_WARN("unconditioned mode, images won't follow the prompt (use cfg-scale=1 for distilled models)"); + } else { + LOG_WARN("cfg value out of expected range may produce unexpected results"); + } + } + float img_cfg_scale = std::isfinite(guidance.img_cfg) ? guidance.img_cfg : guidance.txt_cfg; float slg_scale = guidance.slg.scale;