was-node-suite-comfyui icon indicating copy to clipboard operation
was-node-suite-comfyui copied to clipboard

"Image Style Filter" node can't handle batches.

Open GalaxyTimeMachine opened this issue 2 years ago • 17 comments

The Image Style Filter node works fine with individual image generations, but it fails if there is ever more than 1 in a batch.

!!! Exception during processing !!!
Traceback (most recent call last):
  File "F:\ComfyUI_windows_portable\python_embeded\lib\site-packages\PIL\Image.py", line 3089, in fromarray
    mode, rawmode = _fromarray_typemap[typekey]
KeyError: ((1, 1, 2048, 3), '|u1')

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "F:\ComfyUI_windows_portable\ComfyUI\execution.py", line 145, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
  File "F:\ComfyUI_windows_portable\ComfyUI\execution.py", line 75, in get_output_data
    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
  File "F:\ComfyUI_windows_portable\ComfyUI\execution.py", line 68, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
  File "F:\ComfyUI_windows_portable\ComfyUI\custom_nodes\was-node-suite-comfyui\WAS_Node_Suite.py", line 2789, in image_style_filter
    image = tensor2pil(image)
  File "F:\ComfyUI_windows_portable\ComfyUI\custom_nodes\was-node-suite-comfyui\WAS_Node_Suite.py", line 335, in tensor2pil
    return Image.fromarray(np.clip(255. * image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8))
  File "F:\ComfyUI_windows_portable\python_embeded\lib\site-packages\PIL\Image.py", line 3092, in fromarray
    raise TypeError(msg) from e
TypeError: Cannot handle this data type: (1, 1, 2048, 3), |u1

GalaxyTimeMachine avatar Jul 19 '23 07:07 GalaxyTimeMachine

Oh thanks for pointing this out. Been trying to port all the image nodes and wondering if I forgot any.

WASasquatch avatar Jul 21 '23 05:07 WASasquatch

Should be patched: https://github.com/WASasquatch/was-node-suite-comfyui/commit/d64cbc1fefe9097c01c860fe89c3c6dae69f2862 Go ahead and git pull or update with Manager.

WASasquatch avatar Jul 23 '23 03:07 WASasquatch

Now it doesn't work with single images either.

Traceback (most recent call last):
  File "F:\ComfyUI_windows_portable\ComfyUI\execution.py", line 144, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
  File "F:\ComfyUI_windows_portable\ComfyUI\execution.py", line 74, in get_output_data
    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
  File "F:\ComfyUI_windows_portable\ComfyUI\execution.py", line 67, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
  File "F:\ComfyUI_windows_portable\ComfyUI\custom_nodes\was-node-suite-comfyui\WAS_Node_Suite.py", line 2811, in image_style_filter
    for img in images:
NameError: name 'images' is not defined

GalaxyTimeMachine avatar Jul 23 '23 15:07 GalaxyTimeMachine

Oh, part of the changes got reverted. Sorry about that. Should be patched now.

WASasquatch avatar Jul 23 '23 21:07 WASasquatch

Trying to create single image gives me 2048 x 1 pixel width images, when it goes through the filter, and a batch of 2 gives:

Traceback (most recent call last):
  File "F:\ComfyUI_windows_portable\ComfyUI\execution.py", line 144, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
  File "F:\ComfyUI_windows_portable\ComfyUI\execution.py", line 74, in get_output_data
    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
  File "F:\ComfyUI_windows_portable\ComfyUI\execution.py", line 67, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
  File "F:\ComfyUI_windows_portable\ComfyUI\custom_nodes\was-node-suite-comfyui\WAS_Node_Suite.py", line 2867, in image_style_filter
    tensors.append(img)
AttributeError: 'Tensor' object has no attribute 'append'

GalaxyTimeMachine avatar Jul 24 '23 14:07 GalaxyTimeMachine

Jesus.

Update again.

WASasquatch avatar Jul 24 '23 19:07 WASasquatch

It still creates multiple 1 pixel width images image

GalaxyTimeMachine avatar Jul 25 '23 06:07 GalaxyTimeMachine

It's working for me. What are you inputting into it?

image

WASasquatch avatar Jul 25 '23 16:07 WASasquatch

The image output from "Ultimate SD Upscaler".

GalaxyTimeMachine avatar Jul 25 '23 20:07 GalaxyTimeMachine

I used it like that before I reported it didn't work with batches, without any problem. This behaviour started after you made changes to fix the batch issue.

GalaxyTimeMachine avatar Jul 25 '23 20:07 GalaxyTimeMachine

That's cause it was using tensor regardless of batches, but ultimate SD Upscaler is not outputting correct ComfyUI image format. Even a single image must be batched.

WASasquatch avatar Jul 25 '23 23:07 WASasquatch

Output from the upscaler to save image and a preview window look normal to me. If I put the style filter between them, then it goes wrong.

GalaxyTimeMachine avatar Jul 26 '23 06:07 GalaxyTimeMachine

Not sure. I don't support other custom_nodes for obvious reasons. Did you actually update WAS-NS, or just getting the previous issue?

WASasquatch avatar Jul 26 '23 07:07 WASasquatch

I had updated, but just noticed another update today...still no improvement, though. I even tried it on a different, simpler workflow, with no upscaler, and I get the same problem. It just comes out of the decoder, into the style filter and then to a preview: image

GalaxyTimeMachine avatar Jul 26 '23 08:07 GalaxyTimeMachine

updated to the latest version but somehow i can't still do image blend with videos

LorisTecnology avatar Mar 01 '25 15:03 LorisTecnology

None of my image nodes would work with videos.

WASasquatch avatar Mar 01 '25 18:03 WASasquatch

is there a way to bypass that? maybe batch images? afaik, images from video got loaded as batches right?

LorisTecnology avatar Mar 01 '25 19:03 LorisTecnology