-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What the best way to batch generate multiple images with different parameters? #1330
Comments
Anybody any idea? |
So, basic X/Y Plotting? Maybe this will help: https://github.com/LucianoCirino/efficiency-nodes-comfyui It has these X/Y plotters |
I came up with a way using a custom node. (The basic trick could easily be applied to your own node.) I call mine To use it, you fill The trick is this: There's a class variable (essentially a static variable) called The The code does need an improvement if you intend to have more than one instance in your setup; the issue is that the static Anyway, here's the thing in its current state: class FormattedLineByIndex:
class Config:
def __init__(self, **kwargs):
self.__dict__.update(kwargs)
#TBD multi-instance fix: make this a dict where the caller's self is the key
config = Config(index=0, firstline=None)
@classmethod
def INPUT_TYPES(s):
return {
"required": {
"fmt": ("STRING",{"default":"LINE"}),
"lines": ("STRING",{"multiline":True}),
},
}
@classmethod
def IS_CHANGED(s, *args):
'''forces re-eval'''
return float("nan")
RETURN_TYPES = ["STRING","INT","INT"]
RETURN_NAMES = ["result","next_idx","len"]
CATEGORY = "utils"
FUNCTION = "apply_index"
def apply_index(self, fmt, lines):
config = FormattedLineByIndex.config
lines = [e for e in lines.strip().split("\n") if e]
if not lines:
raise Exception("NO INPUT")
firstline = lines[0]
if firstline != config.firstline:
print("FormattedLineByIndex: First line changed"
f" (from '{config.firstline}' to '{firstline}')"
", resetting index.")
config.index = 0
config.firstline = firstline
lines = [e for e in lines if e.lstrip()[0] != "#"]
if not lines:
raise Exception("NO INPUT")
index = config.index
config.index += 1 #for next time
if index >= len(lines):
#reset for another run, then throw an exception
config.firstline = None
raise Exception(f"BAD INDEX: {index}")
line = lines[index]
#replace the substring 'LINE' with the contents of line
return [fmt.replace("LINE",line), config.index, len(lines)] |
I'm new to ComfyUI, have to say I love the approach! (node based + community ecosystem)
I'm looking for a solution to batch generate images in an automated way with different parameters, prompts or even models? As I understood its not possible to do with native nodes? Are there any tricks or workarounds? I found out that you can do it somehow with 'primitive node' but ist not very efficient.
Is it possible to do this with custom nodes? https://github.com/hnmr293/ComfyUI-nodes-hnmr seems to come closest to what I'm looking for but it seems to be broken at the moment? (nodes don't show up after install) Are there any alternatives? Ideal would be some thing like lists with the different parameters (something like below) but not for rendering grids but individual images. Am grateful for any hint in the direction of automation..
The text was updated successfully, but these errors were encountered: