mirror of
https://github.com/vladmandic/automatic
synced 2026-09-18 16:54:33 +02:00
Adjust clip skip to expected range
This commit is contained in:
@@ -174,9 +174,7 @@ def process_diffusers(p: processing.StableDiffusionProcessing):
|
||||
generator = [torch.Generator(generator_device).manual_seed(s) for s in p.seeds]
|
||||
prompts, negative_prompts, prompts_2, negative_prompts_2 = fix_prompts(prompts, negative_prompts, prompts_2, negative_prompts_2)
|
||||
parser = 'Fixed attention'
|
||||
clip_skip = kwargs.pop("clip_skip", None)
|
||||
if clip_skip is not None and 'XL' in model.__class__.__name__:
|
||||
clip_skip -= 1
|
||||
clip_skip = kwargs.pop("clip_skip", 1)
|
||||
if shared.opts.prompt_attention != 'Fixed attention' and 'StableDiffusion' in model.__class__.__name__ and 'Onnx' not in model.__class__.__name__:
|
||||
try:
|
||||
prompt_parser_diffusers.encode_prompts(model, p, prompts, negative_prompts, steps=kwargs.get("num_inference_steps", 1), clip_skip=clip_skip)
|
||||
@@ -186,8 +184,10 @@ def process_diffusers(p: processing.StableDiffusionProcessing):
|
||||
if os.environ.get('SD_PROMPT_DEBUG', None) is not None:
|
||||
errors.display(e, 'Prompt parser encode')
|
||||
if parser == 'Fixed attention':
|
||||
if clip_skip is not None:
|
||||
args['clip_skip'] = clip_skip
|
||||
if clip_skip == 1:
|
||||
pass # clip_skip = None
|
||||
else:
|
||||
args['clip_skip'] = clip_skip - 1
|
||||
if 'prompt' in possible:
|
||||
if hasattr(model, 'text_encoder') and 'prompt_embeds' in possible and len(p.prompt_embeds) > 0 and p.prompt_embeds[0] is not None:
|
||||
args['prompt_embeds'] = p.prompt_embeds[0]
|
||||
|
||||
@@ -140,7 +140,7 @@ def prepare_embedding_providers(pipe, clip_skip):
|
||||
device = pipe.device if str(pipe.device) != 'meta' else devices.device
|
||||
embeddings_providers = []
|
||||
if 'XL' in pipe.__class__.__name__:
|
||||
embedding_type = -clip_skip
|
||||
embedding_type = -(clip_skip + 1)
|
||||
else:
|
||||
embedding_type = clip_skip
|
||||
if hasattr(pipe, "tokenizer") and hasattr(pipe, "text_encoder"):
|
||||
|
||||
+1
-1
@@ -374,7 +374,7 @@ options_templates.update(options_section(('cuda', "Compute Settings"), {
|
||||
"cuda_compile": OptionInfo([] if not cmd_opts.use_openvino else ["Model", "VAE", "Upscaler"], "Compile Model", gr.CheckboxGroup, {"choices": ["Model", "VAE", "Text Encoder", "Upscaler"]}),
|
||||
"cuda_compile_backend": OptionInfo("none" if not cmd_opts.use_openvino else "openvino_fx", "Model compile backend", gr.Radio, {"choices": ['none', 'inductor', 'cudagraphs', 'aot_ts_nvfuser', 'hidet', 'ipex', 'openvino_fx', 'stable-fast', 'deep-cache', 'olive-ai']}),
|
||||
"cuda_compile_mode": OptionInfo("default", "Model compile mode", gr.Radio, {"choices": ['default', 'reduce-overhead', 'max-autotune', 'max-autotune-no-cudagraphs']}),
|
||||
"cuda_compile_fullgraph": OptionInfo(True, "Model compile fullgraph"),
|
||||
"cuda_compile_fullgraph": OptionInfo(True if not cmd_opts.use_openvino else False, "Model compile fullgraph"),
|
||||
"cuda_compile_precompile": OptionInfo(False, "Model compile precompile"),
|
||||
"cuda_compile_verbose": OptionInfo(False, "Model compile verbose mode"),
|
||||
"cuda_compile_errors": OptionInfo(True, "Model compile suppress errors"),
|
||||
|
||||
Reference in New Issue
Block a user