Skip to content

Commit

Permalink
Ass DarkPopLoraFromStack
Browse files Browse the repository at this point in the history
  • Loading branch information
darkpixel committed Nov 19, 2024
1 parent 3fff434 commit 4063689
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"DarkCheckpointSwitcher": checkpoints.DarkCheckpointSwitcher,
"DarkAnyToString": convert.DarkAnyToString,
"DarkLoraStackFromString": loras.DarkLoraStackFromString,
"DarkPopLoraFromStack": loras.DarkPopLoraFromStack,
}

NODE_DISPLAY_NAME_MAPPINGS = {
Expand All @@ -31,6 +32,7 @@
"DarkCheckpointSwitcher": "Dark Checkpoint Switcher",
"DarkAnyToString": "Dark Any to String",
"DarkLoraStackFromString": "Dark LoRA Stack from String",
"DarkPopLoraFromStack": "Dark LoRA Pop LoRA string from LORA_STACK",
}

__all__ = [NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS]
42 changes: 42 additions & 0 deletions modules/loras.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,48 @@
logger = logging.getLogger(__name__)


class DarkPopLoraFromStack(object):
"""
Accepts a LoRA stack and extracts the first LoRA it finds, removing it from the stack
"""

def __init__(self):
pass

@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"LORA_STACK": (
"LORA_STACK",
{
"forceInput": True,
},
),
},
}

RETURN_TYPES = (
"LORA_STACK",
"STRING",
)
RETURN_NAMES = ("LORA_STACK", "EXTRACTED_LORA")
FUNCTION = "extract_lora_from_stack"

CATEGORY = "DarkPrompt"

def extract_lora_from_stack(self, LORA_STACK):
print(LORA_STACK)
popped_lora = ""
if LORA_STACK:
popped_lora = LORA_STACK.pop(0)
popped_lora = popped_lora[0]

print(popped_lora)

return (LORA_STACK, popped_lora)


class DarkLoraStackFromString(object):
"""
Takes in a string (prompt), scans it for LoRA tags in the format <lora:somelora:x:y> and creates a LoRA stack from the string
Expand Down

0 comments on commit 4063689

Please sign in to comment.