Update README.md
Browse files
README.md
CHANGED
|
@@ -1,3 +1,65 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
# MP_FaceMesh_V2
|
| 10 |
+
|
| 11 |
+
## Model Description
|
| 12 |
+
MP_FaceMesh_V2 is a pytorch port of tensorfolow [FaceMeshV2](https://ai.google.dev/edge/mediapipe/solutions/vision/face_landmarker/index) model from Google's [mediapipe](https://github.com/google-ai-edge/mediapipe) library.
|
| 13 |
+
The model takes a cropped 2D face with 25% margin on each side resized to 256 x 256 pixels and outputs a dense 473 landmark coordinates in a 3D (x,y,z) coordinate space.
|
| 14 |
+
|
| 15 |
+
The original tensorflow model was ported to ONNX and then to pytorch using [onnx2torch](https://github.com/ENOT-AutoDL/onnx2torch). Currently, we are serializing the converted model, which requires onnx2torch as a dependency.
|
| 16 |
+
|
| 17 |
+
See the mediapipe [model card](https://storage.googleapis.com/mediapipe-assets/Model%20Card%20Blendshape%20V2.pdf) for more details.
|
| 18 |
+
|
| 19 |
+
## Model Details
|
| 20 |
+
- **Model Type**: Convolutional Neural Network (MobileNetV2-like)
|
| 21 |
+
- **Framework**: pytorch
|
| 22 |
+
|
| 23 |
+
## Model Sources
|
| 24 |
+
- **Repository**: [GitHub Repository](https://github.com/cosanlab/py-feat)
|
| 25 |
+
- **Model Card**: [Attention Mesh: High-fidelity Face Mesh Prediction in Real-time](https://storage.googleapis.com/mediapipe-assets/Model%20Card%20MediaPipe%20Face%20Mesh%20V2.pdf)
|
| 26 |
+
- **Paper**: [Mediapipe FaceMesh model card](https://arxiv.org/abs/2006.10962)
|
| 27 |
+
## Citation
|
| 28 |
+
If you use the mp_facemesh_v2 model in your research or application, please cite the following paper:
|
| 29 |
+
|
| 30 |
+
Grishchenko, I., Ablavatski, A., Kartynnik, Y., Raveendran, K., & Grundmann, M. (2020). Attention mesh: High-fidelity face mesh prediction in real-time. arXiv preprint arXiv:2006.10962.
|
| 31 |
+
|
| 32 |
+
```
|
| 33 |
+
@misc{grishchenko2020attentionmeshhighfidelityface,
|
| 34 |
+
title={Attention Mesh: High-fidelity Face Mesh Prediction in Real-time},
|
| 35 |
+
author={Ivan Grishchenko and Artsiom Ablavatski and Yury Kartynnik and Karthik Raveendran and Matthias Grundmann},
|
| 36 |
+
year={2020},
|
| 37 |
+
eprint={2006.10962},
|
| 38 |
+
archivePrefix={arXiv},
|
| 39 |
+
primaryClass={cs.CV},
|
| 40 |
+
url={https://arxiv.org/abs/2006.10962},
|
| 41 |
+
}
|
| 42 |
+
```
|
| 43 |
+
|
| 44 |
+
## Example Useage
|
| 45 |
+
|
| 46 |
+
```python
|
| 47 |
+
import torch
|
| 48 |
+
from huggingface_hub import hf_hub_download
|
| 49 |
+
|
| 50 |
+
device = 'cpu'
|
| 51 |
+
|
| 52 |
+
# Load model and weights
|
| 53 |
+
landmark_model_file = hf_hub_download(repo_id='py-feat/mp_facemesh_v2', filename="face_landmarks_detector_Nx3x256x256_onnx.pth")
|
| 54 |
+
landmark_detector = torch.load(landmark_model_file, map_location=device, weights_only=False)
|
| 55 |
+
landmark_detector.eval()
|
| 56 |
+
landmark_detector.to(device)
|
| 57 |
+
|
| 58 |
+
|
| 59 |
+
# Test model
|
| 60 |
+
face_image = "path/to/your/test_image.jpg" # Replace with your extracted face image that is [224, 224]
|
| 61 |
+
|
| 62 |
+
# Extract Landmarks
|
| 63 |
+
landmark_results = landmark_detector(torch.tensor(face_image).to(device))
|
| 64 |
+
|
| 65 |
+
```
|