comfyanonymous / ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.
https://www.comfy.org/
GNU General Public License v3.0
51.08k stars 5.36k forks source link

need wildcards like "wildcard/dynamic prompt" to reading txt file to prompt #134

Open xueqing0622 opened 1 year ago

xueqing0622 commented 1 year ago

need wildcards like "wildcard/dynamic prompt" to reading txt file to prompt, not just use {day|night} I hope to upgrade it immediately, Thx

WASasquatch commented 1 year ago

I just made a noodle soup parser version of CLIPTextExcode, I just need to update it to run every gen. It is here: https://civitai.com/models/20793/was-node-suites-comfyui

Edit: It's updated and should work every run.

xueqing0622 commented 1 year ago

WASasquatch, Very good tool about wildcards. I can see the text description of our wildcard from the cmd window, but over time, or after I close the cmd window, I can only know what my prompt is through png in the output folder. However, how can I know the prompt? When I drag png to the png info of the auto111 webui, it is complex code that I cannot understand, which is obviously incompatible. Opening png using comfyUI is still show the same NSP CLIPTextEncode node as before,", The prompt inside is still "_xxxx" instead of the generated "xxx". Do you have any way to know the final generated description of prompt Image text

xueqing0622 commented 1 year ago

can you output the txt file same name as image file in the same folder, include the Parsed Prompt: "XXX",

WASasquatch commented 1 year ago

The clip encode node doesn't know what the filename is going to be, so it would have to save in a random filename unless I made a new SaveImage node which can accept text string, and also have clip encoder output text to feed into save image. Sounds more hacky but may work.

On a side note maybe @comfyanonymous knows how to output text to the nodes UI so I can display a preview of the parsed prompt form within ComfyUI? That way you wouldn't need to glance the CMD window too.

xueqing0622 commented 1 year ago

yes, that is good idea, I use your node NSP_CLIPTextEncoder.py to output a txt file, and use the node.py to change the txt name as the image name, it work, but if I use mutil NSP_CLIPTextEncoder nodes I have no idea how to combine them Thx again, A very good node to make random.

WASasquatch commented 1 year ago

yes, that is good idea, I use your node NSP_CLIPTextEncoder.py to output a txt file, and use the node.py to change the txt name as the image name, it work, but if I use mutil NSP_CLIPTextEncoder nodes I have no idea how to combine them Thx again, A very good node to make random.

Mind sharing the code you're talking about? I took a look at the node.py and what I'm confused about, and maybe again, @comfyanonymous could elaborate on is what's going on with the PROMPT variable thingy that's being passed around. Where is that being set? Shouldn't that be set with the CLIPTextEncode node? Also, is there a way to set global constants like that you can pick up anywhere?

I also think it is a bug that I change the prompt within the CLIPTextEncode node, but what is scraped by ComfyUI is the unaltered prompt from the input itself. I feel that should be a fall back like original input versus what a node is doing and sending down the line.

xueqing0622 commented 1 year ago

WASasquatch,, that is the two script I edited from you idea and your script. https://github.com/xueqing0622/testScript I use chatGPT to finish it. I cant write scripts, Hope you can update it better in your way. by the way ,I change output png to jpg. you can change back if you like.

xueqing0622 commented 1 year ago

If you have time or any idea, to get these two useful extension to ComfyUI, That will be cool, master! https://github.com/hnmr293/sd-webui-cutoff https://github.com/ashen-sensored/stable-diffusion-webui-two-shot These are the most import extension to avoid color and prompt pollute each other. Thanks again, to give a node to achieve random wildcard。

WASasquatch commented 1 year ago

If you have time or any idea, to get these two useful extension to ComfyUI, That will be cool, master! https://github.com/hnmr293/sd-webui-cutoff https://github.com/ashen-sensored/stable-diffusion-webui-two-shot These are the most import extension to avoid color and prompt pollute each other. Thanks again, to give a node to achieve random wildcard。

I'll take a look. The deep diving tensor and encoding stuff boggles my brain. No good with math and numbers due to dyscalculia. I mix them up and loose them like I got a hole in my brain. Heh

xueqing0622 commented 1 year ago

Haha, you're too modest I can't even write scripts But I like node programming, which is too interesting and has too many possibilities, I used nodes before when using unity3D (bolt just like ue buleprint)

Neverdusk commented 1 year ago

I'm not too familiar with NSP, but would it be possible to use Dynamic Prompts-style wildcards? Essentially, text files that have a wildcard option on each line, invoked by typing TextFileName into the prompt.

For example, a wildcard file named "color.txt" would have "blue, red, yellow, etc." each written a separate line. And I'd type "a color car" as the prompt to generate a car with a randomly chosen color.

I have a few wildcard text files that I use in Auto1111 but would like to use in ComfyUI somehow. A CLIPTextEncode node that supported that would be incredibly useful, especially if it could read any wildcard files in a given directory.

WASasquatch commented 1 year ago

I'm not too familiar with NSP, but would it be possible to use Dynamic Prompts-style wildcards? Essentially, text files that have a wildcard option on each line, invoked by typing TextFileName into the prompt.

For example, a wildcard file named "color.txt" would have "blue, red, yellow, etc." each written a separate line. And I'd type "a color car" as the prompt to generate a car with a randomly chosen color.

I have a few wildcard text files that I use in Auto1111 but would like to use in ComfyUI somehow. A CLIPTextEncode node that supported that would be incredibly useful, especially if it could read any wildcard files in a given directory.

Someone made a wildcard node for ComfyUI already, though I don't remember it's name. Can't seem to find it searching github thing. Though I did add text nodes to WAS Node Suite which easily allow you to load a file, and set up a search and replace by random line.

Example Wildcard Usage with WAS Node Suite: Screenshot_32

If people really want wildcard support I could look into it. I myself find using one file much easier, and I actually was thinking of adding nodes to add to the pantry, or import wildcards into the pantry, etc, so you wouldn't need a 200 files. Loading files sequentially from disk is a slow task in python as apposed to utilizing a already loaded dictionary.

Neverdusk commented 1 year ago

Thank you for the response, this looks like a really useful workaround! I'll definitely try this.

As for the pantry, I might have to look into it. But I do like wildcards because of how simple they are to use and organize. A single node that could read wildcards from a directory and automatically search and replace any detected wildcard in a prompt would be incredible, if you ever have time to attempt something like that.

lilly1987 commented 1 year ago

is it mine? https://github.com/lilly1987/ComfyUI_node_Lilly

Neverdusk commented 1 year ago

is it mine? https://github.com/lilly1987/ComfyUI_node_Lilly

This might be exactly what I'm looking for. I'll try it out. Thanks!

WASasquatch commented 1 year ago

is it mine? https://github.com/lilly1987/ComfyUI_node_Lilly

There you are. Ok lilly gotta remember that. I'm asked this all the time xD