Changing the new version of View Text to be View Anything As Text, and including an old version of View Text, because otherwise it badly breaks any workflows with the old version.

This commit is contained in:
arcum42
2025-03-20 17:20:58 -07:00
parent 9e4e303749
commit 9399d5a8bb
5 changed files with 38 additions and 9 deletions
+4 -2
View File
@@ -16,7 +16,7 @@ Now, you could just write out the metadata by hand, but you probably want that a
Either are going to need inputs from several places, and I had to make custom versions of several nodes to get it.
For the "model_info" parameter, you need to hook it to one of my custom nodes for loading a checkpoint. There's "Load Checkpoint w/ Metadata", "Load Recently Used Checkpoint", and "Load Diffusion Model w/ Metadata".
for the "model_info" parameter, you can either get it from a "Checkpoint Info" node, or hook it to one of my custom nodes for loading a checkpoint. There's "Load Checkpoint w/ Metadata", "Load Recently Used Checkpoint", and "Load Diffusion Model w/ Metadata".
The first is a normal node for loading a checkpoint, just with an added "model_info" output. It *is* going to hash the model the first time you load it and save it to a cache, and it also checks civitai for information on the model, as I'm writing in the Civitai Resources section in the metadata, with model and version id. It also saves the last time you loaded it. Model information is saved in "sage_cache.json", which you might find useful. Indeed, a friend of mine wrote a [useful script](https://github.com/tecknight/comfy_model_html) to generate a model/lora report from it.
@@ -30,9 +30,11 @@ I've got a "Simple Lora Stack" node, which lets you set a lora and weights, and
The lora_stack then needs to go to a "Lora Stack Loader" node. Pipe your model, clip, and the lora_stack through this node, and it'll load all the loras in the stack. Make sure to also hook the lora_stack to the construct node if you want them showing up in the metadata.
You could also use the "Model + Lora Stack Loader" node instead, which accepts a model_info input as well, and loads both the checkpoint and the lora.
Alternative nodes for this are in [ComfyUI-Lora-Auto-Trigger-Words](https://github.com/idrirap/ComfyUI-Lora-Auto-Trigger-Words) and [Comfyroll Studio](https://github.com/Suzie1/ComfyUI_Comfyroll_CustomNodes) and others.
In order for it to print your KSampler information, it'll need to get that as well, and that's what the "Sampler Info" node is for. I've *also* added a "KSampler w/ Sampler Info" node, so you can hook the info node to both the KSampler and the Construct node.
In order for it to print your KSampler information, it'll need to get that as well, and that's what the "Sampler Info" node is for. I've *also* added a "KSampler w/ Sampler Info" node, so you can hook the info node to both the KSampler and the Construct node. Or there's the "KSampler + Decoder" nodes, if you want to decode the VAE at the same time.
Another area where this can be quite useful is hooking the same "Sampler Info" node to *multiple* KSamplers.
+2
View File
@@ -34,6 +34,7 @@ NODE_CLASS_MAPPINGS = {
"Sage_TripleJoinText": Sage_TripleJoinText,
"Sage_CleanText": Sage_CleanText,
"Sage_ViewText": Sage_ViewText,
"Sage_ViewAnything": Sage_ViewAnything,
"Sage_PonyPrefix": Sage_PonyPrefix,
# Model nodes
@@ -104,6 +105,7 @@ NODE_DISPLAY_NAME_MAPPINGS = {
"Sage_TripleJoinText": "Join Text x3",
"Sage_CleanText": "Clean Text",
"Sage_ViewText": "View Text",
"Sage_ViewAnything": "View Any Node as Text",
"Sage_PonyPrefix": "Add Pony v6 Prefixes",
# Model nodes
+1 -1
View File
@@ -39,7 +39,7 @@ app.registerExtension({
//console.log("Foobar node created!");
};
}
if (nodeData.name == "Sage_ViewText") {
if ((nodeData.name == "Sage_ViewText") || (nodeData.name == "Sage_ViewAnything")) {
const onNodeCreated = nodeType.prototype.onNodeCreated;
nodeType.prototype.onNodeCreated = function () {
onNodeCreated ? onNodeCreated.apply(this, []) : undefined;
+3
View File
@@ -226,6 +226,9 @@ class Sage_ModelLoraStackLoader(Sage_LoraStackLoader):
return out[:3]
def load_everything(self, model_info, lora_stack=None):
if model_info["type"] != "CKPT":
raise ValueError("Clip information is missing. Please use a checkpoint for model_info, not a diffusion model.")
pbar = comfy.utils.ProgressBar(len(lora_stack) + 1)
model, clip, vae = self.load_checkpoint(model_info["path"])
pbar.update(1)
+28 -6
View File
@@ -98,7 +98,29 @@ class Sage_ViewText(ComfyNodeABC):
def INPUT_TYPES(s):
return {
"required": {
"text": (IO.ANY, {"forceInput": True, "multiline": True})
"text": ("STRING", {"forceInput": True, "multiline": True})
}
}
RETURN_TYPES = ("STRING",)
FUNCTION = "show_text"
CATEGORY = "Sage Utils/text"
DESCRIPTION = "Shows some text."
OUTPUT_NODE = True
def show_text(self, text):
print(f"String is '{text}'")
return { "ui": {"text": text}, "result" : (text,) }
class Sage_ViewAnything(ComfyNodeABC):
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"any": (IO.ANY, {"forceInput": True, "multiline": True})
}
}
@@ -111,15 +133,15 @@ class Sage_ViewText(ComfyNodeABC):
OUTPUT_NODE = True
INPUT_IS_LIST = True
def show_text(self, text):
print(f"Text is '{text}'")
def show_text(self, any):
print(f"Text is '{any}'")
str = ""
if isinstance(text, list):
for t in text:
if isinstance(any, list):
for t in any:
str += f"{t}\n"
print(f"String is '{t}'")
else:
str = text
str = any
print(f"String is '{str}'")
return { "ui": {"text": str}, "result" : (str,) }