diff --git a/__init__.py b/__init__.py index a24048d..806009a 100644 --- a/__init__.py +++ b/__init__.py @@ -149,6 +149,7 @@ from .nodes.prompting.FL_MadLibGenerator import FL_MadLibGenerator from .nodes.prompting.FL_Prompt import FL_PromptBasic from .nodes.prompting.FL_PromptMulti import FL_PromptMulti from .nodes.prompting.FL_PromptSelector import FL_PromptSelector +from .nodes.prompting.FL_PromptSelectorBasic import FL_PromptSelectorBasic # UTILITY NODES from .nodes.utility.FL_ClipScanner import FL_ClipScanner @@ -339,6 +340,7 @@ NODE_CLASS_MAPPINGS = { "FL_Fal_Sora": FL_Fal_Sora, "FL_PromptBasic": FL_PromptBasic, "FL_PromptMulti": FL_PromptMulti, + "FL_PromptSelectorBasic": FL_PromptSelectorBasic, "FL_PaddingRemover": FL_PaddingRemover, "FL_GPT_Text": FL_GPT_Text, "FL_GoogleCloudStorage": FL_GoogleCloudStorage, @@ -410,6 +412,7 @@ NODE_DISPLAY_NAME_MAPPINGS = { "FL_HalftonePattern": "FL Halftone", "FL_RandomNumber": "FL Random Number", "FL_PromptSelector": "FL Prompt Selector", + "FL_PromptSelectorBasic": "FL Prompt Selector Basic", "FL_Shadertoy": "FL Shadertoy", "FL_PixelArtShader": "FL Pixel Art", "FL_InfiniteZoom": "FL Infinite Zoom", @@ -513,6 +516,7 @@ NODE_DISPLAY_NAME_MAPPINGS = { "FL_Fal_Sora": "FL Fal Sora 2", "FL_PromptBasic": "FL Prompt Basic", "FL_PromptMulti": "FL Prompt Multi", + "FL_PromptSelectorBasic": "FL Prompt Selector Basic", "FL_PaddingRemover": "FL Padding Remover", "FL_GPT_Text": "FL GPT Text", "FL_GoogleCloudStorage": "FL Google Cloud Storage Uploader", diff --git a/nodes/prompting/FL_PromptSelector.py b/nodes/prompting/FL_PromptSelector.py index 101f361..eb7da39 100644 --- a/nodes/prompting/FL_PromptSelector.py +++ b/nodes/prompting/FL_PromptSelector.py @@ -22,8 +22,8 @@ class FL_PromptSelector: num_prompts = len(prompt_lines) - if index < 0 or index >= num_prompts: - raise ValueError(f"Index {index} is out of range. Please provide an index between 0 and {num_prompts - 1}.") + # Loop through prompts using modulo + index = index % num_prompts selected_prompt = prompt_lines[index].strip() diff --git a/nodes/prompting/FL_PromptSelectorBasic.py b/nodes/prompting/FL_PromptSelectorBasic.py new file mode 100644 index 0000000..31ec169 --- /dev/null +++ b/nodes/prompting/FL_PromptSelectorBasic.py @@ -0,0 +1,34 @@ +class FL_PromptSelectorBasic: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "prompts": ("STRING", {"multiline": True}), + "index": ("INT", {"default": 0, "min": 0, "max": 6969, "step": 1}), + }, + } + + RETURN_TYPES = ("STRING",) + FUNCTION = "select_prompt" + CATEGORY = "🏵️Fill Nodes/Prompting" + + def select_prompt(self, prompts, index): + prompt_lines = prompts.split("\n") + + num_prompts = len(prompt_lines) + + # Loop through prompts using modulo + index = index % num_prompts + + selected_prompt = prompt_lines[index].strip() + + return (selected_prompt,) + + +NODE_CLASS_MAPPINGS = { + "FL_PromptSelectorBasic": FL_PromptSelectorBasic, +} + +NODE_DISPLAY_NAME_MAPPINGS = { + "FL_PromptSelectorBasic": "Prompt Selector Basic 🏵️", +} diff --git a/nodes/wip/FL_QwenImageEditStrength.py b/nodes/wip/FL_QwenImageEditStrength.py index c6a2088..60becb7 100644 --- a/nodes/wip/FL_QwenImageEditStrength.py +++ b/nodes/wip/FL_QwenImageEditStrength.py @@ -55,11 +55,25 @@ class FL_QwenImageEditStrength: images_vl = [] llama_template = "<|im_start|>system\nDescribe the key features of the input image (color, shape, size, texture, objects, background), then explain how the user's text instruction should alter or modify the image. Generate a new image that meets the user's requirements while maintaining consistency with the original input where appropriate.<|im_end|>\n<|im_start|>user\n{}<|im_end|>\n<|im_start|>assistant\n" image_prompt = "" + image_dimensions = None # Track first image dimensions for validation for i, (image, strength) in enumerate(images): if image is not None: samples = image.movedim(-1, 1) + # Validate that all images have the same dimensions when using VAE + if vae is not None: + current_dims = (samples.shape[2], samples.shape[3]) # (height, width) + if image_dimensions is None: + image_dimensions = current_dims + elif current_dims != image_dimensions: + raise ValueError( + f"Image size mismatch: Image {i+1} has dimensions {current_dims[0]}x{current_dims[1]}, " + f"but the first image has dimensions {image_dimensions[0]}x{image_dimensions[1]}. " + f"All images must have the same dimensions when using VAE encoding. " + f"Please resize your images to match before connecting them to this node." + ) + # Resize for vision model (384x384) total = int(384 * 384) scale_by = math.sqrt(total / (samples.shape[3] * samples.shape[2])) @@ -69,15 +83,9 @@ class FL_QwenImageEditStrength: s = comfy.utils.common_upscale(samples, width, height, "area", "disabled") images_vl.append(s.movedim(1, -1)) - # Encode to latents if VAE is provided + # Encode to latents if VAE is provided (using original dimensions) if vae is not None: - total = int(1024 * 1024) - scale_by = math.sqrt(total / (samples.shape[3] * samples.shape[2])) - width = round(samples.shape[3] * scale_by / 8.0) * 8 - height = round(samples.shape[2] * scale_by / 8.0) * 8 - - s = comfy.utils.common_upscale(samples, width, height, "area", "disabled") - latent = vae.encode(s.movedim(1, -1)[:, :, :, :3]) + latent = vae.encode(samples.movedim(1, -1)[:, :, :, :3]) individual_latents.append(latent) strengths.append(strength) diff --git a/pyproject.toml b/pyproject.toml index b7b24da..05f7acd 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui_fill-nodes" description = "Fill-Nodes is a versatile collection of custom nodes for ComfyUI that extends functionality across multiple domains. Features include advanced image processing (pixelation, slicing, masking), visual effects generation (glitch, halftone, pixel art), comprehensive file handling (PDF creation/extraction, Google Drive integration), AI model interfaces (GPT, DALL-E, Hugging Face), utility nodes for workflow enhancement, and specialized tools for video processing, captioning, and batch operations. The pack provides both practical workflow solutions and creative tools within a unified node collection." -version = "1.9.9" +version = "2.0.0" license = "LICENSE" dependencies = ["diffusers", "librosa", "sounddevice", "glitch_this", "PyOpenGL", "glfw", "scipy>=1.13.1", "requests", "aiohttp", "moviepy", "matplotlib", "reportlab", "openai", "PyPDF2", "pdf2image", "PyMuPDF", "reportlab", "PyPDF2", "ollama", "kornia", "opencv-python", "gdown", "open_clip_torch", "google-genai"]