diff --git a/.github/workflow_load_frames.jpg b/.github/workflow_load_frames.jpg new file mode 100644 index 0000000..9dc73cb Binary files /dev/null and b/.github/workflow_load_frames.jpg differ diff --git a/.github/workflow_swap_image.jpg b/.github/workflow_swap_image.jpg new file mode 100644 index 0000000..bb6823a Binary files /dev/null and b/.github/workflow_swap_image.jpg differ diff --git a/.github/workflow_swap_video.jpg b/.github/workflow_swap_video.jpg new file mode 100644 index 0000000..efc21e9 Binary files /dev/null and b/.github/workflow_swap_video.jpg differ diff --git a/README.md b/README.md index da8fdbb..0ad29f1 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,8 @@ > Next generation face toolkit for ComfyUI. +This project is under development. There may be compatibility issues in future upgrades. If you encounter any problems, please create an issue, thanks. + ## Installation ### Install custom node @@ -13,12 +15,43 @@ pip install -r requirements.txt ### Download model -All models is same as [facefusion](https://github.com/facefusion/facefusion). +All models is same as [facefusion](https://github.com/facefusion/facefusion) which can be found in [facefusion assets](https://github.com/facefusion/facefusion-assets). -Download what your needs models from [facefusion assets](https://github.com/facefusion/facefusion-assets) +Now it will use the following model by default. In the future, dynamic model selection will be supported. Please download the model based on the following directory structure. Put all into directory `CmofyUI/models/faceless`. +``` +|-- face_detector +| `-- yoloface_8n.onnx +|-- face_landmarker +| |-- 2dfan4.onnx +| `-- face_landmarker_68_5.onnx +|-- face_recognizer +| `-- arcface_w600k_r50.onnx +|-- face_swapper +| |-- inswapper_128.onnx +| `-- inswapper_128_fp16.onnx +|-- gender_age.onnx +`-- rmbg.pth +``` + +## Example workflows + +### Image face swap + +![Image Face Swap](https://raw.githubusercontent.com/jeffy5/comfyui-faceless-node/main/.github/workflow_swap_image.jpg) + +### Video face swap + +![Video Face Swap](https://raw.githubusercontent.com/jeffy5/comfyui-faceless-node/main/.github/workflow_swap_video.jpg) + +### Load frames to preview image + +![Load Frames To Preview](https://raw.githubusercontent.com/jeffy5/comfyui-faceless-node/main/.github/workflow_load_frames.jpg) + +It doesn't support preview video for now. All video will be save in directory `output/faceless`. + ## Thanks and Credits Thanks to [Facefusion](https://github.com/facefusion/facefusion). This project is based on facefusion to implenment a special version for ComfyUI. diff --git a/faceless/ffmpeg.py b/faceless/ffmpeg.py index 63d3962..f2950ba 100644 --- a/faceless/ffmpeg.py +++ b/faceless/ffmpeg.py @@ -106,7 +106,7 @@ def restore_audio(video_path: str, audio_path: str, output_path: str, output_vid if trim_frame_end is not None: end_time = trim_frame_end / output_video_fps commands.extend([ '-to', str(end_time) ]) - commands.extend([ '-i', audio_path, '-c', 'copy', '-map', '0:v:0', '-map', '1:a:0', '-shortest', '-y', output_path ]) + commands.extend([ '-i', audio_path, '-c', 'copy', '-map', '0:v:0', '-map', '1:a?:0', '-shortest', '-y', output_path ]) return run_ffmpeg(commands) def map_amf_preset(output_video_preset : OutputVideoPreset) -> str: diff --git a/faceless/nodes/nodes_remove_background.py b/faceless/nodes/nodes_remove_background.py index ab32f4d..df390d0 100644 --- a/faceless/nodes/nodes_remove_background.py +++ b/faceless/nodes/nodes_remove_background.py @@ -47,8 +47,12 @@ class NodesRemoveBackground: processed_images.append(new_im_tensor) processed_masks.append(pil_im_tensor) - new_ims = torch.cat(processed_images, dim=0) - new_masks = torch.cat(processed_masks, dim=0) + if len(processed_images) > 1: + new_ims = torch.cat(processed_images, dim=0) + new_masks = torch.cat(processed_masks, dim=0) + else: + new_ims = processed_images[0] + new_masks = processed_masks[0] return (new_ims, new_masks) def remove_background(self, orig_image):