DeepFuze
repository·main·Indexed 19 days ago
https://github.com/samkhoze/comfyui-deepfuzeA ComfyUI extension for high-fidelity facial transformations, including lipsyncing, face swapping, and voice cloning. Optimized for Windows (CUDA) and macOS (MPS), it provides nodes for facial movement synchronization, face restoration, and integration with OpenAI LLMs for dialogue generation. It includes a programmatic Python API and a Speaker Encoder for generating voice embeddings using the d-vector method.
What's inside comfyui-deepfuze
- DeepFuze is a deep learning tool integrated with ComfyUI designed for facial transformations, lipsyncing, video generation, voice cloning, face swapping, and lipsync translation. It allows users to combine audio and video with high realism by synchronizing facial movements to audio input.
Available Mozilla TTS Vocoder Models
mainThe project provides experimental implementations of several vocoder models that can be combined with other TTS models. The currently implemented models are:
- Melgan
- MultiBand-Melgan
- ParallelWaveGAN
- GAN-TTS (Discriminator Only)
Use the Speaker Encoder for voice and speaker embedding
mainThe Speaker Encoder is an implementation of the d-vector method (based on arXiv:1710.10467). It is used to generate embeddings for both multi-speaker and single-speaker TTS datasets. These embeddings can be used for voice embedding, visualization, and exploration in interactive charts.Train a new vocoder model
mainTo train a new vocoder model, follow these steps:
- Gather all
.wavfiles into a single folder. - Configure a
config.jsonfile. You must set thedata_pathkey to the path of your wav files folder and define other relevant training parameters. - Example configuration files are available in the
tts/vocoder/configs/directory. - Execute the training script using the
--config_pathflag.
CUDA_VISIBLE_DEVICES='0' python tts/bin/train_vocoder.py --config_path path/to/config.json- Gather all
Generate embedding vectors with compute_embeddings.py
mainTo generate embedding vectors from a dataset, use the
compute_embeddings.pyscript. This script parses all.wavfiles at the specified dataset path and recreates the same folder structure under the provided output path, containing the generated embedding files.Requirements:
- A pretrained model (downloadable from Mozilla TTS Released Models).
- A configuration file (
config.json).
python speaker_encoder/compute_embeddings.py --use_cuda true /model/path/best_model.pth model/config/path/config.json dataset/path/ output_pathConfigure CUDA for Windows Acceleration
mainTo enable significant speed increases on Windows, you must install NVIDIA CUDA and cuDNN.
Requirements:
- NVIDIA CUDA Toolkit: Version
11.8. - cuDNN: Version
8.9.2.26(Download from NVIDIA Developer Archive or provided Google Drive link).
Steps:
- Install CUDA 11.8 and cuDNN 8.9.2.26.
- Add the installation paths to your system Environment Variables.
- Restart your computer.
- Verify installation by running
nvcc --versionin your terminal. It should return a response confirmingrelease 11.8.
Troubleshooting
zlibwapi.dllerror: If you see a missingzlibwapi.dllerror, download the NVIDIAzlibwapi.dllfile and copy it to:C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin\zlibwapi.dllnvcc --version- NVIDIA CUDA Toolkit: Version
Install DeepFuze on Windows (Portable ComfyUI)
mainTo install DeepFuze on Windows using Portable ComfyUI, follow these steps:
- Install Build Tools: Install Visual Studio (Community version is fine) or VS C++ Build Tools with the "Desktop Development with C++" workload selected.
- Install via ComfyUI-Manager:
- Search for
DeepFuzein the Manager and install it. - Restart ComfyUI.
- Alternatively, use "Install Via GIT URL" in the Manager and paste:
https://github.com/SamKhoze/ComfyUI-DeepFuze.git.
- Search for
- Restart ComfyUI.
Note: If you are unsure about CUDA installation, use the CPU version to avoid complexity.
https://github.com/SamKhoze/ComfyUI-DeepFuze.gitInstall DeepFuze on macOS (Manual Installation)
mainDo not use ComfyUI-Manager on Mac. You must install manually:
- Set Environment Variable: Before running, execute:
export PYTORCH_ENABLE_MPS_FALLBACK=1 - Install Dependencies:
- Install PyTorch (tested on M1/M3).
pip install onnxruntime(Note: Useonnxruntime, NOTonnxruntime-gpu).pip install dlib.pip install TTS(for Voice Cloning).
- Clone Repository:
cd custom_nodes git clone https://github.com/SamKhoze/CompfyUI-DeepFuze.git cd CompfyUI-DeepFuze pip install -r requirements.txt - Required Extra Nodes: You must also clone ComfyUI-VideoHelperSuite into your
custom_nodesfolder to load video and audio.
export PYTORCH_ENABLE_MPS_FALLBACK=1 pip install onnxruntime pip install dlib pip install TTS cd custom_nodes git clone https://github.com/SamKhoze/CompfyUI-DeepFuze.git cd CompfyUI-DeepFuze pip install -r requirements.txt- Set Environment Variable: Before running, execute:
Fine-tune a pre-trained model
mainTo fine-tune an existing model, use the
--restore_pathflag pointing to a.pthcheckpoint file.Note on behavior: Restoring a model via
--restore_pathstarts a new training run in a different folder and only restores the weights from the checkpoint. This differs from--continue_path, which resumes training in the original directory.CUDA_VISIBLE_DEVICES='0' python tts/bin/train_vocoder.py --restore_path path/to/your/model.pthTrain the Speaker Encoder
mainYou can train the speaker encoder by following the standard TTS workflow. You must first define a
config.jsonfile tailored to your needs; ensure that audio parameters in the config match your TTS model.To initiate training, use the
train.pyscript with the--config_pathand--data_pathflags. Training progress can be monitored using Tensorboard.python speaker_encoder/train.py --config_path speaker_encoder/config.json --data_path ~/Data/Libri-TTS/train-clean-360Download and Place DeepFuze Models
mainModels must be manually downloaded and placed in the following directory:
./ComfyUI/models/deepfuze/Models can be found on Google Drive. Ensure you download each model individually due to their large size.
Continue a previous training run
mainIf you want to resume training from where a previous run left off (starting in the same directory), use the
--continue_pathflag pointing to your model folder.CUDA_VISIBLE_DEVICES='0' python tts/bin/train_vocoder.py --continue_path path/to/your/model/folder