Skip to content

Commit 7c88c47

Browse files
authored
chore: give feedback about cfg values smaller than 1 (#1088)
1 parent 1f77545 commit 7c88c47

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

stable-diffusion.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,6 +1497,17 @@ class StableDiffusionGGML {
14971497
std::vector<int> skip_layers(guidance.slg.layers, guidance.slg.layers + guidance.slg.layer_count);
14981498

14991499
float cfg_scale = guidance.txt_cfg;
1500+
if (cfg_scale < 1.f) {
1501+
if (cfg_scale == 0.f) {
1502+
// Diffusers follow the convention from the original paper
1503+
// (https://arxiv.org/abs/2207.12598v1), so many distilled model docs
1504+
// recommend 0 as guidance; warn the user that it'll disable prompt folowing
1505+
LOG_WARN("unconditioned mode, images won't follow the prompt (use cfg-scale=1 for distilled models)");
1506+
} else {
1507+
LOG_WARN("cfg value out of expected range may produce unexpected results");
1508+
}
1509+
}
1510+
15001511
float img_cfg_scale = std::isfinite(guidance.img_cfg) ? guidance.img_cfg : guidance.txt_cfg;
15011512
float slg_scale = guidance.slg.scale;
15021513

0 commit comments

Comments
 (0)