diff --git a/html/locale_en.json b/html/locale_en.json
index 77d28add0..29e9f1e89 100644
--- a/html/locale_en.json
+++ b/html/locale_en.json
@@ -144,6 +144,7 @@
{"id":"","label":"Batch count","localized":"","hint":"How many batches of images to create (has no impact on generation performance or VRAM usage)"},
{"id":"","label":"Batch size","localized":"","hint":"How many image to create in a single batch (increases generation performance at cost of higher VRAM usage)"},
{"id":"","label":"cfg scale","localized":"","hint":"Classifier Free Guidance scale: how strongly the image should conform to prompt. Lower values produce more creative results, higher values make it follow the prompt more strictly; recommended values between 5-10"},
+ {"id":"","label":"Guidance End","localized":"","hint":"Ends the effect of CFG and PAG early: A value of 1 acts as normal, 0.5 stops guidance at 50% of steps"},
{"id":"","label":"CLIP skip","localized":"","hint":"Clip skip is a feature that allows users to control the level of specificity of the prompt, the higher the CLIP skip value, the less deep the prompt will be interpreted. CLIP Skip 1 is typical while some anime models produce better results at CLIP skip 2"},
{"id":"","label":"Initial seed","localized":"","hint":"A value that determines the output of random number generator - if you create an image with same parameters and seed as another image, you'll get the same result"},
{"id":"","label":"Variation","localized":"","hint":"Second seed to be mixed with primary seed"},
diff --git a/modules/processing_callbacks.py b/modules/processing_callbacks.py
index dcb2a7760..d5b7d1922 100644
--- a/modules/processing_callbacks.py
+++ b/modules/processing_callbacks.py
@@ -76,9 +76,13 @@ def diffusers_callback(pipe, step: int, timestep: int, kwargs: dict):
except Exception as e:
shared.log.debug(f"Callback: {e}")
if step == int(getattr(pipe, 'num_timesteps', 100) * p.cfg_end) and 'prompt_embeds' in kwargs and 'negative_prompt_embeds' in kwargs:
- pipe._guidance_scale = 0.0 # pylint: disable=protected-access
- for key in {"prompt_embeds", "negative_prompt_embeds", "add_text_embeds", "add_time_ids"} & set(kwargs):
- kwargs[key] = kwargs[key].chunk(2)[-1]
+ if "PAG" in shared.sd_model.__class__.__name__:
+ pipe._guidance_scale = 1.001 if pipe._guidance_scale > 1 else pipe._guidance_scale # pylint: disable=protected-access
+ pipe._pag_scale = 0.001 # pylint: disable=protected-access
+ else:
+ pipe._guidance_scale = 0.0 # pylint: disable=protected-access
+ for key in {"prompt_embeds", "negative_prompt_embeds", "add_text_embeds", "add_time_ids"} & set(kwargs):
+ kwargs[key] = kwargs[key].chunk(2)[-1]
shared.state.current_latent = kwargs['latents']
if shared.cmd_opts.profile and shared.profiler is not None:
shared.profiler.step()
diff --git a/modules/ui_sections.py b/modules/ui_sections.py
index 3cb972bc9..d83a7472d 100644
--- a/modules/ui_sections.py
+++ b/modules/ui_sections.py
@@ -153,7 +153,7 @@ def create_options(tab):
def create_cfg_inputs(tab):
with gr.Row():
cfg_scale = gr.Slider(minimum=0.0, maximum=30.0, step=0.1, label='CFG scale', value=6.0, elem_id=f"{tab}_cfg_scale")
- cfg_end = gr.Slider(minimum=0.0, maximum=1.0, step=0.1, label='CFG end', value=1.0, elem_id=f"{tab}_cfg_end")
+ cfg_end = gr.Slider(minimum=0.0, maximum=1.0, step=0.1, label='Guidance end', value=1.0, elem_id=f"{tab}_cfg_end")
return cfg_scale, cfg_end
diff --git a/scripts/xyz_grid.py b/scripts/xyz_grid.py
index 27ee809a4..ea0494bc7 100644
--- a/scripts/xyz_grid.py
+++ b/scripts/xyz_grid.py
@@ -234,7 +234,7 @@ axis_options = [
AxisOption("Seed", int, apply_field("seed")),
AxisOption("Steps", int, apply_field("steps")),
AxisOption("CFG Scale", float, apply_field("cfg_scale")),
- AxisOption("CFG End", float, apply_field("cfg_end")),
+ AxisOption("Guidance End", float, apply_field("cfg_end")),
AxisOption("Variation seed", int, apply_field("subseed")),
AxisOption("Variation strength", float, apply_field("subseed_strength")),
AxisOption("Clip skip", float, apply_clip_skip),