The Beautiful Future

Attention Mesh: High-fidelity Face Mesh Prediction in Real-time 본문

논문

Attention Mesh: High-fidelity Face Mesh Prediction in Real-time

Small Octopus 2022. 12. 28. 11:11

Grishchenko, I., Ablavatski, A., Kartynnik, Y., Raveendran, K., Grundmann, M.: Attention Mesh: High-fidelity Face Mesh Prediction in Real-time. In: CVPR Workshops (2020)

Google Research

50 FPS on a Pixel2 phone.

puppeteering 인형극

기여한점: 30% 속도향상을 가져오면서 multi-stage cascade approach와 같은 성능

3D 얼굴모델을 사용하지 않고 다이레트로 좌표를 예측.

[5] 연구에 기반을 두고 있음.  얼굴 검출 후 리그레션하는 두 단계 구조.
[5] Real-time Facial Surface Geometry from Monocular Video on Mobile GPUs, 2019.
하지만 얼굴 전체를 리그레션하면 인지적으로 중요한 얼굴 파트에서 품질저하가 있다.
그래서 얼굴파트단위 크롬해서 각 특화된 네트워크로 추론.
하지만 이렇게 여러개의 모델을 각 이미지 인풋으로 학습 및 사용하는 것은 비효율적이다. feature level 공유 시간절약
그리고 이렇게 여러모델을 사용하면 모델간 데이터 전달을 위해 CPU, GPU간 동기화가 필요하게되고 이것도 코스트다.

region-specific heads는   spatial transformers[4] 사용하여 feature maps을 트랜스폼한다.
[4] Spatial transformer networks. NIPS 2015.
이 방식으로 cascaded approach와 비교하여 하나의 모델로 같은 성능의 속도향상을 보인다.
이 구조를 attention mesh로 명명한다.
추가적으로 분리된 모델들과 비교하여 내부적으로 일관성있게 연결되어 있어 학습하기 편하다는 장점이다.

[7]과 비슷한 모델구조를 사용했다.
A deep regression architecture with two-stage re-initialization for high
performance facial landmark detection. CVPR 2017.
[7]은 spatial transformers를 사용 다양한 얼굴 검출기에서 제공된 초기값에 신뢰성있게 네트워 구축.
이 논문과 [7]의 목적이 다르지만 하나의 모델로 salient face regions이 성능향상을 보인다. 

검출 또는 트랙킹된 256x256 얼굴 이미지 입력 , 64x64x32 얼굴 feature map 출력
feature map 은 왼눈, 오눈, 입, 얼굴 전체 총 네개의 브렌치로 나눠져 인퍼런스됨.
얼굴 전체는 64x64x32 feature 전체를 받아서 인퍼런스 나머지는 24x24x32 크기로 크롬된 feature map
으로 부터 인퍼런스한다.
얼굴 전체 모듈은
478개의 3D landmark를 예측하고 각 서브모듈의 ROI을 정의한다.
나머지 눈/입 모듈은 어텐션 메커리즘으로 구해진 24x24xx32 feature map에서 예측한다.
눈 모듈은 feature map이 6x6 까지 줄어든 이후에 동공을 별도로 예측한다. 이것은 눈의 feature를
재사용하게해주며 고정적인 눈 랜드마크에서 보다 동공 랜드마크를 동적이게 해준다.

각 서브모듈은 네크웍의 용량이 각 얼굴 부위에 헌신하게 해주며 품질을 높인다.
보다 높은 품질향상을 위해, 눈과 입을 수평으로 정렬하고 일정 크기로 정규화했다.
attention mesh network을 두가지 절차로 학습했다.
1. 각 서브모듈을 GT landmark 좌표 기준으로 독립적으로 학습했다.
2. 모델 자체에서 구해진 landmark 좌표 기준으로 서브모듈들을 재학습했다.

