bronkula / comfyui-fitsize

A simple set of nodes for making an image fit within a bounding box in comfyui
45 stars 4 forks source link

Batch size doesn't work with "Fit Image and Resize" #1

Open oliverban opened 11 months ago

oliverban commented 11 months ago

It doesn't work even if I type in the batch size manually. With 1 image/frame it works. As title says. I get this error:

Error occurred when executing FS: Fit Image And Resize:

Cannot handle this data type: (1, 1, 768, 3), |u1

File "C:\Users\Oliver\Documents\Github\ComfyUI_windows_portable\ComfyUI\execution.py", line 153, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Oliver\Documents\Github\ComfyUI_windows_portable\ComfyUI\execution.py", line 83, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Oliver\Documents\Github\ComfyUI_windows_portable\ComfyUI\execution.py", line 76, in map_node_over_list results.append(getattr(obj, func)(*slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Oliver\Documents\Github\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-fitsize\nodes.py", line 216, in fit_resize_latent return fit_and_resize_image(image, vae, max_size, resampling, upscale, batch_size, add_noise) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Oliver\Documents\Github\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-fitsize\nodes.py", line 63, in fit_and_resize_image img = tensor2pil(image) ^^^^^^^^^^^^^^^^^ File "C:\Users\Oliver\Documents\Github\ComfyUI_windows_portable\ComfyUI\custom_nodes\comfyui-fitsize\nodes.py", line 11, in tensor2pil return Image.fromarray(np.clip(255. image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\Oliver\Documents\Github\ComfyUI_windows_portable\python_embeded\Lib\site-packages\PIL\Image.py", line 3092, in fromarray raise TypeError(msg) from e

Here is my setup:

brave_stzQGC7AZx
bronkula commented 11 months ago

Interesting. Since Fit Size was meant to output a singular size, it wasn't made to handle batches as input.

oliverban commented 11 months ago

Interesting. Since Fit Size was meant to output a singular size, it wasn't made to handle batches as input.

Ah, okey, I thought it did since it did have that batch size input! I've since rebuilt my workflow to work as intended!

bronkula commented 11 months ago

I'll make an update to pick the first item if a batch is sent.

oliverban commented 11 months ago

I'll make an update to pick the first item if a batch is sent.

Much appreciated, this little node makes Vid2Vid much faster and cleaner with less nodes controlling resizing!