File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed
Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -1484,8 +1484,26 @@ 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- float img_cfg_scale = std::isfinite (guidance.img_cfg ) ? guidance.img_cfg : guidance.txt_cfg ;
1488- float slg_scale = guidance.slg .scale ;
1487+ float img_cfg_scale = guidance.img_cfg ;
1488+ if (cfg_scale < 1 .f ) {
1489+ if (cfg_scale == 0 .f ) {
1490+ // many distilled model docs mention using 0 as guidance, so relax the message a bit
1491+ LOG_DEBUG (" cfg-scale = 0, disabling classifier‑free guidance" );
1492+ } else if (cfg_scale < 0 ) {
1493+ LOG_WARN (" negative cfg-scale isn't supported; setting it to 1" );
1494+ } else {
1495+ LOG_WARN (" cfg-scale < 1 isn't supported; setting it to 1" );
1496+ }
1497+ if (img_cfg_scale == cfg_scale) {
1498+ img_cfg_scale = 1 .f ;
1499+ }
1500+ cfg_scale = 1 .f ;
1501+ }
1502+
1503+ if (!std::isfinite (img_cfg_scale)) {
1504+ img_cfg_scale = cfg_scale;
1505+ }
1506+ float slg_scale = guidance.slg .scale ;
14891507
14901508 if (img_cfg_scale != cfg_scale && !sd_version_is_inpaint_or_unet_edit (version)) {
14911509 LOG_WARN (" 2-conditioning CFG is not supported with this model, disabling it for better performance..." );
You can’t perform that action at this time.
0 commit comments