diff --git a/__init__.py b/__init__.py index 17ed4a4..358f913 100644 --- a/__init__.py +++ b/__init__.py @@ -5,6 +5,7 @@ import comfy.utils import logging import re from comfy.sd1_clip import token_weights, escape_important, unescape_important +from .nodes_debug import PromptEmbeddingFixer, InspectEmbeddingForClip def tokenize_preserving_weights(clip, text): """ @@ -875,6 +876,8 @@ NODE_CLASS_MAPPINGS = { "SaveWeightedEmbeddings": SaveWeightedEmbeddings, "SaveA1111WeightedEmbeddings": SaveA1111WeightedEmbeddings, "SliceExistingEmbedding": SliceExistingEmbedding, + "PromptEmbeddingFixer": PromptEmbeddingFixer, + "InspectEmbeddingForClip": InspectEmbeddingForClip, } NODE_DISPLAY_NAME_MAPPINGS = { @@ -882,6 +885,8 @@ NODE_DISPLAY_NAME_MAPPINGS = { "SaveWeightedEmbeddings": "Save Weighted Embeddings", "SaveA1111WeightedEmbeddings": "Save A1111-style Weighted Embeddings", "SliceExistingEmbedding": "Slice Existing Embedding File", + "PromptEmbeddingFixer": "Prompt Embedding Fixer", + "InspectEmbeddingForClip": "Inspect Embedding For Clip", } __all__ = ['NODE_CLASS_MAPPINGS', 'NODE_DISPLAY_NAME_MAPPINGS'] \ No newline at end of file diff --git a/nodes_debug.py b/nodes_debug.py new file mode 100644 index 0000000..1a97741 --- /dev/null +++ b/nodes_debug.py @@ -0,0 +1,152 @@ +import torch +import os +import folder_paths +import comfy.utils +import re + +class PromptEmbeddingFixer: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "text": ("STRING", {"multiline": True, "dynamicPrompts": True}), + } + } + + RETURN_TYPES = ("STRING",) + FUNCTION = "fix_prompt" + CATEGORY = "EmbeddingToolkit/Utils" + + def fix_prompt(self, text): + # Add space before embedding if missing + text = re.sub(r'(?= 2: + output_text.append(f" [CHECK] Checking single tensor fallback...") + if val.shape[-1] == expected_size: + output_text.append(f" [OK] Fallback match! Shape: {val.shape}") + match_found = True + else: + output_text.append(f" [FAIL] Fallback mismatch. {val.shape[-1]} vs {expected_size}") + + if not match_found: + output_text.append(f" [INFO] No compatible embedding found for this component.") + + except Exception as e: + output_text.append(f" Error inspecting model component: {e}") + else: + output_text.append(" (No transformer found)") + + return {"ui": {"text": ["\n".join(output_text)]}} + +NODE_CLASS_MAPPINGS = { + "PromptEmbeddingFixer": PromptEmbeddingFixer, + "InspectEmbeddingForClip": InspectEmbeddingForClip, +} +NODE_DISPLAY_NAME_MAPPINGS = { + "PromptEmbeddingFixer": "Prompt Embedding Fixer", + "InspectEmbeddingForClip": "Inspect Embedding For Clip", +}