Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
68766215f2 | ||
|
|
287f554a68 | ||
|
|
71465f914c |
@@ -598,9 +598,10 @@ def encode_prompt(clip, text, start_pct, end_pct, defaults, masks):
|
||||
return c
|
||||
|
||||
def couple_mask(args):
|
||||
if args is None:
|
||||
assert len(args) <= 1, "Argument parsing failure. This is a bug in Prompt Control"
|
||||
if not args:
|
||||
return ""
|
||||
return f"MASK({args})"
|
||||
return f"MASK({args[0]})"
|
||||
|
||||
for prompt in prompts:
|
||||
base_prompt, attn_couple_prompts = split_by_function(prompt, "COUPLE", defaults=None, require_args=False)
|
||||
|
||||
@@ -20,6 +20,12 @@ def run(f, *args):
|
||||
return getattr(f, f.FUNCTION)(*args)
|
||||
|
||||
|
||||
def compare_hookgroup_mask(h1, h2):
|
||||
assert len(h1.hooks) == len(h2.hooks)
|
||||
for a, b in zip(h1.hooks, h2.hooks):
|
||||
assert (a.mask == b.mask).all()
|
||||
|
||||
|
||||
@mock.patch("torch.cuda.current_device", lambda: "cpu")
|
||||
class TestEncode(unittest.TestCase):
|
||||
@classmethod
|
||||
@@ -172,6 +178,16 @@ class TestEncode(unittest.TestCase):
|
||||
(c2,) = run(pc, clip, "test COUPLE prompt1 COUPLE test2 COUPLE prompt2")
|
||||
self.assertTrue(len(c) == 2)
|
||||
self.assertTrue(len(c2) == 1)
|
||||
with self.subTest(f"Testing {k} mask shortcut"):
|
||||
(c,) = run(pc, clip, "test COUPLE() prompt1")
|
||||
(c2,) = run(pc, clip, "test COUPLE MASK() prompt1")
|
||||
self.condEqual(c, c2)
|
||||
self.condEqual(c, c2, "hooks", compare_hookgroup_mask)
|
||||
with self.subTest(f"Testing {k} mask shortcut 2"):
|
||||
(c,) = run(pc, clip, "test COUPLE(0 0.2, 0.5) prompt1")
|
||||
(c2,) = run(pc, clip, "test COUPLE MASK(0 0.2, 0.5) prompt1")
|
||||
self.condEqual(c, c2)
|
||||
self.condEqual(c, c2, "hooks", compare_hookgroup_mask)
|
||||
|
||||
def test_styles(self):
|
||||
pc = PCTextEncode()
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
[project]
|
||||
name = "comfyui-prompt-control"
|
||||
description = "Provides nodes for prompt editing and LoRA scheduling, advanced regional prompting (including attention masking) and more, all controlled through your text prompt"
|
||||
version = "2.1.2"
|
||||
version = "2.1.3"
|
||||
license = { file = "LICENSE" }
|
||||
# some lark versions older than 1.1.9 apparently have a bug that breaks things, see https://github.com/asagi4/comfyui-prompt-control/issues/35
|
||||
dependencies = ["lark >= 1.1.9"]
|
||||
|
||||
Reference in New Issue
Block a user