leeway.zlw
commited on
Commit
•
508c460
1
Parent(s):
7910706
docs: update readme
Browse files
README.md
CHANGED
@@ -1,3 +1,415 @@
|
|
1 |
---
|
2 |
license: mit
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: mit
|
3 |
---
|
4 |
+
<h1 align='center'>Hallo2: Long-Duration and High-Resolution Audio-driven Portrait Image Animation</h1>
|
5 |
+
|
6 |
+
<div align='center'>
|
7 |
+
<a href='https://github.com/cuijh26' target='_blank'>Jiahao Cui</a><sup>1*</sup> 
|
8 |
+
<a href='https://github.com/crystallee-ai' target='_blank'>Hui Li</a><sup>1*</sup> 
|
9 |
+
<a href='https://yoyo000.github.io/' target='_blank'>Yao Yao</a><sup>3</sup> 
|
10 |
+
<a href='http://zhuhao.cc/home/' target='_blank'>Hao Zhu</a><sup>3</sup> 
|
11 |
+
<a href='https://github.com/NinoNeumann' target='_blank'>Hanlin Shang</a><sup>1</sup> 
|
12 |
+
<a href='https://github.com/Kaihui-Cheng' target='_blank'>Kaihui Cheng</a><sup>1</sup> 
|
13 |
+
<a href='' target='_blank'>Hang Zhou</a><sup>2</sup> 
|
14 |
+
</div>
|
15 |
+
<div align='center'>
|
16 |
+
<a href='https://sites.google.com/site/zhusiyucs/home' target='_blank'>Siyu Zhu</a><sup>1✉️</sup> 
|
17 |
+
<a href='https://jingdongwang2017.github.io/' target='_blank'>Jingdong Wang</a><sup>2</sup> 
|
18 |
+
</div>
|
19 |
+
|
20 |
+
<div align='center'>
|
21 |
+
<sup>1</sup>Fudan University  <sup>2</sup>Baidu Inc  <sup>3</sup>Nanjing University
|
22 |
+
</div>
|
23 |
+
|
24 |
+
<br>
|
25 |
+
<div align='center'>
|
26 |
+
<a href='https://github.com/fudan-generative-vision/hallo2'><img src='https://img.shields.io/github/stars/fudan-generative-vision/hallo2?style=social'></a>
|
27 |
+
<a href='https://fudan-generative-vision.github.io/hallo2/#/'><img src='https://img.shields.io/badge/Project-HomePage-Green'></a>
|
28 |
+
<a href='https://arxiv.org/abs/2410.07718'><img src='https://img.shields.io/badge/Paper-Arxiv-red'></a>
|
29 |
+
<a href='https://huggingface.co/fudan-generative-ai/hallo2'><img src='https://img.shields.io/badge/%F0%9F%A4%97%20HuggingFace-Model-yellow'></a>
|
30 |
+
<a href='assets/wechat.jpeg'><img src='https://badges.aleen42.com/src/wechat.svg'></a>
|
31 |
+
</div>
|
32 |
+
<br>
|
33 |
+
|
34 |
+
## 📸 Showcase
|
35 |
+
|
36 |
+
<table class="center">
|
37 |
+
<tr>
|
38 |
+
<td style="text-align: center"><b>Tailor Swift Speech @ NYU (4K, 23 minutes)</b></td>
|
39 |
+
<td style="text-align: center"><b>Johan Rockstrom Speech @ TED (4K, 18 minutes)</b></td>
|
40 |
+
</tr>
|
41 |
+
<tr>
|
42 |
+
<td style="text-align: center"><a target="_blank" href="https://cdn.aondata.work/hallo2/videos/showcases/TailorSpeech.mp4"><img src="https://cdn.aondata.work/hallo2/videos/showcases/gifs/TailorSpeechGIF.gif"></a></td>
|
43 |
+
<td style="text-align: center"><a target="_blank" href="https://cdn.aondata.work/hallo2/videos/showcases/TEDSpeech.mp4"><img src="https://cdn.aondata.work/hallo2/videos/showcases/gifs/TEDSpeechGIF.gif"></a></td>
|
44 |
+
</tr>
|
45 |
+
<tr>
|
46 |
+
<td style="text-align: center"><b>Churchill's Iron Curtain Speech (4K, 4 minutes)</b></td>
|
47 |
+
<td style="text-align: center"><b>An LLM Course from Stanford (4K, up to 1 hour)</b></td>
|
48 |
+
</tr>
|
49 |
+
<tr>
|
50 |
+
<td style="text-align: center"><a target="_blank" href="https://cdn.aondata.work/hallo2/videos/showcases/DarkestHour.mp4"><img src="https://cdn.aondata.work/hallo2/videos/showcases/gifs/DarkestHour.gif"></a></td>
|
51 |
+
<td style="text-align: center"><a target="_blank" href="https://cdn.aondata.work/hallo2/videos/showcases/LLMCourse.mp4"><img src="https://cdn.aondata.work/hallo2/videos/showcases/gifs/LLMCourseGIF.gif"></a></td>
|
52 |
+
</tr>
|
53 |
+
</table>
|
54 |
+
|
55 |
+
Visit our [project page](https://fudan-generative-vision.github.io/hallo2/#/) to view more cases.
|
56 |
+
|
57 |
+
## 🔧️ Framework
|
58 |
+
|
59 |
+
![framework](https://raw.githubusercontent.com/fudan-generative-vision/hallo2/refs/heads/main/assets/framework_2.jpg)
|
60 |
+
|
61 |
+
## ⚙️ Installation
|
62 |
+
|
63 |
+
- System requirement: Ubuntu 20.04/Ubuntu 22.04, Cuda 11.8
|
64 |
+
- Tested GPUs: A100
|
65 |
+
|
66 |
+
Create conda environment:
|
67 |
+
|
68 |
+
```bash
|
69 |
+
conda create -n hallo python=3.10
|
70 |
+
conda activate hallo
|
71 |
+
```
|
72 |
+
|
73 |
+
Install packages with `pip`
|
74 |
+
|
75 |
+
```bash
|
76 |
+
pip install torch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cu118
|
77 |
+
pip install -r requirements.txt
|
78 |
+
```
|
79 |
+
|
80 |
+
Besides, ffmpeg is also needed:
|
81 |
+
|
82 |
+
```bash
|
83 |
+
apt-get install ffmpeg
|
84 |
+
```
|
85 |
+
|
86 |
+
### 📥 Download Pretrained Models
|
87 |
+
|
88 |
+
You can easily get all pretrained models required by inference from our [HuggingFace repo](https://huggingface.co/fudan-generative-ai/hallo2).
|
89 |
+
|
90 |
+
Clone the pretrained models into `${PROJECT_ROOT}/pretrained_models` directory by cmd below:
|
91 |
+
|
92 |
+
```shell
|
93 |
+
git lfs install
|
94 |
+
git clone https://huggingface.co/fudan-generative-ai/hallo2 pretrained_models
|
95 |
+
```
|
96 |
+
|
97 |
+
Or you can download them separately from their source repo:
|
98 |
+
|
99 |
+
- [hallo](https://huggingface.co/fudan-generative-ai/hallo2/tree/main/hallo2): Our checkpoints consist of denoising UNet, face locator, image & audio proj.
|
100 |
+
- [audio_separator](https://huggingface.co/huangjackson/Kim_Vocal_2): Kim*Vocal_2 MDX-Net vocal removal model. (\_Thanks to [KimberleyJensen](https://github.com/KimberleyJensen)*)
|
101 |
+
- [insightface](https://github.com/deepinsight/insightface/tree/master/python-package#model-zoo): 2D and 3D Face Analysis placed into `pretrained_models/face_analysis/models/`. (_Thanks to deepinsight_)
|
102 |
+
- [face landmarker](https://storage.googleapis.com/mediapipe-models/face_landmarker/face_landmarker/float16/1/face_landmarker.task): Face detection & mesh model from [mediapipe](https://ai.google.dev/edge/mediapipe/solutions/vision/face_landmarker#models) placed into `pretrained_models/face_analysis/models`.
|
103 |
+
- [motion module](https://github.com/guoyww/AnimateDiff/blob/main/README.md#202309-animatediff-v2): motion module from [AnimateDiff](https://github.com/guoyww/AnimateDiff). (_Thanks to [guoyww](https://github.com/guoyww)_).
|
104 |
+
- [sd-vae-ft-mse](https://huggingface.co/stabilityai/sd-vae-ft-mse): Weights are intended to be used with the diffusers library. (_Thanks to [stablilityai](https://huggingface.co/stabilityai)_)
|
105 |
+
- [StableDiffusion V1.5](https://huggingface.co/runwayml/stable-diffusion-v1-5): Initialized and fine-tuned from Stable-Diffusion-v1-2. (_Thanks to [runwayml](https://huggingface.co/runwayml)_)
|
106 |
+
- [wav2vec](https://huggingface.co/facebook/wav2vec2-base-960h): wav audio to vector model from [Facebook](https://huggingface.co/facebook/wav2vec2-base-960h).
|
107 |
+
- [facelib](https://github.com/sczhou/CodeFormer/releases/tag/v0.1.0): pretrained face parse models
|
108 |
+
- [realesrgan](https://github.com/sczhou/CodeFormer/releases/download/v0.1.0/RealESRGAN_x2plus.pth): background upsample model
|
109 |
+
- [CodeFormer](https://github.com/sczhou/CodeFormer/releases/download/v0.1.0): pretrained [Codeformer](https://github.com/sczhou/CodeFormer) model, it's optional to download it, only if you want to train our video super-resolution model from scratch
|
110 |
+
|
111 |
+
Finally, these pretrained models should be organized as follows:
|
112 |
+
|
113 |
+
```text
|
114 |
+
./pretrained_models/
|
115 |
+
|-- audio_separator/
|
116 |
+
| |-- download_checks.json
|
117 |
+
| |-- mdx_model_data.json
|
118 |
+
| |-- vr_model_data.json
|
119 |
+
| `-- Kim_Vocal_2.onnx
|
120 |
+
|-- CodeFormer/
|
121 |
+
| |-- codeformer.pth
|
122 |
+
| `-- vqgan_code1024.pth
|
123 |
+
|-- face_analysis/
|
124 |
+
| `-- models/
|
125 |
+
| |-- face_landmarker_v2_with_blendshapes.task # face landmarker model from mediapipe
|
126 |
+
| |-- 1k3d68.onnx
|
127 |
+
| |-- 2d106det.onnx
|
128 |
+
| |-- genderage.onnx
|
129 |
+
| |-- glintr100.onnx
|
130 |
+
| `-- scrfd_10g_bnkps.onnx
|
131 |
+
|-- facelib
|
132 |
+
| |-- detection_mobilenet0.25_Final.pth
|
133 |
+
| |-- detection_Resnet50_Final.pth
|
134 |
+
| |-- parsing_parsenet.pth
|
135 |
+
| |-- yolov5l-face.pth
|
136 |
+
| `-- yolov5n-face.pth
|
137 |
+
|-- hallo2
|
138 |
+
| |-- net_g.pth
|
139 |
+
| `-- net.pth
|
140 |
+
|-- motion_module/
|
141 |
+
| `-- mm_sd_v15_v2.ckpt
|
142 |
+
|-- realesrgan
|
143 |
+
| `-- RealESRGAN_x2plus.pth
|
144 |
+
|-- sd-vae-ft-mse/
|
145 |
+
| |-- config.json
|
146 |
+
| `-- diffusion_pytorch_model.safetensors
|
147 |
+
|-- stable-diffusion-v1-5/
|
148 |
+
| `-- unet/
|
149 |
+
| |-- config.json
|
150 |
+
| `-- diffusion_pytorch_model.safetensors
|
151 |
+
`-- wav2vec/
|
152 |
+
`-- wav2vec2-base-960h/
|
153 |
+
|-- config.json
|
154 |
+
|-- feature_extractor_config.json
|
155 |
+
|-- model.safetensors
|
156 |
+
|-- preprocessor_config.json
|
157 |
+
|-- special_tokens_map.json
|
158 |
+
|-- tokenizer_config.json
|
159 |
+
`-- vocab.json
|
160 |
+
```
|
161 |
+
|
162 |
+
### 🛠️ Prepare Inference Data
|
163 |
+
|
164 |
+
Hallo has a few simple requirements for input data:
|
165 |
+
|
166 |
+
For the source image:
|
167 |
+
|
168 |
+
1. It should be cropped into squares.
|
169 |
+
2. The face should be the main focus, making up 50%-70% of the image.
|
170 |
+
3. The face should be facing forward, with a rotation angle of less than 30° (no side profiles).
|
171 |
+
|
172 |
+
For the driving audio:
|
173 |
+
|
174 |
+
1. It must be in WAV format.
|
175 |
+
2. It must be in English since our training datasets are only in this language.
|
176 |
+
3. Ensure the vocals are clear; background music is acceptable.
|
177 |
+
|
178 |
+
We have provided [some samples](examples/) for your reference.
|
179 |
+
|
180 |
+
### 🎮 Run Inference
|
181 |
+
|
182 |
+
#### Long-Duration animation
|
183 |
+
|
184 |
+
Simply to run the `scripts/inference_long.py` and change `source_image`, `driving_audio` and `save_path` in the config file:
|
185 |
+
|
186 |
+
```bash
|
187 |
+
python scripts/inference_long.py --config ./configs/inference/long.yaml
|
188 |
+
```
|
189 |
+
|
190 |
+
Animation results will be saved at `save_path`. You can find more examples for inference at [examples folder](https://github.com/fudan-generative-vision/hallo2/tree/main/examples).
|
191 |
+
|
192 |
+
For more options:
|
193 |
+
|
194 |
+
```shell
|
195 |
+
usage: inference_long.py [-h] [-c CONFIG] [--source_image SOURCE_IMAGE] [--driving_audio DRIVING_AUDIO] [--pose_weight POSE_WEIGHT]
|
196 |
+
[--face_weight FACE_WEIGHT] [--lip_weight LIP_WEIGHT] [--face_expand_ratio FACE_EXPAND_RATIO]
|
197 |
+
|
198 |
+
options:
|
199 |
+
-h, --help show this help message and exit
|
200 |
+
-c CONFIG, --config CONFIG
|
201 |
+
--source_image SOURCE_IMAGE
|
202 |
+
source image
|
203 |
+
--driving_audio DRIVING_AUDIO
|
204 |
+
driving audio
|
205 |
+
--pose_weight POSE_WEIGHT
|
206 |
+
weight of pose
|
207 |
+
--face_weight FACE_WEIGHT
|
208 |
+
weight of face
|
209 |
+
--lip_weight LIP_WEIGHT
|
210 |
+
weight of lip
|
211 |
+
--face_expand_ratio FACE_EXPAND_RATIO
|
212 |
+
face region
|
213 |
+
```
|
214 |
+
|
215 |
+
#### High-Resolution animation
|
216 |
+
|
217 |
+
Simply to run the `scripts/video_sr.py` and pass `input_video` and `output_path`:
|
218 |
+
|
219 |
+
```bash
|
220 |
+
python scripts/video_sr.py --input_path [input_video] --output_path [output_dir] --bg_upsampler realesrgan --face_upsample -w 1 -s 4
|
221 |
+
```
|
222 |
+
|
223 |
+
Animation results will be saved at `output_dir`.
|
224 |
+
|
225 |
+
For more options:
|
226 |
+
|
227 |
+
```shell
|
228 |
+
usage: video_sr.py [-h] [-i INPUT_PATH] [-o OUTPUT_PATH] [-w FIDELITY_WEIGHT] [-s UPSCALE] [--has_aligned] [--only_center_face] [--draw_box]
|
229 |
+
[--detection_model DETECTION_MODEL] [--bg_upsampler BG_UPSAMPLER] [--face_upsample] [--bg_tile BG_TILE] [--suffix SUFFIX]
|
230 |
+
|
231 |
+
options:
|
232 |
+
-h, --help show this help message and exit
|
233 |
+
-i INPUT_PATH, --input_path INPUT_PATH
|
234 |
+
Input video
|
235 |
+
-o OUTPUT_PATH, --output_path OUTPUT_PATH
|
236 |
+
Output folder.
|
237 |
+
-w FIDELITY_WEIGHT, --fidelity_weight FIDELITY_WEIGHT
|
238 |
+
Balance the quality and fidelity. Default: 0.5
|
239 |
+
-s UPSCALE, --upscale UPSCALE
|
240 |
+
The final upsampling scale of the image. Default: 2
|
241 |
+
--has_aligned Input are cropped and aligned faces. Default: False
|
242 |
+
--only_center_face Only restore the center face. Default: False
|
243 |
+
--draw_box Draw the bounding box for the detected faces. Default: False
|
244 |
+
--detection_model DETECTION_MODEL
|
245 |
+
Face detector. Optional: retinaface_resnet50, retinaface_mobile0.25, YOLOv5l, YOLOv5n. Default: retinaface_resnet50
|
246 |
+
--bg_upsampler BG_UPSAMPLER
|
247 |
+
Background upsampler. Optional: realesrgan
|
248 |
+
--face_upsample Face upsampler after enhancement. Default: False
|
249 |
+
--bg_tile BG_TILE Tile size for background sampler. Default: 400
|
250 |
+
--suffix SUFFIX Suffix of the restored faces. Default: None
|
251 |
+
```
|
252 |
+
|
253 |
+
> NOTICE: The High-Resolution animation feature is a modified version of [CodeFormer](https://github.com/sczhou/CodeFormer). When using or redistributing this feature, please comply with the [S-Lab License 1.0](https://github.com/sczhou/CodeFormer?tab=License-1-ov-file). We kindly request that you respect the terms of this license in any usage or redistribution of this component.
|
254 |
+
|
255 |
+
## Training
|
256 |
+
|
257 |
+
### Long-Duration animation
|
258 |
+
|
259 |
+
#### prepare data for training
|
260 |
+
|
261 |
+
The training data, which utilizes some talking-face videos similar to the source images used for inference, also needs to meet the following requirements:
|
262 |
+
|
263 |
+
1. It should be cropped into squares.
|
264 |
+
2. The face should be the main focus, making up 50%-70% of the image.
|
265 |
+
3. The face should be facing forward, with a rotation angle of less than 30° (no side profiles).
|
266 |
+
|
267 |
+
Organize your raw videos into the following directory structure:
|
268 |
+
|
269 |
+
```text
|
270 |
+
dataset_name/
|
271 |
+
|-- videos/
|
272 |
+
| |-- 0001.mp4
|
273 |
+
| |-- 0002.mp4
|
274 |
+
| |-- 0003.mp4
|
275 |
+
| `-- 0004.mp4
|
276 |
+
```
|
277 |
+
|
278 |
+
You can use any `dataset_name`, but ensure the `videos` directory is named as shown above.
|
279 |
+
|
280 |
+
Next, process the videos with the following commands:
|
281 |
+
|
282 |
+
```bash
|
283 |
+
python -m scripts.data_preprocess --input_dir dataset_name/videos --step 1
|
284 |
+
python -m scripts.data_preprocess --input_dir dataset_name/videos --step 2
|
285 |
+
```
|
286 |
+
|
287 |
+
**Note:** 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`.
|
288 |
+
|
289 |
+
Generate the metadata JSON files with the following commands:
|
290 |
+
|
291 |
+
```bash
|
292 |
+
python scripts/extract_meta_info_stage1.py -r path/to/dataset -n dataset_name
|
293 |
+
python scripts/extract_meta_info_stage2.py -r path/to/dataset -n dataset_name
|
294 |
+
```
|
295 |
+
|
296 |
+
Replace `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.
|
297 |
+
|
298 |
+
#### Training
|
299 |
+
|
300 |
+
Update the data meta path settings in the configuration YAML files, `configs/train/stage1.yaml` and `configs/train/stage2_long.yaml`:
|
301 |
+
|
302 |
+
```yaml
|
303 |
+
#stage1.yaml
|
304 |
+
data:
|
305 |
+
meta_paths:
|
306 |
+
- ./data/dataset_name_stage1.json
|
307 |
+
|
308 |
+
#stage2.yaml
|
309 |
+
data:
|
310 |
+
meta_paths:
|
311 |
+
- ./data/dataset_name_stage2.json
|
312 |
+
```
|
313 |
+
|
314 |
+
Start training with the following command:
|
315 |
+
|
316 |
+
```shell
|
317 |
+
accelerate launch -m \
|
318 |
+
--config_file accelerate_config.yaml \
|
319 |
+
--machine_rank 0 \
|
320 |
+
--main_process_ip 0.0.0.0 \
|
321 |
+
--main_process_port 20055 \
|
322 |
+
--num_machines 1 \
|
323 |
+
--num_processes 8 \
|
324 |
+
scripts.train_stage1 --config ./configs/train/stage1.yaml
|
325 |
+
```
|
326 |
+
|
327 |
+
##### Accelerate Usage Explanation
|
328 |
+
|
329 |
+
The `accelerate launch` command is used to start the training process with distributed settings.
|
330 |
+
|
331 |
+
```shell
|
332 |
+
accelerate launch [arguments] {training_script} --{training_script-argument-1} --{training_script-argument-2} ...
|
333 |
+
```
|
334 |
+
|
335 |
+
**Arguments for Accelerate:**
|
336 |
+
|
337 |
+
- `-m, --module`: Interpret the launch script as a Python module.
|
338 |
+
- `--config_file`: Configuration file for Hugging Face Accelerate.
|
339 |
+
- `--machine_rank`: Rank of the current machine in a multi-node setup.
|
340 |
+
- `--main_process_ip`: IP address of the master node.
|
341 |
+
- `--main_process_port`: Port of the master node.
|
342 |
+
- `--num_machines`: Total number of nodes participating in the training.
|
343 |
+
- `--num_processes`: Total number of processes for training, matching the total number of GPUs across all machines.
|
344 |
+
|
345 |
+
**Arguments for Training:**
|
346 |
+
|
347 |
+
- `{training_script}`: The training script, such as `scripts.train_stage1` or `scripts.train_stage2`.
|
348 |
+
- `--{training_script-argument-1}`: Arguments specific to the training script. Our training scripts accept one argument, `--config`, to specify the training configuration file.
|
349 |
+
|
350 |
+
For multi-node training, you need to manually run the command with different `machine_rank` on each node separately.
|
351 |
+
|
352 |
+
For more settings, refer to the [Accelerate documentation](https://huggingface.co/docs/accelerate/en/index).
|
353 |
+
|
354 |
+
### High-Resolution animation
|
355 |
+
|
356 |
+
#### Training
|
357 |
+
|
358 |
+
##### prepare data for training
|
359 |
+
|
360 |
+
We use the VFHQ dataset for training, you can download from its [homepage](https://liangbinxie.github.io/projects/vfhq/). Then updata `dataroot_gt` in `./configs/train/video_sr.yaml`.
|
361 |
+
|
362 |
+
#### training
|
363 |
+
|
364 |
+
Start training with the following command:
|
365 |
+
|
366 |
+
```shell
|
367 |
+
python -m torch.distributed.launch --nproc_per_node=8 --master_port=4322 \
|
368 |
+
basicsr/train.py -opt ./configs/train/video_sr.yaml \
|
369 |
+
--launcher pytorch
|
370 |
+
```
|
371 |
+
|
372 |
+
## 📝 Citation
|
373 |
+
|
374 |
+
If you find our work useful for your research, please consider citing the paper:
|
375 |
+
|
376 |
+
```
|
377 |
+
@misc{cui2024hallo2,
|
378 |
+
title={Hallo2: Long-Duration and High-Resolution Audio-driven Portrait Image Animation},
|
379 |
+
author={Jiahao Cui and Hui Li and Yao Yao and Hao Zhu and Hanlin Shang and Kaihui Cheng and Hang Zhou and Siyu Zhu and️ Jingdong Wang},
|
380 |
+
year={2024},
|
381 |
+
eprint={2410.07718},
|
382 |
+
archivePrefix={arXiv},
|
383 |
+
primaryClass={cs.CV}
|
384 |
+
}
|
385 |
+
```
|
386 |
+
|
387 |
+
## 🌟 Opportunities Available
|
388 |
+
|
389 |
+
Multiple research positions are open at the **Generative Vision Lab, Fudan University**! Include:
|
390 |
+
|
391 |
+
- Research assistant
|
392 |
+
- Postdoctoral researcher
|
393 |
+
- PhD candidate
|
394 |
+
- Master students
|
395 |
+
|
396 |
+
Interested individuals are encouraged to contact us at [[email protected]](mailto://[email protected]) for further information.
|
397 |
+
|
398 |
+
## ⚠️ Social Risks and Mitigations
|
399 |
+
|
400 |
+
The development of portrait image animation technologies driven by audio inputs poses social risks, such as the ethical implications of creating realistic portraits that could be misused for deepfakes. To mitigate these risks, it is crucial to establish ethical guidelines and responsible use practices. Privacy and consent concerns also arise from using individuals' images and voices. Addressing these involves transparent data usage policies, informed consent, and safeguarding privacy rights. By addressing these risks and implementing mitigations, the research aims to ensure the responsible and ethical development of this technology.
|
401 |
+
|
402 |
+
## 🤗 Acknowledgements
|
403 |
+
|
404 |
+
We would like to thank the contributors to the [magic-animate](https://github.com/magic-research/magic-animate), [AnimateDiff](https://github.com/guoyww/AnimateDiff), [ultimatevocalremovergui](https://github.com/Anjok07/ultimatevocalremovergui), [AniPortrait](https://github.com/Zejun-Yang/AniPortrait) and [Moore-AnimateAnyone](https://github.com/MooreThreads/Moore-AnimateAnyone) repositories, for their open research and exploration.
|
405 |
+
|
406 |
+
If we missed any open-source projects or related articles, we would like to complement the acknowledgement of this specific work immediately.
|
407 |
+
|
408 |
+
## 👏 Community Contributors
|
409 |
+
|
410 |
+
Thank you to all the contributors who have helped to make this project better!
|
411 |
+
|
412 |
+
<a href="https://github.com/fudan-generative-vision/hallo2/graphs/contributors">
|
413 |
+
<img src="https://contrib.rocks/image?repo=fudan-generative-vision/hallo2" />
|
414 |
+
</a>
|
415 |
+
|