From a59ea08ea6fd6d4e18285027f28661aed90b21bb Mon Sep 17 00:00:00 2001 From: pacchikAI Date: Sun, 11 May 2025 20:53:05 +0000 Subject: [PATCH] Add files via upload --- __init__.py | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 __init__.py diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..7cf4335 --- /dev/null +++ b/__init__.py @@ -0,0 +1,53 @@ +import os +import csv + +class LoadImageandPrompt: + + def __init__(self): + pass + + + @classmethod + def INPUT_TYPES(s): + return { + "required": { + "FolderLocation": ("STRING",), + "PromptFileName": ("STRING", ), + "index": ("INT",), + }, + } + + RETURN_TYPES = ("STRING","STRING") + RETURN_NAMES = ("Image Name", "Prompt") + + + FUNCTION = "LoadImageandPrompt" + + CATEGORY = "LoadImageandPrompt" + + def LoadImageandPrompt(self, index, FolderLocation, PromptFileName): + PromptFileName = FolderLocation + PromptFileName + with open(PromptFileName, 'r', newline='', encoding='utf-8') as csvfile: + reader = csv.reader(csvfile) + + header = next(reader, None) + + for row in reader: + if len(row) >= 3: # Ensure row has at least 3 columns + if str(index) == row[0]: + return FolderLocation+row[1], row[2] # Return image_name and prompt + + + print(f"No entry found with index {index}") + return None, None + +NODE_CLASS_MAPPINGS = { + "LoadImageandPrompt": LoadImageandPrompt + +} + +# A dictionary that contains the friendly/humanly readable titles for the nodes +NODE_DISPLAY_NAME_MAPPINGS = { + "LoadImageandPrompt": "Load Image and Prompt", + +}