Skip to content

Commit a2344da

Browse files
committed
feat: warn about cfg values smaller than 1
1 parent 43a70e8 commit a2344da

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
@@ -1484,6 +1484,17 @@ class StableDiffusionGGML {
14841484
std::vector<int> skip_layers(guidance.slg.layers, guidance.slg.layers + guidance.slg.layer_count);
14851485

14861486
float cfg_scale = guidance.txt_cfg;
1487+
if (cfg_scale < 1) {
1488+
if (cfg_scale == 0.f) {
1489+
// Diffusers follow the convention from the original paper
1490+
// (https://arxiv.org/abs/2207.12598v1), so many distilled model docs
1491+
// recommend 0 as guidance; warn the user that it'll disable prompt folowing
1492+
LOG_WARN("unconditioned mode, images won't follow the prompt (use cfg-scale=1 for distilled models)");
1493+
} else {
1494+
LOG_WARN("unsupported cfg-scale value");
1495+
}
1496+
}
1497+
14871498
float img_cfg_scale = std::isfinite(guidance.img_cfg) ? guidance.img_cfg : guidance.txt_cfg;
14881499
float slg_scale = guidance.slg.scale;
14891500

0 commit comments

Comments
 (0)