Hallo: Hierarchical Audio-Driven Visual Synthesis for Portrait Image Animation
Hallo: Hierarchical Audio-Driven Visual Synthesis for Portrait Image Animation
| Devil Wears Prada | Green Book | Infernal Affairs |
| Patch Adams | Tough Love | Shawshank Redemption |
Explore more examples.
2024/06/28: We are proud to announce the release of our model training code. Try your own training data. Here is tutorial.2024/06/21: Cloned a Gradio demo on Huggingface space.2024/06/20: Received numerous contributions from the community, including a Windows version, ComfyUI, WebUI, and Docker template.2024/06/15: ✨✨✨ Released some images and audios for inference testing on Huggingface.2024/06/15: Launched the first version on GitHub.Explore the resources developed by our community to enhance your experience with Hallo:
Thanks to all of them.
Join our community and explore these amazing resources to make the most out of Hallo. Enjoy and elevate their creative projects!
Create conda environment:
conda create -n hallo python=3.10
conda activate halloInstall packages with pip
pip install -r requirements.txt
pip install .Besides, ffmpeg is also needed:
apt-get install ffmpegThe entry point for inference is scripts/inference.py. Before testing your cases, two preparations need to be completed:
You can easily get all pretrained models required by inference from our HuggingFace repo.
Clone the pretrained models into ${PROJECT_ROOT}/pretrained_models directory by cmd below:
git lfs install
git clone https://huggingface.co/fudan-generative-ai/hallo pretrained_modelsOr you can download them separately from their source repo:
pretrained_models/face_analysis/models/. (Thanks to deepinsight)pretrained_models/face_analysis/models.Finally, these pretrained models should be organized as follows:
…Hallo has a few simple requirements for input data:
For the source image:
For the driving audio:
We have provided some samples for your reference.
Simply to run the scripts/inference.py and pass source_image and driving_audio as input:
python scripts/inference.py --source_image examples/reference_images/1.jpg --driving_audio examples/driving_audios/1.wavAnimation results will be saved as ${PROJECT_ROOT}/.cache/output.mp4 by default. You can pass --output to specify the output file name. You can find more examples for inference at examples folder.
For more options:
…The training data, which utilizes some talking-face videos similar to the source images used for inference, also needs to meet the following requirements:
Organize your raw videos into the following directory structure:
dataset_name/
|-- videos/
| |-- 0001.mp4
| |-- 0002.mp4
| |-- 0003.mp4
| `-- 0004.mp4You can use any dataset_name, but ensure the videos directory is named as shown above.
Next, process the videos with the following commands:
python -m scripts.data_preprocess --input_dir dataset_name/videos --step 1
python -m scripts.data_preprocess --input_dir dataset_name/videos --step 2Note: Execute steps 1 and 2 sequentially as they perform different tasks. Step 1 converts videos into frames, extracts audio from each video, and generates the necessary masks. Step 2 generates face embeddings using InsightFace and audio embeddings using Wav2Vec, and requires a GPU. For parallel processing, use the -p and -r arguments. The -p argument specifies the total number of instances to launch, dividing the data into p parts. The -r argument specifies which part the current process should handle. You need to manually launch multiple instances with different values for -r.
Generate the metadata JSON files with the following commands:
python scripts/extract_meta_info_stage1.py -r path/to/dataset -n dataset_name
python scripts/extract_meta_info_stage2.py -r path/to/dataset -n dataset_nameReplace path/to/dataset with the path to the parent directory of videos, such as dataset_name in the example above. This will generate dataset_name_stage1.json and dataset_name_stage2.json in the ./data directory.
Update the data meta path settings in the configuration YAML files, configs/train/stage1.yaml and configs/train/stage2.yaml:
#stage1.yaml
data:
meta_paths:
- ./data/dataset_name_stage1.json
#stage2.yaml
data:
meta_paths:
- ./data/dataset_name_stage2.jsonStart training with the following command:
accelerate launch -m \
--config_file accelerate_config.yaml \
--machine_rank 0 \
--main_process_ip 0.0.0.0 \
--main_process_port 20055 \
--num_machines 1 \
--num_processes 8 \
scripts.train_stage1 --config ./configs/train/stage1.yamlThe accelerate launch command is used to start the training process with distributed settings.
accelerate launch [arguments] {training_script} --{training_script-argument-1} --{training_script-argument-2} ...Arguments for Accelerate:
-m, --module: Interpret the launch script as a Python module.--config_file: Configuration file for Hugging Face Accelerate.--machine_rank: Rank of the current machine in a multi-node setup.--main_process_ip: IP address of the master node.--main_process_port: Port of the master node.--num_machines: Total number of nodes participating in the training.--num_processes: Total number of processes for training, matching the total number of GPUs across all machines.Arguments for Training:
{training_script}: The training script, such as scripts.train_stage1 or scripts.train_stage2.--{training_script-argument-1}: Arguments specific to the training script. Our training scripts accept one argument, --config, to specify the training configuration file.For multi-node training, you need to manually run the command with different machine_rank on each node separately.
For more settings, refer to the Accelerate documentation.
preprocessing #face is invalid: 0
xFormers Module Not Found
Loading weighs last very long
New Leav
Is there a way to directly read frames from a video and feed them to the model for training, instead of processing the video into individual frames and storing them locally? Doing so poses a significant challenge to disk capacity.
About train stage1 step_loss=Nan
我在train_stage这个过程中,一直显示nccl time out。请问能给出您的意见吗
test checkpoint after training
ONNXRuntimeError
ONNXRuntimeError