mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 16:54:33 +02:00
add pag for sd15 and sdxl
This commit is contained in:
@@ -17,6 +17,7 @@ ignore-paths=/usr/lib/.*$,
|
||||
^modules/tcd/.*$,
|
||||
^modules/xadapters/.*$,
|
||||
^modules/hidiffusion/.*$,
|
||||
^modules/pag/.*$,
|
||||
ignore-patterns=
|
||||
ignored-modules=
|
||||
jobs=0
|
||||
|
||||
@@ -35,6 +35,11 @@ it is time to give credit to original [author](https://github.com/auTOMATIC1111)
|
||||
Simply enable checkbox in advanced menu and set desired resolution
|
||||
Additional settings are available in *settings -> inference settings -> hidiffusion*
|
||||
And can also be set and used via *xyz grid*
|
||||
- [Perturbed-Attention Guidance](https://github.com/KU-CVLAB/Perturbed-Attention-Guidance)
|
||||
PAG enhances sample quality by utilizing self-attention in formation of latent in addition to standard CFG scale
|
||||
Simply set *advanced -> attention guidance* and *advanced -> adaptive scaling*
|
||||
Additional options are available in *settings -> inference settings -> pag*
|
||||
*Note*: PAG has replaced SAG as attention guidance method in SD.Next
|
||||
- **IP Adapter Masking**:
|
||||
Powerful method of using masking with ip-adapters
|
||||
When combined with multiple ip-adapters, it allows for different inputs guidance for each segment of the input image
|
||||
|
||||
@@ -12,7 +12,6 @@ Main ToDo list can be found at [GitHub projects](https://github.com/users/vladma
|
||||
|
||||
- stable diffusion 3.0
|
||||
- powerpaint: <https://github.com/zhuang2002/PowerPaint>
|
||||
- joytag: <https://github.com/fpgaminer/joytag>
|
||||
|
||||
### Features
|
||||
|
||||
|
||||
+2
-1
@@ -310,7 +310,8 @@
|
||||
{"id":"","label":"include watermark","localized":"","hint":"Add invisible watermark to image by altering some pixel values"},
|
||||
{"id":"","label":"watermark string","localized":"","hint":"Watermark string to add to image. Keep very short to avoid image corruption."},
|
||||
{"id":"","label":"show log view","localized":"","hint":"Show log view at the bottom of the main window"},
|
||||
{"id":"","label":"Log view update period","localized":"","hint":"Log view update period, in miliseconds"}
|
||||
{"id":"","label":"Log view update period","localized":"","hint":"Log view update period, in miliseconds"},
|
||||
{"id":"","label":"PAG layer names","localized":"","hint":"Space separated list of layers<br>Available: d[0-5], m[0], u[0-8]<br>Default: m0"}
|
||||
],
|
||||
"scripts": [
|
||||
{"id":"","label":"X values","localized":"","hint":"Separate values for X axis using commas"},
|
||||
|
||||
@@ -57,7 +57,7 @@ def control_run(units: List[unit.Unit] = [], inputs: List[Image.Image] = [], ini
|
||||
prompt: str = '', negative: str = '', styles: List[str] = [],
|
||||
steps: int = 20, sampler_index: int = None,
|
||||
seed: int = -1, subseed: int = -1, subseed_strength: float = 0, seed_resize_from_h: int = -1, seed_resize_from_w: int = -1,
|
||||
cfg_scale: float = 6.0, clip_skip: float = 1.0, image_cfg_scale: float = 6.0, diffusers_guidance_rescale: float = 0.7, sag_scale: float = 0.0, cfg_end: float = 1.0,
|
||||
cfg_scale: float = 6.0, clip_skip: float = 1.0, image_cfg_scale: float = 6.0, diffusers_guidance_rescale: float = 0.7, pag_scale: float = 0.0, pag_adaptive: float = 0.5, cfg_end: float = 1.0,
|
||||
full_quality: bool = True, restore_faces: bool = False, tiling: bool = False, hidiffusion: bool = False,
|
||||
hdr_mode: int = 0, hdr_brightness: float = 0, hdr_color: float = 0, hdr_sharpen: float = 0, hdr_clamp: bool = False, hdr_boundary: float = 4.0, hdr_threshold: float = 0.95,
|
||||
hdr_maximize: bool = False, hdr_max_center: float = 0.6, hdr_max_boundry: float = 1.0, hdr_color_picker: str = None, hdr_tint_ratio: float = 0,
|
||||
@@ -103,7 +103,8 @@ def control_run(units: List[unit.Unit] = [], inputs: List[Image.Image] = [], ini
|
||||
clip_skip = clip_skip,
|
||||
image_cfg_scale = image_cfg_scale,
|
||||
diffusers_guidance_rescale = diffusers_guidance_rescale,
|
||||
sag_scale = sag_scale,
|
||||
pag_scale = pag_scale,
|
||||
pag_adaptive = pag_adaptive,
|
||||
full_quality = full_quality,
|
||||
restore_faces = restore_faces,
|
||||
tiling = tiling,
|
||||
|
||||
@@ -3,9 +3,11 @@ import diffusers.pipelines as p
|
||||
def is_sd15(model):
|
||||
if model is None:
|
||||
return False
|
||||
return isinstance(model, p.StableDiffusionPipeline) or isinstance(model, p.StableDiffusionImg2ImgPipeline) or isinstance(model, p.StableDiffusionInpaintPipeline)
|
||||
return model.__name__ == p.StableDiffusionPipeline.__name__ or model.__name__ == p.StableDiffusionImg2ImgPipeline.__name__ or model.__name__ == p.StableDiffusionInpaintPipeline.__name__
|
||||
# return isinstance(model, p.StableDiffusionPipeline) or isinstance(model, p.StableDiffusionImg2ImgPipeline) or isinstance(model, p.StableDiffusionInpaintPipeline)
|
||||
|
||||
def is_sdxl(model):
|
||||
if model is None:
|
||||
return False
|
||||
return isinstance(model, p.StableDiffusionXLPipeline) or isinstance(model, p.StableDiffusionXLImg2ImgPipeline) or isinstance(model, p.StableDiffusionXLInpaintPipeline)
|
||||
return model.__name__ == p.StableDiffusionXLPipeline.__name__ or model.__name__ == p.StableDiffusionXLImg2ImgPipeline.__name__ or model.__name__ == p.StableDiffusionXLInpaintPipeline.__name__
|
||||
# return isinstance(model, p.StableDiffusionXLPipeline) or isinstance(model, p.StableDiffusionXLImg2ImgPipeline) or isinstance(model, p.StableDiffusionXLInpaintPipeline)
|
||||
|
||||
+3
-2
@@ -123,7 +123,7 @@ def img2img(id_task: str, mode: int,
|
||||
n_iter, batch_size,
|
||||
cfg_scale, image_cfg_scale,
|
||||
diffusers_guidance_rescale,
|
||||
sag_scale,
|
||||
pag_scale, pag_adaptive,
|
||||
cfg_end,
|
||||
refiner_start,
|
||||
clip_skip,
|
||||
@@ -235,7 +235,8 @@ def img2img(id_task: str, mode: int,
|
||||
denoising_strength=denoising_strength,
|
||||
image_cfg_scale=image_cfg_scale,
|
||||
diffusers_guidance_rescale=diffusers_guidance_rescale,
|
||||
sag_scale=sag_scale,
|
||||
pag_scale=pag_scale,
|
||||
pag_adaptive=pag_adaptive,
|
||||
refiner_start=refiner_start,
|
||||
inpaint_full_res=inpaint_full_res != 0,
|
||||
inpaint_full_res_padding=inpaint_full_res_padding,
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
from diffusers.pipelines import StableDiffusionPipeline, StableDiffusionXLPipeline # pylint: disable=unused-import
|
||||
from modules import shared, processing, sd_models
|
||||
from modules.pag.pipe_sd import StableDiffusionPAGPipeline
|
||||
from modules.pag.pipe_sdxl import StableDiffusionXLPAGPipeline
|
||||
from modules.control.units import detect
|
||||
|
||||
|
||||
orig_pipeline = None
|
||||
|
||||
|
||||
def apply(p: processing.StableDiffusionProcessing): # pylint: disable=arguments-differ
|
||||
global orig_pipeline # pylint: disable=global-statement
|
||||
c = shared.sd_model.__class__ if shared.sd_loaded else None
|
||||
if p.pag_scale == 0:
|
||||
unapply()
|
||||
return None
|
||||
if c == StableDiffusionPAGPipeline or c == StableDiffusionXLPAGPipeline:
|
||||
pass
|
||||
elif detect.is_sd15(c):
|
||||
orig_pipeline = shared.sd_model
|
||||
shared.sd_model = sd_models.switch_pipe(StableDiffusionPAGPipeline, shared.sd_model)
|
||||
elif detect.is_sdxl(c):
|
||||
orig_pipeline = shared.sd_model
|
||||
shared.sd_model = sd_models.switch_pipe(StableDiffusionXLPAGPipeline, shared.sd_model)
|
||||
else:
|
||||
shared.log.warning(f'PAG: pipeline={c} required={StableDiffusionPipeline.__name__}')
|
||||
return None
|
||||
|
||||
p.task_args['pag_scale'] = p.pag_scale
|
||||
p.task_args['pag_adaptive_scaling'] = p.pag_adaptive
|
||||
pag_applied_layers = shared.opts.pag_apply_layers
|
||||
pag_applied_layers_index = pag_applied_layers.split() if len(pag_applied_layers) > 0 else []
|
||||
pag_applied_layers_index = [p.strip() for p in pag_applied_layers_index]
|
||||
p.task_args['pag_applied_layers_index'] = pag_applied_layers_index if len(pag_applied_layers_index) > 0 else ['m0'] # Available layers: d[0-5], m[0], u[0-8]
|
||||
shared.log.debug(f'{c}: args={p.task_args}')
|
||||
|
||||
|
||||
def unapply():
|
||||
global orig_pipeline # pylint: disable=global-statement
|
||||
if orig_pipeline is not None:
|
||||
shared.sd_model = orig_pipeline
|
||||
orig_pipeline = None
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,7 @@ from modules import shared, devices, errors, images, scripts, memstats, lowvram,
|
||||
from modules.sd_hijack_hypertile import context_hypertile_vae, context_hypertile_unet
|
||||
from modules.processing_class import StableDiffusionProcessing, StableDiffusionProcessingTxt2Img, StableDiffusionProcessingImg2Img, StableDiffusionProcessingControl # pylint: disable=unused-import
|
||||
from modules.processing_info import create_infotext
|
||||
from modules import pag
|
||||
|
||||
|
||||
opt_C = 4
|
||||
@@ -156,6 +157,7 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
|
||||
|
||||
shared.prompt_styles.apply_styles_to_extra(p)
|
||||
shared.prompt_styles.extract_comments(p)
|
||||
pag.apply(p)
|
||||
if shared.opts.cuda_compile_backend == 'none':
|
||||
sd_models.apply_token_merging(p.sd_model)
|
||||
sd_hijack_freeu.apply_freeu(p, shared.backend == shared.Backend.ORIGINAL)
|
||||
@@ -189,6 +191,7 @@ def process_images(p: StableDiffusionProcessing) -> Processed:
|
||||
processed = process_images_inner(p)
|
||||
|
||||
finally:
|
||||
pag.unapply()
|
||||
if shared.opts.cuda_compile_backend == 'none':
|
||||
sd_models.remove_token_merging(p.sd_model)
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ class StableDiffusionProcessing:
|
||||
"""
|
||||
The first set of paramaters: sd_models -> do_not_reload_embeddings represent the minimum required to create a StableDiffusionProcessing
|
||||
"""
|
||||
def __init__(self, sd_model=None, outpath_samples=None, outpath_grids=None, prompt: str = "", styles: List[str] = None, seed: int = -1, subseed: int = -1, subseed_strength: float = 0, seed_resize_from_h: int = -1, seed_resize_from_w: int = -1, seed_enable_extras: bool = True, sampler_name: str = None, hr_sampler_name: str = None, batch_size: int = 1, n_iter: int = 1, steps: int = 50, cfg_scale: float = 7.0, image_cfg_scale: float = None, clip_skip: int = 1, width: int = 512, height: int = 512, full_quality: bool = True, restore_faces: bool = False, tiling: bool = False, hidiffusion: bool = False, do_not_save_samples: bool = False, do_not_save_grid: bool = False, extra_generation_params: Dict[Any, Any] = None, overlay_images: Any = None, negative_prompt: str = None, eta: float = None, do_not_reload_embeddings: bool = False, denoising_strength: float = 0, diffusers_guidance_rescale: float = 0.7, sag_scale: float = 0.0, cfg_end: float = 1, resize_mode: int = 0, resize_name: str = 'None', scale_by: float = 0, selected_scale_tab: int = 0, hdr_mode: int = 0, hdr_brightness: float = 0, hdr_color: float = 0, hdr_sharpen: float = 0, hdr_clamp: bool = False, hdr_boundary: float = 4.0, hdr_threshold: float = 0.95, hdr_maximize: bool = False, hdr_max_center: float = 0.6, hdr_max_boundry: float = 1.0, hdr_color_picker: str = None, hdr_tint_ratio: float = 0, override_settings: Dict[str, Any] = None, override_settings_restore_afterwards: bool = True, sampler_index: int = None, script_args: list = None): # pylint: disable=unused-argument
|
||||
def __init__(self, sd_model=None, outpath_samples=None, outpath_grids=None, prompt: str = "", styles: List[str] = None, seed: int = -1, subseed: int = -1, subseed_strength: float = 0, seed_resize_from_h: int = -1, seed_resize_from_w: int = -1, seed_enable_extras: bool = True, sampler_name: str = None, hr_sampler_name: str = None, batch_size: int = 1, n_iter: int = 1, steps: int = 50, cfg_scale: float = 7.0, image_cfg_scale: float = None, clip_skip: int = 1, width: int = 512, height: int = 512, full_quality: bool = True, restore_faces: bool = False, tiling: bool = False, hidiffusion: bool = False, do_not_save_samples: bool = False, do_not_save_grid: bool = False, extra_generation_params: Dict[Any, Any] = None, overlay_images: Any = None, negative_prompt: str = None, eta: float = None, do_not_reload_embeddings: bool = False, denoising_strength: float = 0, diffusers_guidance_rescale: float = 0.7, pag_scale: float = 0.0, pag_adaptive: float = 0.5, cfg_end: float = 1, resize_mode: int = 0, resize_name: str = 'None', scale_by: float = 0, selected_scale_tab: int = 0, hdr_mode: int = 0, hdr_brightness: float = 0, hdr_color: float = 0, hdr_sharpen: float = 0, hdr_clamp: bool = False, hdr_boundary: float = 4.0, hdr_threshold: float = 0.95, hdr_maximize: bool = False, hdr_max_center: float = 0.6, hdr_max_boundry: float = 1.0, hdr_color_picker: str = None, hdr_tint_ratio: float = 0, override_settings: Dict[str, Any] = None, override_settings_restore_afterwards: bool = True, sampler_index: int = None, script_args: list = None): # pylint: disable=unused-argument
|
||||
self.outpath_samples: str = outpath_samples
|
||||
self.outpath_grids: str = outpath_grids
|
||||
self.prompt: str = prompt
|
||||
@@ -42,7 +42,8 @@ class StableDiffusionProcessing:
|
||||
self.scale_by: float = scale_by
|
||||
self.image_cfg_scale = image_cfg_scale
|
||||
self.diffusers_guidance_rescale = diffusers_guidance_rescale
|
||||
self.sag_scale = sag_scale
|
||||
self.pag_scale = pag_scale
|
||||
self.pag_adaptive = pag_adaptive
|
||||
self.cfg_end = cfg_end
|
||||
self.width: int = width
|
||||
self.height: int = height
|
||||
|
||||
@@ -365,6 +365,7 @@ def process_diffusers(p: processing.StableDiffusionProcessing):
|
||||
p.extra_generation_params['Sampler options'] = '/'.join(sampler_options)
|
||||
|
||||
def update_pipeline(sd_model, p: processing.StableDiffusionProcessing):
|
||||
"""
|
||||
if p.sag_scale > 0 and is_txt2img():
|
||||
update_sampler(shared.sd_model)
|
||||
supported = ['DDIMScheduler', 'PNDMScheduler', 'DDPMScheduler', 'DEISMultistepScheduler', 'UniPCMultistepScheduler', 'DPMSolverMultistepScheduler', 'DPMSolverSinlgestepScheduler']
|
||||
@@ -376,6 +377,7 @@ def process_diffusers(p: processing.StableDiffusionProcessing):
|
||||
p.task_args['sag_scale'] = p.sag_scale
|
||||
else:
|
||||
shared.log.warning(f'SAG incompatible scheduler: current={sd_model.scheduler.__class__.__name__} supported={supported}')
|
||||
"""
|
||||
if sd_models.get_diffusers_task(sd_model) == sd_models.DiffusersTaskType.INPAINTING and getattr(p, 'image_mask', None) is None and p.task_args.get('image_mask', None) is None and getattr(p, 'mask', None) is None:
|
||||
shared.log.warning('Processing: mode=inpaint mask=None')
|
||||
sd_model = sd_models.set_diffuser_pipe(sd_model, sd_models.DiffusersTaskType.IMAGE_2_IMAGE)
|
||||
|
||||
@@ -479,6 +479,9 @@ options_templates.update(options_section(('advanced', "Inference Settings"), {
|
||||
"freeu_s1": OptionInfo(0.9, "1st stage skip factor", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}),
|
||||
"freeu_s2": OptionInfo(0.2, "2nd stage skip factor", gr.Slider, {"minimum": 0.0, "maximum": 1.0, "step": 0.01}),
|
||||
|
||||
"pag_sep": OptionInfo("<h2>Perturbed-Attention Guidance</h2>", "", gr.HTML),
|
||||
"pag_apply_layers": OptionInfo("m0", "PAG layer names"),
|
||||
|
||||
"hypertile_sep": OptionInfo("<h2>HyperTile</h2>", "", gr.HTML),
|
||||
"hypertile_hires_only": OptionInfo(False, "HyperTile hires pass only"),
|
||||
"hypertile_unet_enabled": OptionInfo(False, "HyperTile UNet"),
|
||||
|
||||
+3
-2
@@ -13,7 +13,7 @@ def txt2img(id_task,
|
||||
steps, sampler_index, hr_sampler_index,
|
||||
full_quality, restore_faces, tiling, hidiffusion,
|
||||
n_iter, batch_size,
|
||||
cfg_scale, image_cfg_scale, diffusers_guidance_rescale, sag_scale, cfg_end,
|
||||
cfg_scale, image_cfg_scale, diffusers_guidance_rescale, pag_scale, pag_adaptive, cfg_end,
|
||||
clip_skip,
|
||||
seed, subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w,
|
||||
height, width,
|
||||
@@ -57,7 +57,8 @@ def txt2img(id_task,
|
||||
cfg_scale=cfg_scale,
|
||||
image_cfg_scale=image_cfg_scale,
|
||||
diffusers_guidance_rescale=diffusers_guidance_rescale,
|
||||
sag_scale=sag_scale,
|
||||
pag_scale=pag_scale,
|
||||
pag_adaptive=pag_adaptive,
|
||||
cfg_end=cfg_end,
|
||||
clip_skip=clip_skip,
|
||||
width=width,
|
||||
|
||||
@@ -113,7 +113,7 @@ def create_ui(_blocks: gr.Blocks=None):
|
||||
|
||||
mask_controls = masking.create_segment_ui()
|
||||
|
||||
cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, sag_scale, cfg_end = ui_sections.create_advanced_inputs('control')
|
||||
cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, pag_scale, pag_adaptive, cfg_end = ui_sections.create_advanced_inputs('control')
|
||||
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundry, hdr_color_picker, hdr_tint_ratio, = ui_sections.create_correction_inputs('control')
|
||||
|
||||
with gr.Accordion(open=False, label="Video", elem_id="control_video", elem_classes=["small-accordion"]):
|
||||
@@ -500,7 +500,7 @@ def create_ui(_blocks: gr.Blocks=None):
|
||||
prompt, negative, styles,
|
||||
steps, sampler_index,
|
||||
seed, subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w,
|
||||
cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, sag_scale, cfg_end, full_quality, restore_faces, tiling, hidiffusion,
|
||||
cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, pag_scale, pag_adaptive, cfg_end, full_quality, restore_faces, tiling, hidiffusion,
|
||||
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundry, hdr_color_picker, hdr_tint_ratio,
|
||||
resize_mode_before, resize_name_before, width_before, height_before, scale_by_before, selected_scale_tab_before,
|
||||
resize_mode_after, resize_name_after, width_after, height_after, scale_by_after, selected_scale_tab_after,
|
||||
|
||||
@@ -132,7 +132,7 @@ def create_ui():
|
||||
denoising_strength = gr.Slider(minimum=0.0, maximum=0.99, step=0.01, label='Denoising strength', value=0.50, elem_id="img2img_denoising_strength")
|
||||
refiner_start = gr.Slider(minimum=0.0, maximum=1.0, step=0.05, label='Denoise start', value=0.0, elem_id="img2img_refiner_start")
|
||||
|
||||
cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, sag_scale, cfg_end = ui_sections.create_advanced_inputs('img2img')
|
||||
cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, pag_scale, pag_adaptive, cfg_end = ui_sections.create_advanced_inputs('img2img')
|
||||
full_quality, restore_faces, tiling, hidiffusion = ui_sections.create_options('img2img')
|
||||
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundry, hdr_color_picker, hdr_tint_ratio, = ui_sections.create_correction_inputs('img2img')
|
||||
|
||||
@@ -183,7 +183,7 @@ def create_ui():
|
||||
full_quality, restore_faces, tiling, hidiffusion,
|
||||
batch_count, batch_size,
|
||||
cfg_scale, image_cfg_scale,
|
||||
diffusers_guidance_rescale, sag_scale, cfg_end,
|
||||
diffusers_guidance_rescale, pag_scale, pag_adaptive, cfg_end,
|
||||
refiner_start,
|
||||
clip_skip,
|
||||
denoising_strength,
|
||||
|
||||
@@ -167,10 +167,12 @@ def create_advanced_inputs(tab, base=True):
|
||||
with gr.Row():
|
||||
image_cfg_scale = gr.Slider(minimum=0.0, maximum=30.0, step=0.1, label='Secondary guidance', value=6.0, elem_id=f"{tab}_image_cfg_scale")
|
||||
diffusers_guidance_rescale = gr.Slider(minimum=0.0, maximum=1.0, step=0.05, label='Rescale guidance', value=0.7, elem_id=f"{tab}_image_cfg_rescale", visible=shared.backend == shared.Backend.DIFFUSERS)
|
||||
diffusers_sag_scale = gr.Slider(minimum=0.0, maximum=1.0, step=0.05, label='Attention guidance', value=0.0, elem_id=f"{tab}_image_sag_scale", visible=shared.backend == shared.Backend.DIFFUSERS)
|
||||
with gr.Row():
|
||||
diffusers_pag_scale = gr.Slider(minimum=0.0, maximum=30.0, step=0.05, label='Attention guidance', value=0.0, elem_id=f"{tab}_image_pag_scale", visible=shared.backend == shared.Backend.DIFFUSERS)
|
||||
diffusers_pag_adaptive = gr.Slider(minimum=0.0, maximum=1.0, step=0.05, label='Adaptive scaling', value=0.5, elem_id=f"{tab}_image_pag_scale", visible=shared.backend == shared.Backend.DIFFUSERS)
|
||||
with gr.Row():
|
||||
clip_skip = gr.Slider(label='CLIP skip', value=1, minimum=0, maximum=12, step=0.1, elem_id=f"{tab}_clip_skip", interactive=True)
|
||||
return cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, diffusers_sag_scale, cfg_end
|
||||
return cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, diffusers_pag_scale, diffusers_pag_adaptive, cfg_end
|
||||
|
||||
|
||||
def create_correction_inputs(tab):
|
||||
|
||||
@@ -46,7 +46,7 @@ def create_ui():
|
||||
with gr.Accordion(open=False, label="Samplers", elem_classes=["small-accordion"], elem_id="txt2img_sampler_group"):
|
||||
ui_sections.create_sampler_options('txt2img')
|
||||
seed, reuse_seed, subseed, reuse_subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w = ui_sections.create_seed_inputs('txt2img')
|
||||
_cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, sag_scale, _cfg_end = ui_sections.create_advanced_inputs('txt2img', base=False)
|
||||
_cfg_scale, clip_skip, image_cfg_scale, diffusers_guidance_rescale, pag_scale, pag_adaptive, _cfg_end = ui_sections.create_advanced_inputs('txt2img', base=False)
|
||||
hdr_mode, hdr_brightness, hdr_color, hdr_sharpen, hdr_clamp, hdr_boundary, hdr_threshold, hdr_maximize, hdr_max_center, hdr_max_boundry, hdr_color_picker, hdr_tint_ratio, = ui_sections.create_correction_inputs('txt2img')
|
||||
enable_hr, hr_sampler_index, denoising_strength, hr_upscaler, hr_force, hr_second_pass_steps, hr_scale, hr_resize_x, hr_resize_y, refiner_steps, refiner_start, refiner_prompt, refiner_negative = ui_sections.create_hires_inputs('txt2img')
|
||||
override_settings = ui_common.create_override_inputs('txt2img')
|
||||
@@ -65,7 +65,7 @@ def create_ui():
|
||||
steps, sampler_index, hr_sampler_index,
|
||||
full_quality, restore_faces, tiling, hidiffusion,
|
||||
batch_count, batch_size,
|
||||
cfg_scale, image_cfg_scale, diffusers_guidance_rescale, sag_scale, cfg_end,
|
||||
cfg_scale, image_cfg_scale, diffusers_guidance_rescale, pag_scale, pag_adaptive, cfg_end,
|
||||
clip_skip,
|
||||
seed, subseed, subseed_strength, seed_resize_from_h, seed_resize_from_w,
|
||||
height, width,
|
||||
|
||||
@@ -17,6 +17,7 @@ exclude = [
|
||||
"modules/xadapter/*.py",
|
||||
"modules/hidiffusion/*.py",
|
||||
"modules/tcd/*.py",
|
||||
"modules/pag/pipe_*.py",
|
||||
]
|
||||
[tool.ruff.lint]
|
||||
select = [
|
||||
|
||||
@@ -21,6 +21,12 @@ def apply_field(field):
|
||||
return fun
|
||||
|
||||
|
||||
def apply_task_args(field):
|
||||
def fun(p, x, xs):
|
||||
p.task_args[field] = x
|
||||
return fun
|
||||
|
||||
|
||||
def apply_setting(field):
|
||||
def fun(p, x, xs):
|
||||
shared.opts.data[field] = x
|
||||
@@ -280,6 +286,9 @@ axis_options = [
|
||||
AxisOption("[HiDiffusion] T1", float, apply_override('hidiffusion_t1')),
|
||||
AxisOption("[HiDiffusion] T2", float, apply_override('hidiffusion_t2')),
|
||||
AxisOption("[HiDiffusion] Agression step", float, apply_field('hidiffusion_steps')),
|
||||
AxisOption("[PAG] Attention scale", float, apply_field('pag_scale')),
|
||||
AxisOption("[PAG] Adaptive scaling", float, apply_field('pag_adaptive')),
|
||||
AxisOption("[PAG] Applied layers", str, apply_setting('pag_apply_layers')),
|
||||
]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user