Upload app.py
Browse files
app.py
CHANGED
|
@@ -430,9 +430,14 @@ def demo_lam(flametracking, lam, cfg):
|
|
| 430 |
template_vertices = flame_model.v_template.unsqueeze(0).expand(batch_size, -1, -1)
|
| 431 |
shapedirs = flame_model.shapedirs
|
| 432 |
|
| 433 |
-
# shape blend
|
| 434 |
n_shape_params = flame_model.n_shape_params if hasattr(flame_model, 'n_shape_params') else 10
|
| 435 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 436 |
|
| 437 |
# mesh 저장
|
| 438 |
mesh = trimesh.Trimesh(vertices=v_shaped.squeeze(0).cpu().numpy(), faces=faces)
|
|
|
|
| 430 |
template_vertices = flame_model.v_template.unsqueeze(0).expand(batch_size, -1, -1)
|
| 431 |
shapedirs = flame_model.shapedirs
|
| 432 |
|
| 433 |
+
# shape blend (shape_param이 1차원인 경우 2차원으로 변환)
|
| 434 |
n_shape_params = flame_model.n_shape_params if hasattr(flame_model, 'n_shape_params') else 10
|
| 435 |
+
# shape_param을 올바른 차원으로 변환
|
| 436 |
+
if shape_param.dim() == 1:
|
| 437 |
+
shape_param_2d = shape_param.unsqueeze(0) # (num_betas) -> (1, num_betas)
|
| 438 |
+
else:
|
| 439 |
+
shape_param_2d = shape_param
|
| 440 |
+
v_shaped = template_vertices + blend_shapes(shape_param_2d, shapedirs[:, :, :n_shape_params])
|
| 441 |
|
| 442 |
# mesh 저장
|
| 443 |
mesh = trimesh.Trimesh(vertices=v_shaped.squeeze(0).cpu().numpy(), faces=faces)
|