WASasquatch / was-node-suite-comfyui

An extensive node suite for ComfyUI with over 210 new nodes
MIT License
1.15k stars 170 forks source link

WAS_Load_Image_Batch -> IS_CHANGED ? #54

Closed MoonMoon82 closed 1 year ago

MoonMoon82 commented 1 year ago

It seems you designed this node to reload the node, even if the input has not changed. In WAS_Load_Image_Batch IS_CHANGED it says:

    @classmethod
    def IS_CHANGED(cls, **kwargs):
        return float("NaN")

In the usual ComfyUI LoadImage it is comparing the hash of the image to identify if it has changed. I guess you had a good reason to design it that way, but if you have a huge input directory (>1000 files) it takes a quite long time to run the Image Batch node. Could you please check if there's a chance to adjust it, so it won't take that long to run this node anymore?

WASasquatch commented 1 year ago

That's has nothing to do with how long it takes (and comparing hashes would take longer), but is required otherwise the node wouldn't run at all as you haven't changed any input on the node.

polarsky89 commented 1 year ago

Also, if you could give a little bit od understanding how doeas index and batch work, so I could get some control on which image is loaded first?

WASasquatch commented 1 year ago

Index only works for single images, to pick a image from the batch. The list is sorted by filename, so whatever file is first in the folder will go first. Its very hacky as ComfyUI lacks crucial features like a callback function on nodes prior to a prompt run.

WASasquatch commented 1 year ago

You can also use the glob input to filter the files. Like *.png for only png files. Or *_mask.* for files that end in _mask like "ComfyUI_22_mask.png"

polarsky89 commented 1 year ago

Thanks, that might help. Is it possible to implement a 'reset index' button or some method to keep the list starting from index 0 when needed? Now i figured the only method is to change the input folder to a different one, run, and then change it back. Lots of pain when trying to work with many frames in different folders edit: right now the index keeps going +1 until you change the folder

WASasquatch commented 1 year ago

Thanks, that might help. Is it possible to implement a 'reset index' button or some method to keep the list starting from index 0 when needed? Now i figured the only method is to change the input folder to a different one, run, and then change it back. Lots of pain when trying to work with many frames in different folders edit: right now the index keeps going +1 until you change the folder

That somewhat falls back on lack of communication from the front end with nodes. Nodes only ever get info from the front end when they run. There needs to be a OnChange like event when input is changed it can fire off a node function that handles pre-run steps, such as resetting index, or reading a folder and populating a list to select a image instead of using a index which is hard to relate to a image.

Comfyanonymous (or someone) needs to add this sort of functionality to ComfyUI. When a node inputs are changed we should be able to see that change on the backend to handle crucial ease of use features. Feel free to create a issue on ComfyUI so the priority of this is seen. Cause I haven't even gotten a response on discussion I tried.

WASasquatch commented 1 year ago

You can also reset the Batch Counters in was_suite_settings.json by having the settings file open in notepad or whatever, and change the counter for that batch to 0.

    "Batch Counters": {
        "Batch 001": 1
    },
    "Batch Paths": {
        "Batch 001": "C:\\Users\\jorda\\Pictures\\ErinKellyman"
    },
MoonMoon82 commented 1 year ago

@polarsky89 you can also change the "Label" text of a Load Image Batch Node. In gerenal, as far as I observed, every manual change of input parameters lead to a reset of all attributes of a node class.

@WASasquatch I'm not quite sure if it perhaps would be sufficient to compare the index instead of comparing hashes. Maybe this would be an workaround? Just an example: I created a landscape depthmap sequence in blender (~250 files) which I input as controlnet-condition, but the same depthmap file needs to be used as controlnet condition 4 times (in 1000 batch counts). So in this case, I guess this workaround would save 3/4 of image loading time.

WASasquatch commented 1 year ago

@WASasquatch I'm not quite sure if it perhaps would be sufficient to compare the index instead of comparing hashes. Maybe this would be an workaround? Just an example: I created a landscape depthmap sequence in blender (~250 files) which I input as controlnet-condition, but the same depthmap file needs to be used as controlnet condition 4 times (in 1000 batch counts). So in this case, I guess this workaround would save 3/4 of image loading time.

I don't think I'm following. Wouldn't the increment be happening in the node function itself? So it wouldn't run, to get a increment, for the IS_CHANGED to see?