Downloads · 30 days
0
py-feat/landmarks68_to_mesh478
landmarks68_to_mesh478 is a machine learning model from py-feat. Use it for the machine learning task on the model card, and read the license before you ship it in a product. It is set up for py-feat. The card lists the license as mit.
Licensing scope: See the license and provenance notice before relying on this card's license metadata for pretrained-weight redistribution or commercial use. Existing valid grants are preserved.
Downloads · 30 days
0
Access
Public
Updated Oct 8, 2026
Repo size
1.8 MB
Likes
0
Public
Click a slice to open those files.
.png1.1 MB · 59%
From the Hugging Face model README
Licensing scope: See the license and provenance notice before relying on this card's license metadata for pretrained-weight redistribution or commercial use. Existing valid grants are preserved.
Cross-topology bridge: lets users running py-feat's default Detector (mobilefacenet 68-pt landmarks) render the rich 478-vertex MediaPipe FaceMesh without running MPDetector.
Linear regression with PCA bottleneck mapping aligned 68-point dlib landmarks (mobilefacenet output of py-feat's Detector) to 478-vertex MediaPipe FaceMesh in pose-canonical (MP-canonical-aligned) space.
In a 3-way comparison on the same train/test split (compare_68_to_478.py):
Detector(face_model="img2pose", landmark_model="mobilefacenet"))MPDetector), GPA-aligned to MP canonical reference (cm units)For reference: AU → 478-pt mesh model achieves R²=0.244. The 68→478 model nearly 2× higher because dlib landmarks share rich spatial information with MP mesh that 20 AU intensities cannot encode.
import numpy as np
m = np.load("landmarks68_to_mesh478_pca_v2.npz")
# 1. User has raw 68-pt landmarks from Detector (image-space pixels), shape (68, 2)
raw = ... # from fex.landmarks_2d (or extract from x_0..x_67, y_0..y_67 columns)
# 2. Procrustes-align raw landmarks to the saved reference (8 stable upper-face anchors)
# See feat.utils.image_operations or save_landmarks68_to_mesh478_pca.py for fit_similarity_batched_2d
anchor_indices = m["anchor_indices_dlib68"] # [27, 28, 29, 30, 36, 39, 42, 45]
ref_anchors = m["reference_dlib_anchors"] # (8, 2) population-mean dlib anchor positions
aligned = procrustes_align_2d(raw, anchor_indices, ref_anchors) # (68, 2)
# 3. Predict 478-pt MP mesh
flat = np.concatenate([aligned[:, 0], aligned[:, 1]]) @ m["coef"] + m["intercept"]
# 4. Unpack to (478, 3) — IMPORTANT: axis-major layout, NOT interleaved
mesh = np.stack([flat[:478], flat[478:956], flat[956:]], axis=1)
Adapts ideas from Cheong et al. 2023 / Py-Feat tutorial 06 (E. Jolly): Cheong's model used PLS for AU → 68 dlib landmarks. Here we extend the linear-regression approach to a cross-topology problem (68 dlib → 478 MP), use PCA-bottleneck for output regularization, and train on 10× more data (~340K wild-celebrity frames).
NPZ with:
Loader: np.load(...) — no extra deps.
The model produces a pose-canonical mesh (frontal, MP head-centric cm coords). To align it with the head pose of the original observed image — or to render it at any user-chosen pose — apply a rigid transform after prediction:
import numpy as np
m = np.load("landmarks68_to_mesh478_pca_v2.npz")
# 1) Predict the canonical mesh as before
flat = aligned_lm @ m["coef"] + m["intercept"]
canonical_mesh = np.stack([flat[:478], flat[478:956], flat[956:]], axis=1) # (478, 3)
# 2) Build a 3x3 rotation matrix R from your pose source. With img2pose
# Pitch/Yaw/Roll (radians) returned by py-feat's Detector:
from scipy.spatial.transform import Rotation
R = Rotation.from_euler("xyz", [pitch, yaw, roll]).as_matrix() # (3, 3)
# 3) (Optional) scale s and translation t:
posed_mesh = canonical_mesh @ R.T # (478, 3)
# posed_mesh = s * (canonical_mesh @ R.T) + t # if you want re-projection
# Or, if you have MP's full 4x4 facial_transformation_matrix (M):
# homog = np.concatenate([canonical_mesh, np.ones((478, 1))], axis=1)
# posed = (homog @ M.T)[:, :3]
Convention notes:
Rotation.from_euler("xyz", ...) is intrinsic xyz (R = Rx·Ry·Rz) — the most
common convention. For img2pose Pitch/Yaw/Roll, this matches.

This distribution retains its existing license: mit metadata. This PCA/regression mapping was fit on CelebV-HQ frames with MobileFaceNet 68-point landmarks and MediaPipe mesh targets, with img2pose used in the source pipeline as described above.
Review the CelebV-HQ agreement, the unresolved landmark-checkpoint grant from cunjian/pytorch_face_landmark, and the exact MediaPipe/img2pose asset terms separately from Py-Feat's MIT implementation. The img2pose upstream license is CC BY-NC 4.0. Neither geometry conversion nor fitting PCA/regression coefficients supplies additional upstream rights. See the component notice.
This notice clarifies scope; it does not revoke existing valid grants or create a new license for third-party material. Dataset and teacher terms do not automatically relicense every trained artifact or inference output. A software license or model-card badge alone does not establish all checkpoint redistribution or commercial-use permissions.