仓库:GitHub - waityousea/xuniren

附:xuniren windows安装教程

NeRF视频三维重建视频训练步骤:

环境说明:
官方:Ubuntu 22.04,Pytorch 1.12 and CUDA 11.6。
实测:Ubuntu 20.04,PyTorch  1.11.0,Python  3.8(ubuntu20.04),Cuda  11.3。

视频训练(fay):
一、训练准备
1.使用以下仓库进行模型训练
git clone https://github.com/ashawkey/RAD-NeRF.git
cd RAD-NeRF

2.安装依赖
sudo apt install portaudio19-dev
sudo apt install ffmpeg
pip install -r requirements.txt

3.生成扩展
bash scripts/install_ext.sh

4.安装pytorch3d
pip install "git+https://github.com/facebookresearch/pytorch3d.git"

二、视频数据预处理
1.视频要求
512*512像素,25FPS,1~5分钟,mp4格式。
(用V100或者3090,视频大于4分钟,训练效果不太理想,3分钟左右会比较合适。)

2.安装pytorch3d
pip install "git+https://github.com/facebookresearch/pytorch3d.git"

3.准备人脸解析模型
wget https://github.com/YudongGuo/AD-NeRF/blob/master/data_util/face_parsing/79999_iter.pth?raw=true -O data_utils/face_parsing/79999_iter.pth

4.准备basel脸部模型
从https://faces.dmi.unibas.ch/bfm/main.php?nav=1-2&id=downloads下载`01_MorphableModel.mat`
将文件放到 `data_utils/face_tracking/3DMM/`
wget https://github.com/YudongGuo/AD-NeRF/blob/master/data_util/face_tracking/3DMM/exp_info.npy?raw=true -O data_utils/face_tracking/3DMM/exp_info.npy
wget https://github.com/YudongGuo/AD-NeRF/blob/master/data_util/face_tracking/3DMM/keys_info.npy?raw=true -O data_utils/face_tracking/3DMM/keys_info.npy
wget https://github.com/YudongGuo/AD-NeRF/blob/master/data_util/face_tracking/3DMM/sub_mesh.obj?raw=true -O data_utils/face_tracking/3DMM/sub_mesh.obj
wget https://github.com/YudongGuo/AD-NeRF/blob/master/data_util/face_tracking/3DMM/topology_info.npy?raw=true -O data_utils/face_tracking/3DMM/topology_info.npy

5.运行convert_BFM.py
cd data_utils/face_tracking
python convert_BFM.py

6.准备ASR模型
选择安装DeepSpeech(需要手动安装TensorFlow 1.15)或Wav2Vec(PyTorch实现)。

7.开始处理
#执行全部步骤
python data_utils/process.py data/<ID>/<ID>.mp4
#分步执行(共9步)
python data_utils/process.py data/<ID>/<ID>.mp4 --task 1

8.检查输出文件
处理完成结果:
./data/<ID>
├──<ID>.mp4 # original video
├──ori_imgs # original images from video
│  ├──0.jpg
│  ├──0.lms # 2D landmarks
│  ├──...
├──gt_imgs # ground truth images (static background)
│  ├──0.jpg
│  ├──...
├──parsing # semantic segmentation
│  ├──0.png
│  ├──...
├──torso_imgs # inpainted torso images
│  ├──0.png
│  ├──...
├──aud.wav # original audio   task 1 
├──aud_eo.npy # audio features (wav2vec)
├──aud.npy # audio features (deepspeech)
├──bc.jpg # default background
├──track_params.pt # raw head tracking results
├──transforms_train.json # head poses (train split)
├──transforms_val.json # head poses (test split)

9.替换xuniren的文件
transforms_train.json替换/xuniren/data/kf.json
(重命名为kf.json)

三、视频训练
# 默认使用硬盘.
# 可以指定CPU/GPU进行训练.
# `--preload 0`:从硬盘加载数据 (默认, 慢).
# `--preload 1`: 指定CPU,约70G内存 (较慢)
# `--preload 2`: 指定GPU,约24G显存 (快)
1.头部训练(不建议增加太多)
python main.py data/<ID>/  --workspace <trial_ID>/ -O --iters 200000

2.唇部微调
python main.py data/<fay03_fh>/  --workspace <trial_ID>/ -O --iters 500000 --finetune_lips

3.躯干训练(视频身体部分一定不能太多)
python main.py data/<fay03_fh>/  --workspace <trial_ID_torso>/ -O --torso --head_ckpt <trial_ID>/checkpoints/<npg_0043.pth> --iters 200000 --preload 2

4.替换xuniren的文件
/RAD-NeRF/data/<trial_ID>/<trial_ID_torso>/checkpoints/<ngp_ep0043.pth>替换/xuniren/data/pretrained/ngp_kf.pth
(重命名为ngp_kf.pth)

Logo

鸿蒙生态一站式服务平台。

更多推荐