Deep3DFaceReconstruction让一张人脸照片变成三维的真人脸

Deep3DFaceReconstruction让一张人脸照片变成三维的真人脸

flyfish

曾经是需要这样的,头上戴设备的,现在用AI可以省点麻烦。
Deep3DFaceReconstruction让一张人脸照片变成三维的真人脸_第1张图片

实例1

论文Accurate 3D Face Reconstruction with Weakly-Supervised Learning: From Single Image to Image Set

TensorFlow版本源码
PyTorch版本源码
推荐点击这里下载源码和模型,原网址不带模型的,本文已经提供好了源码和模型的下载地址,这里是PyTorch版本.

链接:https://pan.baidu.com/s/1FuTOeo5kR4ziiAwt1BjxSw 
提取码:fb4q

如果直接使用原网站源码,需要到 https://faces.dmi.unibas.ch/ 注册之后,才能下载模型,这里避免了到各个地方下载的劳役之苦

如果不使用本下载地址,需要做以下工作

推理需要准备的模型

两个模型如下放置

Deep3DFaceRecon_pytorch
│
└─── BFM
    │
    └─── 01_MorphableModel.mat
    │
    └─── Exp_Pca.bin
    |
    └─── ...

一个模型如下放置

Deep3DFaceRecon_pytorch
│
└─── checkpoints
    │
    └─── 
        │
        └─── epoch_20.pth

训练需要准备的模型

多个模型如下放置

Deep3DFaceRecon_pytorch
│
└─── checkpoints
    │
    └─── recog_model
        │
        └─── ms1mv3_arcface_r50_fp16
	    |
	    └─── backbone.pth

一个模型如下放置

Deep3DFaceRecon_pytorch
│
└─── checkpoints
    │
    └─── init_model
        │
        └─── resnet50-0676ba61.pth

一个模型如下放置

Deep3DFaceRecon_pytorch
│
└─── checkpoints
    │
    └─── lm_model
        │
        └─── 68lm_detector.pb

测试
模型名字懒得起名字就叫model_name

 python test.py --name=model_name --epoch=20 --img_folder=./datasets/examples

成功之后如下提示

----------------- Options ---------------
                add_image: True                          
               bfm_folder: BFM                           
                bfm_model: BFM_model_front.mat           
                 camera_d: 10.0                          
                   center: 112.0                         
          checkpoints_dir: ./checkpoints                 
             dataset_mode: None                          
                 ddp_port: 12355                         
        display_per_batch: True                          
                    epoch: 20                            	[default: latest]
          eval_batch_nums: inf                           
                    focal: 1015.0                        
                  gpu_ids: 0                             
               img_folder: ./datasets/examples           	[default: examples]
                init_path: checkpoints/init_model/resnet50-0676ba61.pth
                  isTrain: False                         	[default: None]
                    model: facerecon                     
                     name: model_name                    	[default: face_recon]
                net_recon: resnet50                      
                    phase: test                          
                   suffix:                               
                  use_ddp: False                         	[default: True]
              use_last_fc: False                         
                  verbose: False                         
           vis_batch_nums: 1                             
               world_size: 1                             
                    z_far: 15.0                          
                   z_near: 5.0                           
----------------- End -------------------
model [FaceReconModel] was created
loading the model from ./checkpoints/model_name/epoch_20.pth
0 ./datasets/examples/000002.jpg
create glctx on device cuda:0
1 ./datasets/examples/000006.jpg
2 ./datasets/examples/000007.jpg
3 ./datasets/examples/000031.jpg
...

训练的数据集,网盘不得浪费空间,没放进网盘

Path Size Files Format Description
ffhq-dataset 2.56 TB 210,014 Main folder
├  ffhq-dataset-v2.json 255 MB 1 JSON Metadata including copyright info, URLs, etc.
├  images1024x1024 89.1 GB 70,000 PNG Aligned and cropped images at 1024×1024
├  thumbnails128x128 1.95 GB 70,000 PNG Thumbnails at 128×128
├  in-the-wild-images 955 GB 70,000 PNG Original images from Flickr
├  tfrecords 273 GB 9 tfrecords Multi-resolution data for StyleGAN and StyleGAN2
└  zips 1.28 TB 4 ZIP Contents of each folder as a ZIP archive.

实例2

论文 Towards Fast, Accurate and Stable 3D Dense Face Alignment
官网地址 https://github.com/cleardusk/3DDFA_V2

模型和源码下载地址

链接:

链接:https://pan.baidu.com/s/1szv4JIklfxDiDkzeZ2KWow 
提取码:arpx

简单的测试命令

python3 demo.py -f examples/inputs/emma.jpg -o 3d

效果图片自己脑补或者打开文件看吧,传上来容易违规。

如果把真人脸迁移到卡通的样子

你可能感兴趣的:(有趣的AI,人工智能,深度学习,计算机视觉)