WASasquatch / was-node-suite-comfyui

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

Image Threshold Error #469

Open brbbbq opened 2 months ago

brbbbq commented 2 months ago

I'm getting this error when trying to use the Image Threshold node. I tried updating the suite, but it didn't help:

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

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

Traceback (most recent call last):
  File "J:\ComfyUI_windows_portable-1\ComfyUI\execution.py", line 151, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "J:\ComfyUI_windows_portable-1\ComfyUI\execution.py", line 81, in get_output_data
    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "J:\ComfyUI_windows_portable-1\ComfyUI\execution.py", line 74, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "J:\ComfyUI_windows_portable-1\ComfyUI\custom_nodes\was-node-suite-comfyui\WAS_Node_Suite.py", line 5599, in image_threshold
    return (pil2tensor(self.apply_threshold(tensor2pil(image), threshold)), )
                                            ^^^^^^^^^^^^^^^^^
  File "J:\ComfyUI_windows_portable-1\ComfyUI\custom_nodes\was-node-suite-comfyui\WAS_Node_Suite.py", line 359, in tensor2pil
    return Image.fromarray(np.clip(255. * image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "J:\ComfyUI_windows_portable-1\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, 320, 3), |u1
WASasquatch commented 2 months ago

Is the image a batch of images? That very old method only does one image at a time.

I have updated the method to handle batched images: https://github.com/WASasquatch/was-node-suite-comfyui/commit/bb34bd429ab74a22a7f58551429a0f3046e1464e

image

brbbbq commented 2 months ago

It is an image batch. I updated the nodes through the manager. I'll take another look at it in the morning.

brbbbq commented 2 months ago

I updated the node, and it's kind of working, but for some reason the output is causing VHS Video Combine node to render a grid. 240908-122511-chrome

It only occurs when selecting one of the video formats. If I select an image format, like 'gif', it renders correctly. 240908-122408-chrome

WASasquatch commented 2 months ago

Uhh, well that's different. Lol I am not sure what that is about. Maybe because the images are greyscale? Traditionally the node was meant for image based masks for raster edits like blend nodes or what not. May need a convert to RGB space.

On Sun, Sep 8, 2024, 9:29 AM brbbbq @.***> wrote:

I updated the node, and it's kind of working, but for some reason the output is causing VHS Video Combine node to render a grid. 240908-122511-chrome.png (view on web) https://github.com/user-attachments/assets/1cb7d70f-878f-4bec-8854-bf6ecd9b53d9

It only occurs when selecting one of the video formats. If I select an image format, like 'gif', it renders correctly. 240908-122408-chrome.png (view on web) https://github.com/user-attachments/assets/6c3dacbf-2de3-40f1-98a6-628e747efa66

— Reply to this email directly, view it on GitHub https://github.com/WASasquatch/was-node-suite-comfyui/issues/469#issuecomment-2336745070, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAIZEZNWIVVMVSHAKA2P64DZVR3NRAVCNFSM6AAAAABN2I3UOCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMZWG42DKMBXGA . You are receiving this because you commented.Message ID: @.***>

brbbbq commented 2 months ago

Yea, so random. You know what, I just realized there's an Image Level node, which actually works a little better for my needs, so not a big deal at this point. I appreciate you looking into it.