WASasquatch / was-node-suite-comfyui

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

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

Open GalaxyTimeMachine opened 1 year ago

GalaxyTimeMachine commented 1 year ago

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
WASasquatch commented 1 year ago

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

WASasquatch commented 1 year ago

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

GalaxyTimeMachine commented 1 year ago

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
WASasquatch commented 1 year ago

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

GalaxyTimeMachine commented 1 year ago

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'
WASasquatch commented 1 year ago

Jesus.

Update again.

GalaxyTimeMachine commented 1 year ago

It still creates multiple 1 pixel width images image

WASasquatch commented 1 year ago

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

image

GalaxyTimeMachine commented 1 year ago

The image output from "Ultimate SD Upscaler".

GalaxyTimeMachine commented 1 year ago

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.

WASasquatch commented 1 year ago

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.

GalaxyTimeMachine commented 1 year ago

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.

WASasquatch commented 1 year ago

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

GalaxyTimeMachine commented 1 year ago

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