ManglerFTW / ComfyI2I

ComfyI2I is a set of custom nodes for ComfyUI that help with image 2 image functions.
Other
158 stars 16 forks source link

Chaining #3

Closed nistvan86 closed 1 year ago

nistvan86 commented 1 year ago

I'm trying to chain the "Final output" of the "Combine and Paste" into another "Mask Ops" node to refine different part of the image. I'm getting the following error. It doesn't seem to matter if I'm adding any image conversion node (like sharpening) in between. Am I not supposed to do this and always create masks on the original image?

Error occurred when executing Mask Ops:

Unable to infer channel dimension format

  File "e:\aistuff\ComfyUI_windows_portable\ComfyUI\execution.py", line 151, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
  File "e:\aistuff\ComfyUI_windows_portable\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 "e:\aistuff\ComfyUI_windows_portable\ComfyUI\execution.py", line 74, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
  File "E:\aistuff\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyI2I\ComfyI2I.py", line 662, in Mask_Ops
    result = model(**inputs(text=text, images=image, padding=True, return_tensors="pt"))
  File "e:\aistuff\ComfyUI_windows_portable\python_embeded\lib\site-packages\transformers\models\clipseg\processing_clipseg.py", line 112, in __call__
    image_features = self.image_processor(images, return_tensors=return_tensors, **kwargs)
  File "e:\aistuff\ComfyUI_windows_portable\python_embeded\lib\site-packages\transformers\image_processing_utils.py", line 494, in __call__
    return self.preprocess(images, **kwargs)
  File "e:\aistuff\ComfyUI_windows_portable\python_embeded\lib\site-packages\transformers\models\vit\image_processing_vit.py", line 262, in preprocess
    images = [self.resize(image=image, size=size_dict, resample=resample) for image in images]
  File "e:\aistuff\ComfyUI_windows_portable\python_embeded\lib\site-packages\transformers\models\vit\image_processing_vit.py", line 262, in 
    images = [self.resize(image=image, size=size_dict, resample=resample) for image in images]
  File "e:\aistuff\ComfyUI_windows_portable\python_embeded\lib\site-packages\transformers\models\vit\image_processing_vit.py", line 126, in resize
    return resize(
  File "e:\aistuff\ComfyUI_windows_portable\python_embeded\lib\site-packages\transformers\image_transforms.py", line 299, in resize
    data_format = infer_channel_dimension_format(image) if data_format is None else data_format
  File "e:\aistuff\ComfyUI_windows_portable\python_embeded\lib\site-packages\transformers\image_utils.py", line 169, in infer_channel_dimension_format
    raise ValueError("Unable to infer channel dimension format")
ManglerFTW commented 1 year ago

It looks like the issue was that clipseg didn't accept rgba data types. I've uploaded a new ComfyI2I.py to the repo that should fix the issue for you. Please let me know if it works out.

nistvan86 commented 1 year ago

Sorry for the late reply, I've just got time. Thanks for the changes, although now it crashes with a different error.

I've tried to run my existing workflow where every Mask Ops node's image input is the original txt2img VAE Decoded image, this was working with the previous version. Now this crashes with the following error.

I've tried updating the dependencies with the install.bat inside ComfyUI\custom_nodes\ComfyI2I\ but it didn't solve the issue. If I revert back to the 6e6f1878f7b98a566f8f0f1f19d63331688f53de commit it's working again.

Error occurred when executing Mask Ops:

'Image' object has no attribute 'cpu'

  File "e:\aistuff\ComfyUI_windows_portable\ComfyUI\execution.py", line 151, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
  File "e:\aistuff\ComfyUI_windows_portable\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 "e:\aistuff\ComfyUI_windows_portable\ComfyUI\execution.py", line 74, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
  File "E:\aistuff\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyI2I\ComfyI2I.py", line 660, in Mask_Ops
    image = tensor2pil(image)
  File "E:\aistuff\ComfyUI_windows_portable\ComfyUI\custom_nodes\ComfyI2I\ComfyI2I.py", line 191, in tensor2pil
    return Image.fromarray(np.clip(255. * image.cpu().numpy().squeeze(), 0, 255).astype(np.uint8))
ManglerFTW commented 1 year ago

Thank you for your patience. I missed a line. It should be fixed now. Hopefully :). Check the new update and let me know how it goes.

nistvan86 commented 1 year ago

Thanks, it's working correctly now! :)

ManglerFTW commented 1 year ago

You're welcome!