mirror of
https://github.com/vladmandic/automatic
synced 2026-09-20 01:31:13 +02:00
add compel parser
This commit is contained in:
@@ -14,26 +14,19 @@ Stuff to be added...
|
||||
- Add `Gradio` theme maker
|
||||
- Create new `GitHub` hooks/actions for CI/CD
|
||||
- Monitor file changes for misbehaving extensions
|
||||
- Kitchen theme: <https://github.com/canisminor1990/sd-webui-kitchen-theme>
|
||||
- Lightbox improvements
|
||||
- Check duplicate extensions
|
||||
- Reload browser on server restart
|
||||
- Gradio 3.28.4 when ready
|
||||
- Remove origin wiki
|
||||
- Import core repos
|
||||
- Import rembg
|
||||
- Improve core `Stability-AI` code: <https://github.com/vladmandic/automatic/discussions/795>
|
||||
- Improve core `k-Diffusion` code
|
||||
- Update and mdularize `cli` scripts
|
||||
|
||||
## Investigate
|
||||
|
||||
Stuff to be investigated...
|
||||
|
||||
- Torch Compile
|
||||
- TXT2IMG: <https://github.com/vladmandic/automatic/discussions/814>
|
||||
- `TensorRT`
|
||||
- [Temporal Weighing](https://github.com/comfyanonymous/ComfyUI/discussions/473)
|
||||
|
||||
## Merge PRs
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ from collections import namedtuple
|
||||
from typing import List
|
||||
import lark
|
||||
import torch
|
||||
from compel import Compel
|
||||
from modules.shared import log, opts
|
||||
|
||||
# a prompt like this: "fantasy landscape with a [mountain:lake:0.25] and [an oak:a christmas tree:0.75][ in foreground::0.6][ in background:0.25] [shoddy:masterful:0.5]"
|
||||
@@ -289,8 +290,19 @@ def parse_prompt_attention(text):
|
||||
round_brackets = []
|
||||
square_brackets = []
|
||||
if opts.prompt_attention == 'Fixed attention':
|
||||
return [[text, 1.0]]
|
||||
elif opts.prompt_attention == 'Original parser':
|
||||
res = [[text, 1.0]]
|
||||
log.debug(f'Prompt parse-attention: {opts.prompt_attention} {res}')
|
||||
return res
|
||||
elif opts.prompt_attention == 'Compel parser':
|
||||
conjunction = Compel.parse_prompt_string(text)
|
||||
if conjunction is None or conjunction.prompts is None or conjunction.prompts is None or len(conjunction.prompts[0].children) == 0:
|
||||
return [["", 1.0]]
|
||||
res = []
|
||||
for frag in conjunction.prompts[0].children:
|
||||
res.append([frag.text, frag.weight])
|
||||
log.debug(f'Prompt parse-attention: {opts.prompt_attention} {res}')
|
||||
return res
|
||||
elif opts.prompt_attention == 'A1111 parser':
|
||||
re_attention = re_attention_v1
|
||||
whitespace = ''
|
||||
else:
|
||||
@@ -344,7 +356,7 @@ def parse_prompt_attention(text):
|
||||
res.pop(i + 1)
|
||||
else:
|
||||
i += 1
|
||||
log.debug(f'Prompt parse-attention: {res}')
|
||||
log.debug(f'Prompt parse-attention: {opts.prompt_attention} {res}')
|
||||
return res
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
+1
-1
@@ -254,7 +254,7 @@ options_templates.update(options_section(('sd', "Stable Diffusion"), {
|
||||
"sub_quad_kv_chunk_size": OptionInfo(512, "Sub-quadratic cross-attentionkv chunk size for the sub-quadratic cross-attention layer optimization to use", gr.Slider, {"minimum": 0, "maximum": 8192, "step": 8}),
|
||||
"sub_quad_chunk_threshold": OptionInfo(80, "Sub-quadratic cross-attention percentage of VRAM chunking threshold", gr.Slider, {"minimum": 0, "maximum": 100, "step": 1}),
|
||||
"always_batch_cond_uncond": OptionInfo(False, "Disables cond/uncond batching that is enabled to save memory with --medvram or --lowvram"),
|
||||
"prompt_attention": OptionInfo("Full parser", "Prompt attention parser", gr.Radio, lambda: {"choices": ["Fixed attention", "Original parser", "Full parser"] }),
|
||||
"prompt_attention": OptionInfo("Full parser", "Prompt attention parser", gr.Radio, lambda: {"choices": ["Full parser", "Compel parser", "A1111 parser", "Fixed attention"] }),
|
||||
}))
|
||||
|
||||
options_templates.update(options_section(('system-paths', "System Paths"), {
|
||||
|
||||
@@ -45,6 +45,7 @@ voluptuous
|
||||
yapf
|
||||
scikit-image
|
||||
basicsr
|
||||
compel
|
||||
requests==2.30.0
|
||||
tqdm==4.65.0
|
||||
accelerate==0.18.0
|
||||
|
||||
Reference in New Issue
Block a user