Skip to content

Commit 200f634

Browse files
committed
feat: give feedback about cfg values smaller than 1
1 parent 43a70e8 commit 200f634

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

stable-diffusion.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1484,6 +1484,23 @@ 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 == 1.f) {
1489+
LOG_INFO("pure conditioned mode (no negatives)");
1490+
} else if (cfg_scale == 0.f) {
1491+
// Diffusers follow the convention from the original paper//
1492+
// (https://arxiv.org/abs/2207.12598v1), so many distilled model docs recommend
1493+
// 0 as guidance; warn the user that it disables prompt folowing instead
1494+
LOG_WARN("unconditioned mode (cfg-scale=0), images won't follow the prompt (use cfg-scale=1 for distilled models)");
1495+
} else if (cfg_scale < 1) {
1496+
if (cfg_scale < 0) {
1497+
LOG_WARN("negative cfg-scale values aren't supported");
1498+
} else {
1499+
LOG_WARN("cfg-scale values between 0 and 1 aren't supported");
1500+
}
1501+
}
1502+
}
1503+
14871504
float img_cfg_scale = std::isfinite(guidance.img_cfg) ? guidance.img_cfg : guidance.txt_cfg;
14881505
float slg_scale = guidance.slg.scale;
14891506

0 commit comments

Comments
 (0)