From 18f7dca62efe0b68d59b8befba386cff1f10466a Mon Sep 17 00:00:00 2001 From: Lee Date: Mon, 10 Mar 2025 11:26:34 -0500 Subject: [PATCH] Update image_and_text_description_by_seed.py --- nodes/image_and_text_description_by_seed.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nodes/image_and_text_description_by_seed.py b/nodes/image_and_text_description_by_seed.py index 0a5b5bb..3880857 100644 --- a/nodes/image_and_text_description_by_seed.py +++ b/nodes/image_and_text_description_by_seed.py @@ -45,7 +45,7 @@ class ImageAndTextDescriptionBySeed: if not files: raise ValueError("No image files found in the directory.") - # Calculate the index based on the seed + # Calculate the index based on the seed for the image index = seed % len(files) image_path = os.path.join(directory, files[index]) @@ -77,11 +77,12 @@ class ImageAndTextDescriptionBySeed: metadata = '' raw_metadata = '' - # Get the first text file in the directory + # Select text file based on the seed text_files = [f for f in os.listdir(directory) if os.path.isfile(os.path.join(directory, f)) and f.lower().endswith('.txt')] if text_files: - text_file = text_files[0] + text_index = seed % len(text_files) + text_file = text_files[text_index] text_path = os.path.join(directory, text_file) with open(text_path, 'r', encoding='utf-8') as f: text_content = f.read() @@ -107,7 +108,6 @@ class ImageAndTextDescriptionBySeed: path = os.path.abspath(path) return path - NODE_CLASS_MAPPINGS = { "ImageAndTextDescriptionBySeed": ImageAndTextDescriptionBySeed }