YuanxunLu / LiveSpeechPortraits

Live Speech Portraits: Real-Time Photorealistic Talking-Head Animation (SIGGRAPH Asia 2021)
MIT License
1.16k stars 198 forks source link

部分问题 #63

Closed foocker closed 2 years ago

foocker commented 2 years ago

抱歉看了一些信息,还是有很多细节问题。 下面是初步疑问,待更新。 希望在不违背保密协议的情况下,楼主解答部分问题。

开这个题也在于想将其全部解答,对后来者友好。

训练理解

整体上模型本身已经实现了损失函数和训练流程代码,只需要自己实现数据制作即可训练。
有三个模型需要训练:audio2feature,audio2headpose和feature2face,分别建模音频到嘴巴3D偏移量(25*3),上身刚性运动(肩膀),关键点到人脸的生成映射。
已给的数据类audiovisual_dataset,face_dataset,前者用于audio2feature和audio2headpose的训练,后者用于feature2face的训练。

目前看来核心点全来自3D 人脸追踪相关数据处理方法

数据组织:

一个五分钟左右的单人带语音高清视频,生成如下组织格式的训练素材
  data
      -- train
          --person1
              --xxx1(见feature2face需要的数据等展开内容)
              ...
          --person2
              --xxx2
              ...
          ...
      --val
          ...
      -- test
          ...
  train_list.txt (person1, person2, ...) opt.train_dataset_persons
  val_list.txt 

  因为是person-special, 所以self.clip_nums = len(self.clip_names)=len(opt.xx_dataset_names)
  应该是一个人的视频分成了很多部分。 
  data
      --person1
          -- train
              --clip_num_i
                  ....见feature2face需要的数据等展开内容
              ...
          -- val
              ...
          -- test
              ...

          train_list.txt (clip_num_0, clip_num_1, ...) opt.train_dataset_persons
          val_list.txt 

      --person2
          ...
          ...
          ...

训练audio2feature需要的数据:

音频
    从视频中ffmpeg提取
mean_pts3d.npy
    3D人脸追踪坐标平均值
x_APC_feature_V0324_ckpt_xx.npy 
    自动计算而得
3d_fit_data.npz
    见下

训练audio2headpose需要的数据:

3d_fit_data.npz 或者tracking_results.mat 替代
    见下
tracked3D_normalized_pts_fix_contour.npy
    见下

feature2face需要的数据:

帧图片
    原始视频帧图?
*.h5 
    image info(帧名字,标签信息等),具体是原始帧路径和图片二进制内容
candidates
    候选规则暂时随意。
camera_intrinsic.npy
    针孔模型,a perspective camera (pinhole) model,3D人脸追踪模型自带?主要是f值的计算问题。
change_paras.npz
    tracking results 是原视频帧上的3D人脸坐标? 3D人脸追踪会自带其对应的相机模型(直接得到相机参数)?
    'scale, xc, yc' 怎么计算的? 虽然在另一个issue回答了,但还是不知道怎么计算。
tracked2D_normalized_pts_fix_contour.npy
    如何fixed the contour indices instead of using sliding contour indices found during the tracking?这里只知道其是512*512坐标系。
3d_fit_data.npz
    pts_3d:普通3D人脸预测出的3D坐标?比如DECA, 在原始视频帧上预测的3D人脸坐标
    rot_angles:其欧拉角?
    trans:平移向量
    以上三者是对裁剪缩放后的人脸做的3D预测,作为直接的训练文件还是? 看其他答案是在原始视频帧上的预测,因此推测:
    3D模型有对应的相机模型,可以将其(pts_3d)映射为2D人脸图片,然后对此2D人脸做缩放和裁剪到512,得到change_paras.npz 
    对pts_3d作用摄像机模型以及固定边缘,可得到tracked2D_normalized_pts_fix_contour.npy

mean_pts3d.npy
    该人物训练集中3D关键点的平均值,学习偏移量。

shoulder_points3D.npy
    2D到3D:固定第一帧中的肩膀点(论文18个?)光流追踪( LK flow)视频其余帧,得到2D肩膀边缘坐标,使用billboard assumption & camera calibration 
    将2D映射到3D,深度取为所得全部3D肩膀数据z轴上的平均值?
    billboard assumption 什么含义(没查到)。

问题:

normalize 并没有做归一化
FN的关键点检测需要改变Index,73-> 68
3D landmarks是3D人脸模型的坐标系统
APC_feature_base.npy is the generated APC features from training audio sequences 
of each person, manifold projection learns a mapping from input audio to the training database.

从这四个函数猜测:
    tgt_image = self.common_dataset_transform(h5中图片的读取并做关于change_paras中的resize,crop,pad操作,以512*512为坐标系), 
    self.get_crop_coords(2D关键点的裁剪系数,以tgt_image为坐标系,512*512),
    self.get_transform(以关键点算出的裁剪参数对关键点和tgt_image做裁剪和缩放self.opt.loadSize=512),
    feature_map = self.get_feature_image 函数得知,肩后做了pad(来自self.image_pad)是对原始图片h5中相对于change_paras的操作。
    猜测:
        h5中保存的是原始2d图,对其做change_paras参数缩放裁剪操作后的2d关键点,保存在'tracked2D_normalized_pts_fix_contour.npy'中。?或者对原图2d检测后做缩放裁剪pad后的图做3D追踪。
        其实,h5保存原始图和对应的关键点,后续对图和对应的关键点同时做增强即可。所以tgt_image = self.common_dataset_transform可以省略。
       另外一层:3D追踪,有自己的对齐处理,512*512,对应有change_paras产生。 后续2D上对原图(h5)做change_paras处理与landmark对齐,然后img+landmark做aug。
    关键问题:
        change_paras.npy咋计算

解答

YuanxunLu commented 2 years ago

You don't need to exactly work as same as what I did. The training-related codes provide clues for your training but you don't have to strictly follow my codes, including how to construct the dataset, functions, training structures, etc.

Check the reference work in the paper if you don't understand any ideas in the proposed work. It is not my duty to solve any questions about prior knowledge needed in the paper, and you can follow the structure of the paper, including the citing work to build the pre-required knowledge.

Researchers who work familiar with the field (audio-visual, 3d facial related) would understand quickly what the proposed method does if they check the papers & codes well, and that is the best effort of mine.

foocker commented 2 years ago

thx, yes, the best way is understand all knowledge and recreate it by myself. at present, i only have a littlle, so awkward. i have completed the all pipline, althought still some problem, it's ok.