Skip to content

Commit

Permalink
Update new split of AFLW2000-3D && Update rendering demo
Browse files Browse the repository at this point in the history
  • Loading branch information
cleardusk committed Sep 15, 2019
1 parent f30027c commit 0ff8ca4
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,5 @@ utils/cython/build
utils/cython/*.so
utils/cython/mesh_core_cython.cpp
PAF/

samples/*.obj
13 changes: 12 additions & 1 deletion benchmark_aflw2000.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
#!/usr/bin/env python3
# coding: utf-8

"""
Notation (2019.09.15): two versions of spliting AFLW2000-3D:
1) AFLW2000-3D.pose.npy: according to the fitted pose
2) AFLW2000-3D-new.pose: according to AFLW labels
There is no obvious difference between these two splits.
"""

import os.path as osp
import numpy as np
from math import sqrt
from utils.io import _load

d = 'test.configs'

# [1312, 383, 305], current version
yaws_list = _load(osp.join(d, 'AFLW2000-3D.pose.npy'))
# pts21 = _load(osp.join(d, 'AFLW2000-3D.pts21.npy'))

# [1306, 462, 232], same as paper
# yaws_list = _load(osp.join(d, 'AFLW2000-3D-new.pose.npy'))

# origin
pts68_all_ori = _load(osp.join(d, 'AFLW2000-3D.pts68.npy'))
Expand Down
10 changes: 5 additions & 5 deletions demo@obama/rendering.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/usr/bin/env python3
# coding: utf-8

import sys

sys.path.append('../')
import os
import os.path as osp
from glob import glob
import sys

sys.path.append('../')
from utils.lighting import RenderPipeline
import numpy as np
import scipy.io as sio
import imageio
import time

cfg = {
'intensity_ambient': 0.3,
Expand All @@ -31,7 +31,7 @@ def _to_ctype(arr):
return arr


def main():
def obama_demo():
wd = 'obama_res@dense_py'
if not osp.exists(wd):
os.mkdir(wd)
Expand All @@ -55,4 +55,4 @@ def main():


if __name__ == '__main__':
main()
obama_demo()
39 changes: 39 additions & 0 deletions demo@obama/rendering_demo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env python3
# coding: utf-8

"""
A demo for rendering mesh generated by `main.py`
"""

from rendering import cfg, _to_ctype, RenderPipeline
import scipy.io as sio
import imageio
import numpy as np
import matplotlib.pyplot as plt


def test():
# 1. first, using main.py to generate dense vertices, like emma_input_0.mat
fp = '../samples/emma_input_0.mat'
vertices = sio.loadmat(fp)['vertex'].T # 3xm
print(vertices.shape)
img = imageio.imread('../samples/emma_input.jpg').astype(np.float32) / 255.

# 2. render it
# triangles = sio.loadmat('tri_refine.mat')['tri'] # mx3
triangles = sio.loadmat('../visualize/tri.mat')['tri'].T - 1 # mx3
print(triangles.shape)
triangles = _to_ctype(triangles).astype(np.int32) # for type compatible
app = RenderPipeline(**cfg)
img_render = app(vertices, triangles, img)

plt.imshow(img_render)
plt.show()


def main():
test()


if __name__ == '__main__':
main()
Binary file added test.configs/AFLW2000-3D-new.pose.npy
Binary file not shown.

0 comments on commit 0ff8ca4

Please sign in to comment.