Gourieff / comfyui-reactor-node

Fast and Simple Face Swap Extension Node for ComfyUI
GNU General Public License v3.0
1.09k stars 114 forks source link

Error when no face is detected #222

Closed andreclaudino closed 3 months ago

andreclaudino commented 4 months ago

First, confirm

What happened?

I am using the node to face swap videos. If in some frame the video contains no detected faces the whole process fail. The desired scenario could be a silent ignore, allowing to process the fames containing the required faces while keeping the current frames as is.

Steps to reproduce the problem

Load a video and an image, provide both, video frames and image to ReActor node, save the frames combining a video.

Sysinfo

Ubuntu 22.04, NVIDIA GeForce RTX 3090

Relevant console log

Error occurred when executing ReActorFaceSwap:

list index out of range

File "/home/claudino/Aplicacoes/ComfyUI/execution.py", line 155, in recursive_execute
output_data, output_ui = get_output_data(obj, input_data_all)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/claudino/Aplicacoes/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 "/home/claudino/Aplicacoes/ComfyUI/execution.py", line 78, in map_node_over_list
results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/claudino/Aplicacoes/ComfyUI/custom_nodes/comfyui-reactor-node/nodes.py", line 234, in execute
script.process(
File "/home/claudino/Aplicacoes/ComfyUI/custom_nodes/comfyui-reactor-node/scripts/reactor_faceswap.py", line 81, in process
result = swap_face(
^^^^^^^^^^
File "/home/claudino/Aplicacoes/ComfyUI/custom_nodes/comfyui-reactor-node/scripts/reactor_swapper.py", line 255, in swap_face
target_face, wrong_gender = get_face_single(target_img, target_faces, face_index=face_num, gender_target=gender_target)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/claudino/Aplicacoes/ComfyUI/custom_nodes/comfyui-reactor-node/scripts/reactor_swapper.py", line 133, in get_face_single
return get_face_single(img_data, analyze_faces(img_data, det_size_half), face_index, det_size_half, gender_source, gender_target)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/claudino/Aplicacoes/ComfyUI/custom_nodes/comfyui-reactor-node/scripts/reactor_swapper.py", line 134, in get_face_single
return get_face_gender(face,face_index,gender_target,"Target")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/claudino/Aplicacoes/ComfyUI/custom_nodes/comfyui-reactor-node/scripts/reactor_swapper.py", line 96, in get_face_gender
face_gender = gender[face_index]
~~~~~~^^^^^^^^^^^^

Additional information

I could resolve this issue if I have the help of the developers. Let me know how I can change the code to allow the silent bypass.

Gourieff commented 4 months ago

Hi, yes, there's already merged PR (https://github.com/Gourieff/comfyui-reactor-node/pull/143) with the implemented fix for this point, so it will be added soon to the main branch