Home

Awesome

MoFaNeRF:Morphable Facial Neural Radiance Field

report report report report report

<img src="https://i.imgur.com/PNRhZAN.png" width="1024">

Any questions or discussions are welcomed!

Catalog

Install

pip install -r requirements.txt # tested on Python 3.7
<box style="text-indent:1.0em; font-size: 13px"> <details> <summary> Dependencies (click to expand) </summary> </details> </box> <br>

Download the pretrained models:

./download_pretrained_models.sh

Test our model

<img src="https://neverstopzyy.github.io/mofanerf/images/fig_gen_fit.png" width=1024>

1. Prepare your data first

We preprocess wild images using the following three steps: alignment, segmentation and relighting, and we pack these steps into wildData_preprocess.py. After the preprocessing, one aligned image and one estimated camera pose you will get.

This demo show the way to batch processing of the wild images.

 python ./tools/wildData_preprocess.py --filePath ./data/fit/

2. Fit to the processed image

This demo show how to fit our model to target image.

python run_fit.py --filePath ./data/fit/segRelRes/1.png

3. Render images of novel views

This demo show how to render novel views with the fitted parameters, and just simply add one parameter "--renderType rendering".

python run_fit.py --filePath ./data/fit/segRelRes/1.png --renderType rendering  

4. Refine the rendered results

This demo show how to use our refinement module to enrich details of the rendered results.

The refined results will be saved in folder refine in the same parent directory as the target folder.

python run_refine.py --name facescape --nerf_folder ./data/fit/fitting/segRelRes_1/render/

1. Render modulation results

This demo simply show how to rig and edit the fitting results.

python run_fit.py --filePath ./data/fit/segRelRes/1.png --renderType rendering_modulation

2. Refine the rendered results

python run_refine.py --name facescape --nerf_folder ./data/fit/fitting/segRelRes_1/render/

Train your own model

1. Train the coarse part of MoFaNeRF

 python run_train.py --config ./configs/exp_mofanerf.txt

2. There are three steps to train our refineNet:

2.1. Render the training data with MoFaNeRF:

python render_refine_trainSet.py  --config ./configs/exp_mofanerf.txt

2.2. Prepare paired ground truth images of rendered results:

Try to modify the folder paths in prepare_refineNet_trainSet.py to achieve it.

2.3. Run the training code for refineNet:

python run_train_refineNet.py --name facescape --dataroot *dataPath* --nerf_folder train --gt_folder GT

Tips: It takes a long time to run render_refine_trainSet.py, so you can try to distribute the task across several machines. A simple way to do this is to split the identity list with the parameters "begin_person" and "end_person", thus enabling multiple identities to be rendered at the same time.

Bibtex

If you find this project helpful to your research, please consider citing:

@InProceedings{zhuang2022mofanerf,
  title={MoFaNeRF: Morphable Facial Neural Radiance Field},
  author={Zhuang, Yiyu and Zhu, Hao and Sun, Xusen and Cao, Xun},
  booktitle={European Conference on Computer Vision},
  year={2022}
}