Attention mechanism
[2] Draw: A recurrent neural network for image generation, 2015.
[4] Spatial transformer networks. NIPS 2015.
위 어텐션 기법들은 feature space에서 grid of 2D points들을 뽑아낸다.
그리고 미분가능하게 feature를 뽑아낸다. 2D gaussian kernel 또는 affine transformation interpolation을
통해서. 이 방법은 네트워크를 E2E로 학습가능하게 하며 attention mechanism에 의해 사용된 feature가 
풍부해지게 한다. 우리는 [4]의 transformer module을 사용하였다.
affine transform으로 정의되서 sampled grid of points를 zoom, rotate, translate, skew할 수 있다.
이 affine transform는 supervised로 구축 수도 있고 face mesh submodel의 출력으로부터 계산되어질수도 있다.

3만장의 이미지에 2D 랜드마크를 직접 어노테이션했고, synthetic model을 이용해서 z값을 근사화했다.

평가를 위해, 얼굴 파트 단위로 학습된 모델과 비교하였다. 기본 메쉬, 눈, 입 순차적으로 동작된다(cascade).

Performance (속도 비교)

attention mesh model이 cascade of seperate face and region model보다 25% 빠르다. 
[6]  On-device neural net inference with mobile gpus. 2019.
을 사용하여 TFLite GPU 속도를 측정하였다. 
각 region model: 8.82+4.18+4.7 = 17.7 ms 에 CPU-GPU sync에 소비되는시간 4.7 ms을 추가해야한다.

Mesh quality
3D interocular distance로 오차 정규화함.
attention mesh model이 cascade of model을 눈 영역은 능가했고 입 영역은 상응하는 수준임을 보인다.

AR Makeup
잘못된 landmark위치는 uncanny vally 에 쉽게 빠지게한다.
base mesh와 attention mesh with submoduel을 비교.
80명 대상으로 A/B test를 10개의 이미지에 했고 46%의 AR samples이 실제 립스틱 바른 이미지로
분류되었고 38%dml 실제 이미지가 AR로 분류되었다.

Puppeteering(퍼피티어링, 인형극)
인형극 또는 trigger로 사용될 수도 있다.
[3] Dual laplacian morphing for triangular meshes. Computer Animation and Virtual Worlds 2007.
Laplacian mesh editing to morph a canonical mesh into the predicted mesh.

결론
리얼타입 통합 정확한 face mesh predection.
differentiable attention mechanism. 
독립적 지역 특화 모델 돌리는 대신 salient face region 마다 연산가능하게 했다.

StackOverflow

Q.
How to convert Mediapipe Face Mesh to Blendshape weight (https://stackoverflow.com/questions/68169684/how-to-convert-mediapipe-face-mesh-to-blendshape-weight)

A1.
(두가지 방향성이 있다.)
Blendshape generation can be divided into two methods:

(landmark로 부터 바로 구하는 방법)
Direct math from mesh landmarks:

  1. kalidokit, https://github.com/yeemachine/kalidokit
  2. Mefamo, https://github.com/JimWest/MeFaMo

(network을 사용하는 방법)
AI model:

  1. mocap4face, https://github.com/facemoji/mocap4face
  2. AvatarWebKit, https://github.com/Hallway-Inc/AvatarWebKit

(데이터 페어를 만들어라.)
With the rapid development of supervised learning, collecting face and 52-bs paired datasets seems the best way to solve this problem.

==== update 2022.11.21 =====

NVIDIA has released maxine-ar-sdk to compute face blendshapes. The predicted blendshpaes are slightly different from Arkit 52. I have successfully compiled it and run it well on windows with RTX-20 or RTX-30 cards.

If anyone really needs one mediapipe-based solution, just comments. I can contribute to label CC face datasets for fine-tuning your own models with NMAXINE-AR-SDK.


A2.
My approach: First sample many pairs of random blendshapes -> face mesh (detecting face mesh on 3D model), and then learning an inverse model from that. (A simple neuronet would do)

Therefore you end up with a model that can give blendshapes given a face mesh.

The catch, which is also mentioned in the above blurb, is that you wanna handle different face mesh inputs. In the above blurb it seems that they sample the 3D model but transform the sampled mesh into the canonical face mesh, and hence end up with a canonical inverse model. At inference you transform a given mesh into the canonical face mesh as well.

Another solution might be to directly transform your different people's face meshes into the 3D model's mesh.

Comments