Skip to content

Commit eefc3c3

Browse files
committed
preserve img-cfg default behavior
1 parent a4fcb54 commit eefc3c3

4 files changed

Lines changed: 10 additions & 8 deletions

File tree

examples/cli/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,8 @@ Generation Options:
129129
--hires-upscale-tile-size <int> highres fix upscaler tile size, reserved for model-backed upscalers (default:
130130
128)
131131
--cfg-scale <float> unconditional guidance scale: (default: 7.0)
132-
--img-cfg-scale <float> image guidance scale for inpaint or image edit models: (default: 1.0)
132+
--img-cfg-scale <float> image guidance scale for inpaint or image edit models: (default: same as
133+
--cfg-scale)
133134
--guidance <float> distilled guidance scale for models with guidance input (default: 3.5)
134135
--slg-scale <float> skip layer guidance (SLG) scale, only for DiT models: (default: 0). 0 means
135136
disabled, a value of 2.5 is nice for sd3.5 medium
@@ -140,7 +141,7 @@ Generation Options:
140141
--flow-shift <float> shift value for Flow models like SD3.x or WAN (default: auto)
141142
--high-noise-cfg-scale <float> (high noise) unconditional guidance scale: (default: 7.0)
142143
--high-noise-img-cfg-scale <float> (high noise) image guidance scale for inpaint or image edit models (default:
143-
1.0)
144+
same as --cfg-scale)
144145
--high-noise-guidance <float> (high noise) distilled guidance scale for models with guidance input
145146
(default: 3.5)
146147
--high-noise-slg-scale <float> (high noise) skip layer guidance (SLG) scale, only for DiT models: (default:

examples/common/common.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ ArgOptions SDGenerationParams::get_options() {
940940
&sample_params.guidance.txt_cfg},
941941
{"",
942942
"--img-cfg-scale",
943-
"image guidance scale for inpaint or image edit models: (default: 1.0)",
943+
"image guidance scale for inpaint or image edit models: (default: same as --cfg-scale)",
944944
&sample_params.guidance.img_cfg},
945945
{"",
946946
"--guidance",
@@ -972,7 +972,7 @@ ArgOptions SDGenerationParams::get_options() {
972972
&high_noise_sample_params.guidance.txt_cfg},
973973
{"",
974974
"--high-noise-img-cfg-scale",
975-
"(high noise) image guidance scale for inpaint or image edit models (default: 1.0)",
975+
"(high noise) image guidance scale for inpaint or image edit models (default: same as --cfg-scale)",
976976
&high_noise_sample_params.guidance.img_cfg},
977977
{"",
978978
"--high-noise-guidance",

examples/server/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,8 @@ Default Generation Options:
231231
--hires-upscale-tile-size <int> highres fix upscaler tile size, reserved for model-backed upscalers (default:
232232
128)
233233
--cfg-scale <float> unconditional guidance scale: (default: 7.0)
234-
--img-cfg-scale <float> image guidance scale for inpaint or image edit models: (default: 1.0)
234+
--img-cfg-scale <float> image guidance scale for inpaint or image edit models: (default: same as
235+
--cfg-scale)
235236
--guidance <float> distilled guidance scale for models with guidance input (default: 3.5)
236237
--slg-scale <float> skip layer guidance (SLG) scale, only for DiT models: (default: 0). 0 means
237238
disabled, a value of 2.5 is nice for sd3.5 medium
@@ -242,7 +243,7 @@ Default Generation Options:
242243
--flow-shift <float> shift value for Flow models like SD3.x or WAN (default: auto)
243244
--high-noise-cfg-scale <float> (high noise) unconditional guidance scale: (default: 7.0)
244245
--high-noise-img-cfg-scale <float> (high noise) image guidance scale for inpaint or image edit models (default:
245-
1.0)
246+
same as --cfg-scale)
246247
--high-noise-guidance <float> (high noise) distilled guidance scale for models with guidance input
247248
(default: 3.5)
248249
--high-noise-slg-scale <float> (high noise) skip layer guidance (SLG) scale, only for DiT models: (default:

src/stable-diffusion.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,7 +2853,7 @@ char* sd_sample_params_to_str(const sd_sample_params_t* sample_params) {
28532853
sample_params->guidance.txt_cfg,
28542854
std::isfinite(sample_params->guidance.img_cfg)
28552855
? sample_params->guidance.img_cfg
2856-
: 1.0f,
2856+
: sample_params->guidance.txt_cfg,
28572857
sample_params->guidance.distilled_guidance,
28582858
sample_params->guidance.slg.layer_count,
28592859
sample_params->guidance.slg.layer_start,
@@ -3338,7 +3338,7 @@ struct GenerationRequest {
33383338
// img_cfg == txt_cfg means that img_cfg is not used
33393339
bool img_cfg_was_unset = !std::isfinite(guidance->img_cfg);
33403340
if (!std::isfinite(guidance->img_cfg)) {
3341-
guidance->img_cfg = 1.0f;
3341+
guidance->img_cfg = guidance->txt_cfg;
33423342
}
33433343

33443344
if (!sd_version_supports_img_cfg(sd_ctx->sd->version, has_ref_images)) {

0 commit comments

Comments
 (0)