commit 0b7589225ac8da1a38399b4b059984f4fb26ce5b Author: Antonio Cordero Balcazar Date: Thu May 11 16:12:40 2023 +0200 Initial version diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0575a0b --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +scripts/__pycache__ diff --git a/README.md b/README.md new file mode 100644 index 0000000..0ad8105 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ +# Send To Negative + +## Purpose + +This extension allows the use of negative weights in the prompt and moves them to the negative prompt. This allows useful tricks when using a wildcard extension since you can add negative parts from the positive prompt. It will process recursive weights (one inside of another), but won't calculate the multiplied weights. + +The extension must be loaded after the wildcard extension. With the "Dynamic Prompts" extension this happens by default due to both extensions default folder names. diff --git a/scripts/sendtonegative.py b/scripts/sendtonegative.py new file mode 100644 index 0000000..c05c89c --- /dev/null +++ b/scripts/sendtonegative.py @@ -0,0 +1,45 @@ +import logging +from modules.processing import StableDiffusionProcessing +import modules.scripts as scripts +import re + +VERSION = '0.1' + +logger = logging.getLogger(__name__) +logger.setLevel(logging.DEBUG) + +class Script(scripts.Script): + def __init__(self): + pass + + def title(self): + return f"SendToNegative v{VERSION}" + + def show(self, is_img2img): + return scripts.AlwaysVisible + + def process(self, p: StableDiffusionProcessing, *args, **kwargs): + try: + find = r"(((?