ZHO-ZHO-ZHO / ComfyUI-InstantID

Unofficial implementation of InstantID for ComfyUI
1.23k stars 67 forks source link

Error occurred when executing PreviewImage: #62

Open kubilaykilinc opened 5 months ago

kubilaykilinc commented 5 months ago

My PC configuration: NVDIA RTX 3050 - 12 GB Vram 32 GB Ram - Win 11 Last version ComfyUI and successfully installed CofyUI InstantID node

I am using example workflow & Using JuggernutXL 8 - base model. but i am getting this error.


Error occurred when executing PreviewImage:

'str' object has no attribute 'shape'

File "ComfyUI_windows_portable\ComfyUI\execution.py", line 155, in recursive_execute output_data, output_ui = get_output_data(obj, input_data_all) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "ComfyUI_windows_portable\ComfyUI\execution.py", line 85, in get_output_data return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "ComfyUI_windows_portable\ComfyUI\execution.py", line 78, in map_node_over_list results.append(getattr(obj, func)(**slice_dict(input_data_all, i))) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "ComfyUI_windows_portable\ComfyUI\nodes.py", line 1415, in save_images full_output_folder, filename, counter, subfolder, filename_prefix = folder_paths.get_save_image_path(filename_prefix, self.output_dir, images[0].shape[1], images[0].shape[0]) ^^^^^^^^^^^^^^^

steverhoades commented 5 months ago

I am seeing the seeing the same error. As far as I can tell this is because insightface is not detecting a face in the image.

steverhoades commented 5 months ago

OK, I think I figured it out. This occurs when a face is not detected in the image. There are a few things that factor into this.

  1. det_size is 640px by 640px
  2. img_resize is max 1280 pixels

If your face is taking up the majority of the pixels, i.e.> 640px, then it will fail to detect a face and show this error. Therefore, you will need to make sure your image is > 640 pixels and that the face is < 640 pixels of the entire image.

kubilaykilinc commented 5 months ago

image

Thank you very much for the information you provided. I thought about your idea and solved this problem by adding the "Prepare imafe for insightface" node between the source face image and the "prepare image for clipvision" node. Problem solved.

steverhoades commented 5 months ago

@ZHO-ZHO-ZHO I think raising an error when face is not detected would be a good strategy here. Otherwise the end-user is left to interpret an arguably ambiguous error.