MCPcopy Create free account
hub / github.com/MotrixLab/AiOS / main

Function main

util/smplx/examples/demo.py:24–118  ·  view source on GitHub ↗
(model_folder,
         model_type='smplx',
         ext='npz',
         gender='neutral',
         plot_joints=False,
         num_betas=10,
         sample_shape=True,
         sample_expression=True,
         num_expression_coeffs=10,
         plotting_module='pyrender',
         use_face_contour=False)

Source from the content-addressed store, hash-verified

22
23
24def main(model_folder,
25 model_type='smplx',
26 ext='npz',
27 gender='neutral',
28 plot_joints=False,
29 num_betas=10,
30 sample_shape=True,
31 sample_expression=True,
32 num_expression_coeffs=10,
33 plotting_module='pyrender',
34 use_face_contour=False):
35
36 model = smplx.create(model_folder,
37 model_type=model_type,
38 gender=gender,
39 use_face_contour=use_face_contour,
40 num_betas=num_betas,
41 num_expression_coeffs=num_expression_coeffs,
42 ext=ext)
43 print(model)
44
45 betas, expression = None, None
46 if sample_shape:
47 betas = torch.randn([1, model.num_betas], dtype=torch.float32)
48 if sample_expression:
49 expression = torch.randn([1, model.num_expression_coeffs],
50 dtype=torch.float32)
51
52 output = model(betas=betas, expression=expression, return_verts=True)
53 vertices = output.vertices.detach().cpu().numpy().squeeze()
54 joints = output.joints.detach().cpu().numpy().squeeze()
55
56 print('Vertices shape =', vertices.shape)
57 print('Joints shape =', joints.shape)
58
59 if plotting_module == 'pyrender':
60 import pyrender
61 import trimesh
62 vertex_colors = np.ones([vertices.shape[0], 4]) * [0.3, 0.3, 0.3, 0.8]
63 tri_mesh = trimesh.Trimesh(vertices,
64 model.faces,
65 vertex_colors=vertex_colors)
66
67 mesh = pyrender.Mesh.from_trimesh(tri_mesh)
68
69 scene = pyrender.Scene()
70 scene.add(mesh)
71
72 if plot_joints:
73 sm = trimesh.creation.uv_sphere(radius=0.005)
74 sm.visual.vertex_colors = [0.9, 0.1, 0.1, 1.0]
75 tfs = np.tile(np.eye(4), (len(joints), 1, 1))
76 tfs[:, :3, 3] = joints
77 joints_pcl = pyrender.Mesh.from_trimesh(sm, poses=tfs)
78 scene.add(joints_pcl)
79
80 pyrender.Viewer(scene, use_raymond_lighting=True)
81 elif plotting_module == 'matplotlib':

Callers 1

demo.pyFile · 0.70

Calls 4

scatterMethod · 0.80
showMethod · 0.80
printFunction · 0.50
detachMethod · 0.45

Tested by

no test coverage detected