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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
'[object Object]': null
|
3 |
+
license: mit
|
4 |
+
---
|
5 |
+
<h1 align='center'>DicFace: Dirichlet-Constrained Variational Codebook Learning for Temporally Coherent Video Face Restoration</h1>
|
6 |
+
|
7 |
+
<div align='center'>
|
8 |
+
<a href='' target='_blank'>Yan Chen</a><sup>1</sup> 
|
9 |
+
<a href='' target='_blank'>Hanlin Shang</a><sup>1</sup> 
|
10 |
+
<a href='' target='_blank'>Ce Liu</a><sup>1</sup> 
|
11 |
+
<a href='' target='_blank'>Yuxuan Chen</a><sup>1</sup> 
|
12 |
+
<a href='' target='_blank'>Hui Li</a><sup>1</sup> 
|
13 |
+
<a href='' target='_blank'>Weihao Yuan</a><sup>2</sup> 
|
14 |
+
</div>
|
15 |
+
<div align='center'>
|
16 |
+
<a href='' target='_blank'>Hao Zhu</a><sup>3</sup> 
|
17 |
+
<a href='' target='_blank'>Zilong Dong</a><sup>2</sup> 
|
18 |
+
<a href='https://sites.google.com/site/zhusiyucs/home' target='_blank'>Siyu Zhu</a><sup>1โ๏ธ</sup> 
|
19 |
+
</div>
|
20 |
+
|
21 |
+
<div align='center'>
|
22 |
+
<sup>1</sup>Fudan University 
|
23 |
+
<sup>2</sup>Alibaba Group 
|
24 |
+
<sup>3</sup>Nanjing University 
|
25 |
+
</div>
|
26 |
+
|
27 |
+
<br>
|
28 |
+
<div align='center'>
|
29 |
+
<a href='https://github.com/fudan-generative-vision/DicFace'><img src='https://img.shields.io/github/stars/fudan-generative-vision/DicFace'></a>
|
30 |
+
<!-- <a href='https://github.com/fudan-generative-vision/DicFace/#/'><img src='https://img.shields.io/badge/Project-HomePage-Green'></a> -->
|
31 |
+
<a href='https://arxiv.org/abs/2506.13355'><img src='https://img.shields.io/badge/Paper-Arxiv-red'></a>
|
32 |
+
<!-- <a href=''><img src='https://img.shields.io/badge/%F0%9F%A4%97%20HuggingFace-Model-yellow'></a> -->
|
33 |
+
<!-- <a href='assets/wechat.jpeg'><img src='https://badges.aleen42.com/src/wechat.svg'></a> -->
|
34 |
+
</div>
|
35 |
+
<!-- <div align='Center'>
|
36 |
+
<i><strong><a href='https://cvpr.thecvf.com/Conferences/2025' target='_blank'>CVPR 2025</a></strong></i>
|
37 |
+
</div> -->
|
38 |
+
<br>
|
39 |
+
<!--
|
40 |
+
<table align='center' border="0" style="width: 100%; text-align: center; margin-top: 80px;">
|
41 |
+
<tr>
|
42 |
+
<td>
|
43 |
+
<video align='center' src="https://github.com/user-attachments/assets/274ecc2b-3d89-4d31-bb0a-a5f3611fae8a" muted autoplay loop></video>
|
44 |
+
</td>
|
45 |
+
</tr>
|
46 |
+
</table> -->
|
47 |
+
|
48 |
+
|
49 |
+
<table align="center" border="0" style="width: 100%; margin-top: 80px;">
|
50 |
+
<tr>
|
51 |
+
<td style="text-align: center;">
|
52 |
+
<video src="https://github.com/user-attachments/assets/274ecc2b-3d89-4d31-bb0a-a5f3611fae8a"
|
53 |
+
muted autoplay loop style="display: block; margin: 0 auto;"></video>
|
54 |
+
</td>
|
55 |
+
</tr>
|
56 |
+
</table>
|
57 |
+
## ๐ธ Showcase
|
58 |
+
|
59 |
+
### Blind Face Restoration
|
60 |
+
<table align="center" width="100%" border="0" cellpadding="10">
|
61 |
+
<tr>
|
62 |
+
<td style="text-align: center;">
|
63 |
+
<video src="https://github.com/user-attachments/assets/eb61d793-b860-476e-bae5-f6fcade1e11f" muted autoplay loop width="480"></video>
|
64 |
+
</td>
|
65 |
+
<td style="text-align: center;">
|
66 |
+
<video src="https://github.com/user-attachments/assets/eb9be43a-8fb9-4fbd-ac92-a686ab0c188b" muted autoplay loop width="480"></video>
|
67 |
+
</td>
|
68 |
+
</tr>
|
69 |
+
</table>
|
70 |
+
|
71 |
+
|
72 |
+
### Face Inpainting
|
73 |
+
<table align="center" width="100%" border="0" cellpadding="10">
|
74 |
+
<tr>
|
75 |
+
<td style="text-align: center;">
|
76 |
+
<video src="https://github.com/user-attachments/assets/1cd12d53-2ead-4cf3-b56c-1a6316484e93" muted autoplay loop width="480"></video>
|
77 |
+
</td>
|
78 |
+
<td style="text-align: center;">
|
79 |
+
<video src="https://github.com/user-attachments/assets/a16b7021-a401-41cb-9a39-37a788f6a001" muted autoplay loop width="480"></video>
|
80 |
+
</td>
|
81 |
+
</tr>
|
82 |
+
</table>
|
83 |
+
|
84 |
+
### Face Colorization
|
85 |
+
<table align="center" width="100%" border="0" cellpadding="10">
|
86 |
+
<tr>
|
87 |
+
<td style="text-align: center;">
|
88 |
+
<video src="https://github.com/user-attachments/assets/cb038911-8b26-472d-8fb9-a6cdda127084" muted autoplay loop width="480"></video>
|
89 |
+
</td>
|
90 |
+
<td style="text-align: center;">
|
91 |
+
<video src="https://github.com/user-attachments/assets/ffc85ef7-4987-42af-b892-79544ea29f87" muted autoplay loop width="480"></video>
|
92 |
+
</td>
|
93 |
+
</tr>
|
94 |
+
</table>
|
95 |
+
|
96 |
+
## ๐ฐ News
|
97 |
+
|
98 |
+
- **`2025/06/23`**: Release our pretrained model on huggingface [repo](https://huggingface.co/fudan-generative-ai/DicFace).
|
99 |
+
- **`2025/06/17`**: Paper submitted on Arixiv. [paper](https://arxiv.org/abs/2506.13355)
|
100 |
+
- **`2025/06/16`**: ๐๐๐ Release inference scripts
|
101 |
+
|
102 |
+
|
103 |
+
|
104 |
+
## ๐
๏ธ Roadmap
|
105 |
+
|
106 |
+
| Status | Milestone | ETA |
|
107 |
+
| :----: | :------------------------------------------------------------------------------------------- | :--------: |
|
108 |
+
| โ
| **[Inference Code release](https://github.com/fudan-generative-vision/DicFace)** | 2025-6-16 |
|
109 |
+
| โ
| **[Model Weight release๏ผ baidu-link](https://pan.baidu.com/s/1VTNbdtZDvgY0163a1T8ITw?pwd=dicf)** |2025-6-16|
|
110 |
+
| โ
| **[Paper submitted on Arixiv](https://arxiv.org/abs/2506.13355)** | 2025-6-17 |
|
111 |
+
| ๐ | **[Test data release]()** | 2025-6-24 |
|
112 |
+
| ๐ | **[Training Code release]()** | 2025-6-24 |
|
113 |
+
|
114 |
+
|
115 |
+
|
116 |
+
## โ๏ธ Installation
|
117 |
+
|
118 |
+
- System requirement: PyTorch version >=2.4.1, python == 3.10
|
119 |
+
- Tested on GPUs: A800, python version == 3.10, PyTorch version == 2.4.1, cuda version == 12.1
|
120 |
+
|
121 |
+
Download the codes:
|
122 |
+
|
123 |
+
```bash
|
124 |
+
git clone https://github.com/fudan-generative-vision/DicFace
|
125 |
+
cd DicFace
|
126 |
+
```
|
127 |
+
|
128 |
+
Create conda environment:
|
129 |
+
|
130 |
+
```bash
|
131 |
+
conda create -n DicFace python=3.10
|
132 |
+
conda activate DicFace
|
133 |
+
```
|
134 |
+
|
135 |
+
Install PyTorch
|
136 |
+
|
137 |
+
```bash
|
138 |
+
conda install pytorch==2.4.1 torchvision==0.19.1 torchaudio==2.4.1 pytorch-cuda=12.1 -c pytorch -c nvidia
|
139 |
+
```
|
140 |
+
|
141 |
+
Install packages with `pip`
|
142 |
+
|
143 |
+
```bash
|
144 |
+
pip install -r requirements.txt
|
145 |
+
python basicsr/setup.py develop
|
146 |
+
conda install -c conda-forge dlib
|
147 |
+
```
|
148 |
+
|
149 |
+
### ๐ฅ Download Pretrained Models
|
150 |
+
|
151 |
+
The pre-trained weights have been uploaded to Baidu Netdisk. Please download them from the [link](https://pan.baidu.com/s/1VTNbdtZDvgY0163a1T8ITw?pwd=dicf)
|
152 |
+
|
153 |
+
Now you can easily get all pretrained models required by inference from our HuggingFace [repo](https://huggingface.co/fudan-generative-ai/DicFace).
|
154 |
+
|
155 |
+
**File Structure of Pretrained Models**
|
156 |
+
The downloaded .ckpts directory contains the following pre-trained models:
|
157 |
+
|
158 |
+
```
|
159 |
+
.ckpts
|
160 |
+
|-- CodeFormer # CodeFormer-related models
|
161 |
+
| |-- bfr_100k.pth # Blind Face Restoration model
|
162 |
+
| |-- color_100k.pth # Color Restoration model
|
163 |
+
| `-- inpainting_100k.pth # Image Inpainting model
|
164 |
+
|-- dlib # dlib face-related models
|
165 |
+
| |-- mmod_human_face_detector.dat # Human face detector
|
166 |
+
| `-- shape_predictor_5_face_landmarks.dat # 5-point face landmark predictor
|
167 |
+
|-- facelib # Face processing library models
|
168 |
+
| |-- detection_Resnet50_Final.pth # ResNet50 face detector
|
169 |
+
| |-- detection_mobilenet0.25_Final.pth # MobileNet0.25 face detector
|
170 |
+
| |-- parsing_parsenet.pth # Face parsing model
|
171 |
+
| |-- yolov5l-face.pth # YOLOv5l face detection model
|
172 |
+
| `-- yolov5n-face.pth # YOLOv5n face detection model
|
173 |
+
|-- realesrgan # Real-ESRGAN super-resolution model
|
174 |
+
| `-- RealESRGAN_x2plus.pth # 2x super-resolution enhancement model
|
175 |
+
`-- vgg # VGG feature extraction model
|
176 |
+
`-- vgg.pth # VGG network pre-trained weights
|
177 |
+
```
|
178 |
+
|
179 |
+
### ๐ฎ Run Inference
|
180 |
+
|
181 |
+
#### for blind face restoration
|
182 |
+
|
183 |
+
```bash
|
184 |
+
python scripts/inference.py \
|
185 |
+
-i /path/to/video \
|
186 |
+
-o /path/to/output_folder \
|
187 |
+
--max_length 10 \
|
188 |
+
--save_video_fps 24 \
|
189 |
+
--ckpt_path /bfr/bfr_weight.pth \
|
190 |
+
--bg_upsampler realesrgan \
|
191 |
+
--save_video
|
192 |
+
|
193 |
+
# or your videos has been aligned
|
194 |
+
python scripts/inference.py \
|
195 |
+
-i /path/to/video \
|
196 |
+
-o /path/to/output_folder \
|
197 |
+
--max_length 10 \
|
198 |
+
--save_video_fps 24 \
|
199 |
+
--ckpt_path /bfr/bfr_weight.pth \
|
200 |
+
--save_video \
|
201 |
+
--has_aligned
|
202 |
+
```
|
203 |
+
|
204 |
+
#### for colorization & inpainting task
|
205 |
+
|
206 |
+
|
207 |
+
**The current colorization & inpainting tasks only supports input of aligned faces. If a non-aligned face is input, it may lead to unsatisfactory final results.**
|
208 |
+
|
209 |
+
``` bash
|
210 |
+
# for colorization task
|
211 |
+
python scripts/inference_color_and_inpainting.py \
|
212 |
+
-i /path/to/video_warped \
|
213 |
+
-o /path/to/output_folder \
|
214 |
+
--max_length 10 \
|
215 |
+
--save_video_fps 24 \
|
216 |
+
--ckpt_path /colorization/colorization_weight.pth \
|
217 |
+
--bg_upsampler realesrgan \
|
218 |
+
--save_video \
|
219 |
+
--has_aligned
|
220 |
+
|
221 |
+
# for inpainting task
|
222 |
+
python scripts/inference_color_and_inpainting.py \
|
223 |
+
-i /path/to/video_warped \
|
224 |
+
-o /path/to/output_folder \
|
225 |
+
--max_length 10 \
|
226 |
+
--save_video_fps 24 \
|
227 |
+
--ckpt_path /inpainting/inpainting_weight.pth \
|
228 |
+
--bg_upsampler realesrgan \
|
229 |
+
--save_video \
|
230 |
+
--has_aligned
|
231 |
+
```
|
232 |
+
|
233 |
+
## test data
|
234 |
+
|
235 |
+
our test data link: https://pan.baidu.com/s/1zMp3fnf6LvlRT9CAoL1OUw?pwd=drhh
|
236 |
+
|
237 |
+
**TBD**
|
238 |
+
|
239 |
+
## ๐ Citation
|
240 |
+
|
241 |
+
If you find our work useful for your research, please consider citing the paper:
|
242 |
+
|
243 |
+
```
|
244 |
+
@misc{chen2025dicfacedirichletconstrainedvariationalcodebook,
|
245 |
+
title={DicFace: Dirichlet-Constrained Variational Codebook Learning for Temporally Coherent Video Face Restoration},
|
246 |
+
author={Yan Chen and Hanlin Shang and Ce Liu and Yuxuan Chen and Hui Li and Weihao Yuan and Hao Zhu and Zilong Dong and Siyu Zhu},
|
247 |
+
year={2025},
|
248 |
+
eprint={2506.13355},
|
249 |
+
archivePrefix={arXiv},
|
250 |
+
primaryClass={cs.CV},
|
251 |
+
url={https://arxiv.org/abs/2506.13355},
|
252 |
+
}
|
253 |
+
|
254 |
+
```
|