Skip to content

Commit

Permalink
* Fix problem with seed property in ComfyUI, and allow a value of -1 …
Browse files Browse the repository at this point in the history
…to get a random one.
  • Loading branch information
acorderob committed Sep 4, 2024
1 parent 8a960df commit faa5570
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
8 changes: 6 additions & 2 deletions ppp.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PromptPostProcessor: # pylint: disable=too-few-public-methods,too-many-in
"""

NAME = "Prompt Post-Processor"
VERSION = (2, 5, 0)
VERSION = (2, 5, 1)

class IFWILDCARDS_CHOICES(Enum):
ignore = "ignore"
Expand Down Expand Up @@ -74,7 +74,9 @@ def __init__(
self.wil_process_wildcards = options.get("process_wildcards", True)
self.wil_keep_choices_order = options.get("keep_choices_order", False)
self.wil_choice_separator = options.get("choice_separator", self.DEFAULT_CHOICE_SEPARATOR)
self.wil_ifwildcards = self.IFWILDCARDS_CHOICES(options.get("if_wildcards", self.IFWILDCARDS_CHOICES.ignore.value))
self.wil_ifwildcards = self.IFWILDCARDS_CHOICES(
options.get("if_wildcards", self.IFWILDCARDS_CHOICES.ignore.value)
)
# Send to negative options
self.stn_ignore_repeats = options.get("stn_ignore_repeats", True)
self.stn_join_attention = options.get("stn_join_attention", True)
Expand Down Expand Up @@ -405,6 +407,8 @@ def process_prompt(
tuple: A tuple containing the processed prompt and negative prompt.
"""
try:
if seed == -1:
seed = np.random.randint(0, 2**32)
self.rng = np.random.default_rng(seed & 0xFFFFFFFF)
prompt = original_prompt
negative_prompt = original_negative_prompt
Expand Down
14 changes: 7 additions & 7 deletions ppp_comfyui.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@ def INPUT_TYPES(cls):
"forceInput": True,
},
),
"seed": (
"INT",
{
"default": None,
"forceInput": False,
},
),
"pos_prompt": (
"STRING",
{
Expand All @@ -70,6 +63,13 @@ def INPUT_TYPES(cls):
),
},
"optional": {
"seed": (
"INT",
{
"default": -1,
"forceInput": False,
},
),
"debug_level": (
[e.value for e in DEBUG_LEVEL],
{
Expand Down

0 comments on commit faa5570

Please sign in to comment.