Closed ghostsquad closed 5 months ago
You can use matplotlib to plot multiple images, though not out of the box. I guess this is what used by most custom nodes.
Alternatively, ipywidgets can also be used. There is already a widget for displaying multiple images in the repo. Adding titles to them won't be a lot of work. Though you can't save the grid as an image this way.
Here is a simple example using the builtin widget:
def plot(x):
image, _ = LoadImage(r'D:\ComfyUI\output\ComfyUI_00017_.png')
image = ImageBlur(image, x)
# PreviewImage(image).wait()[0] to get the PIL.Image
return PreviewImage(image).wait()
images = []
for x in [1, 5, 10, 15, 20, 25, 30]:
print(x)
images.append(plot(x))
Images(*images)
How would I add titles?
sorry for some of these newb questions. Sometimes I feel like I spend more time tweaking my workflow than I do generating images. ComfyScript has saved me a lot of time though so far. No more zooming and panning in the UI, and I can see all relevant parameters right on one screen.
Changing grid[i, j] = image
to a widget containing both the image and the label should work. I'll add it later.
If you have any suggestions for docs on widgets, please let me know. Happy to read up on it.
The docs of ipywidgets is here: https://ipywidgets.readthedocs.io/en/stable/
The usage is simple, just nesting widgets and display()
. But it lacks some features, you may have to write some HTML/CSS in case there's no built-in option.
Another choice is Solara. It's like React, but in Python. It has some nice widgets, like the file drop used in metadata viewer, though the customization is also limited.
Titles are now supported.
Docs: https://github.com/Chaoses-Ib/ComfyScript/blob/main/docs/UI/ipywidgets.md
thanks!
Is there a more idiomatic way of making an xy grid in Python as opposed to using custom nodes?