Add MediaPipe Hand detector and landmark Core ML packages
Browse files- README.md +92 -0
- coreml/hand_detector.mlpackage/Data/com.apple.CoreML/model.mlmodel +3 -0
- coreml/hand_detector.mlpackage/Data/com.apple.CoreML/weights/weight.bin +3 -0
- coreml/hand_detector.mlpackage/Manifest.json +18 -0
- coreml/hand_landmark_detector.mlpackage/Data/com.apple.CoreML/model.mlmodel +3 -0
- coreml/hand_landmark_detector.mlpackage/Data/com.apple.CoreML/weights/weight.bin +3 -0
- coreml/hand_landmark_detector.mlpackage/Manifest.json +18 -0
- mediapipe-hand-coreml.tar +3 -0
README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: mediapipe-pytorch-license
|
| 4 |
+
license_link: https://github.com/zmurez/MediaPipePyTorch/blob/master/LICENSE
|
| 5 |
+
library_name: coremltools
|
| 6 |
+
pipeline_tag: object-detection
|
| 7 |
+
base_model: qualcomm/MediaPipe-Hand-Detection
|
| 8 |
+
tags:
|
| 9 |
+
- coreml
|
| 10 |
+
- apple-silicon
|
| 11 |
+
- mediapipe
|
| 12 |
+
- hand-detection
|
| 13 |
+
- hand-landmarks
|
| 14 |
+
- gesture-control
|
| 15 |
+
- macos
|
| 16 |
+
---
|
| 17 |
+
|
| 18 |
+
# MediaPipe Hand Detection & Landmarks — Core ML
|
| 19 |
+
|
| 20 |
+
A ready-to-use two-model Core ML pipeline for real-time hand tracking on Apple Silicon, converted from Qualcomm AI Hub's MediaPipe Hand ONNX release.
|
| 21 |
+
|
| 22 |
+
The bundle contains both models required by the pipeline:
|
| 23 |
+
|
| 24 |
+
1. **Palm detector** — finds hands and seven detector keypoints.
|
| 25 |
+
2. **Hand landmark detector** — predicts presence, handedness, and 21 three-dimensional landmarks from each detected hand crop.
|
| 26 |
+
|
| 27 |
+
Together they enable gesture-controlled apps, games, plugins, and agents. Gesture recognition itself is implemented by interpreting the 21 landmarks; these models do not contain a separate gesture classifier. See [Hugging Mac](https://github.com/devilyouwei/hugging-mac) for the complete local macOS pipeline.
|
| 28 |
+
|
| 29 |
+
## Model details
|
| 30 |
+
|
| 31 |
+
| Component | Input | Outputs | Parameters |
|
| 32 |
+
|---|---|---|---:|
|
| 33 |
+
| `hand_detector.mlpackage` | `image`: `1 × 3 × 256 × 256` FP32 RGB | `box_coords`: `1 × 2944 × 18`; `box_scores`: `1 × 2944 × 1` | 1.76M |
|
| 34 |
+
| `hand_landmark_detector.mlpackage` | `image`: `1 × 3 × 256 × 256` FP32 RGB crop | `scores`: `1`; `lr`: `1`; `landmarks`: `1 × 21 × 3` | 2.01M |
|
| 35 |
+
|
| 36 |
+
- Precision: FP32
|
| 37 |
+
- Core ML deployment target: macOS 13 or later
|
| 38 |
+
- Combined package size: 15.3 MB
|
| 39 |
+
- The landmark model can be loaded lazily only when landmarks are requested.
|
| 40 |
+
|
| 41 |
+
## Core ML example
|
| 42 |
+
|
| 43 |
+
```python
|
| 44 |
+
from pathlib import Path
|
| 45 |
+
|
| 46 |
+
import coremltools as ct
|
| 47 |
+
import numpy as np
|
| 48 |
+
from huggingface_hub import snapshot_download
|
| 49 |
+
from PIL import Image, ImageOps
|
| 50 |
+
|
| 51 |
+
root = Path(snapshot_download(
|
| 52 |
+
repo_id="hugging-mac/mediapipe-hand-coreml",
|
| 53 |
+
allow_patterns=["coreml/**"],
|
| 54 |
+
)) / "coreml"
|
| 55 |
+
|
| 56 |
+
detector = ct.models.MLModel(
|
| 57 |
+
root / "hand_detector.mlpackage",
|
| 58 |
+
compute_units=ct.ComputeUnit.ALL,
|
| 59 |
+
)
|
| 60 |
+
image = ImageOps.pad(Image.open("hand.jpg").convert("RGB"), (256, 256))
|
| 61 |
+
value = np.asarray(image, dtype=np.float32) / 255.0
|
| 62 |
+
tensor = np.ascontiguousarray(value.transpose(2, 0, 1))[None]
|
| 63 |
+
outputs = detector.predict({"image": tensor})
|
| 64 |
+
|
| 65 |
+
print(outputs["box_coords"].shape) # (1, 2944, 18)
|
| 66 |
+
print(outputs["box_scores"].shape) # (1, 2944, 1)
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
Raw detector outputs require MediaPipe anchor decoding and weighted NMS. The resulting rotated hand crop is passed to the landmark model. Use the [Hugging Mac MediaPipe Hand SDK](https://github.com/devilyouwei/hugging-mac/tree/main/packages/hugging_mac_sdk/src/hugging_mac_sdk/models/mediapipe_hand_detection) for the complete pipeline, coordinate projection, and handedness handling.
|
| 70 |
+
|
| 71 |
+
## Conversion verification
|
| 72 |
+
|
| 73 |
+
The Core ML models were compared with ONNX Runtime on identical random inputs. Maximum absolute differences:
|
| 74 |
+
|
| 75 |
+
- Detector boxes: `6.866e-5`
|
| 76 |
+
- Detector scores: `1.526e-4`
|
| 77 |
+
- Hand presence: `3.92e-8`
|
| 78 |
+
- Handedness: `4.59e-6`
|
| 79 |
+
- Landmarks: `4.47e-7`
|
| 80 |
+
|
| 81 |
+
## Provenance and integrity
|
| 82 |
+
|
| 83 |
+
- Upstream: [Qualcomm MediaPipe Hand Detection](https://huggingface.co/qualcomm/MediaPipe-Hand-Detection)
|
| 84 |
+
- Upstream revision: `013e27b599e37c3b4c69439de15de53cc5b5708e`
|
| 85 |
+
- Qualcomm AI Hub release: `v0.60.0`, ONNX float
|
| 86 |
+
- `hand_detector.mlpackage` SHA-256: `a81143ef0bfa896d4206caf226697141ab8c052d57ba5e95fc7c7ac2660dc83d`
|
| 87 |
+
- `hand_landmark_detector.mlpackage` SHA-256: `d4049538d8fe4b4ffa77f71e1efa43705fc010e721c0456a95d9c97453c13716`
|
| 88 |
+
- Complete bundle SHA-256: `5432c988be7ed2fd6847097f823e0d813f97be7dc7a7d6587129386dbcd75929`
|
| 89 |
+
|
| 90 |
+
## License
|
| 91 |
+
|
| 92 |
+
The upstream repository declares a custom license and links to the MediaPipePyTorch license, which states that the implementation follows the Apache License 2.0 terms used by MediaPipe. Review the upstream Qualcomm distribution terms and linked source license before redistribution or commercial use. Hugging Mac is not affiliated with or endorsed by Qualcomm, Google, or MediaPipe.
|
coreml/hand_detector.mlpackage/Data/com.apple.CoreML/model.mlmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:de163c1bee3e5845eca334483b77d63adda4539fc35190c5b9146a6f3bb73cff
|
| 3 |
+
size 130040
|
coreml/hand_detector.mlpackage/Data/com.apple.CoreML/weights/weight.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:94ae575261d4d6d47829b38d5167e3ca29e15fd85e14434adbf629e49066809b
|
| 3 |
+
size 7038336
|
coreml/hand_detector.mlpackage/Manifest.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"fileFormatVersion": "1.0.0",
|
| 3 |
+
"itemInfoEntries": {
|
| 4 |
+
"11300D9C-7B69-44DA-BE56-E880BAA4E2AF": {
|
| 5 |
+
"author": "com.apple.CoreML",
|
| 6 |
+
"description": "CoreML Model Weights",
|
| 7 |
+
"name": "weights",
|
| 8 |
+
"path": "com.apple.CoreML/weights"
|
| 9 |
+
},
|
| 10 |
+
"D5A6C0DB-5D82-4498-BBC8-F42D3AD0A070": {
|
| 11 |
+
"author": "com.apple.CoreML",
|
| 12 |
+
"description": "CoreML Model Specification",
|
| 13 |
+
"name": "model.mlmodel",
|
| 14 |
+
"path": "com.apple.CoreML/model.mlmodel"
|
| 15 |
+
}
|
| 16 |
+
},
|
| 17 |
+
"rootModelIdentifier": "D5A6C0DB-5D82-4498-BBC8-F42D3AD0A070"
|
| 18 |
+
}
|
coreml/hand_landmark_detector.mlpackage/Data/com.apple.CoreML/model.mlmodel
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0897d8c4085735b89a3aabada2e4ae73c9a04968f6d1fc30b8789f389af5f6ca
|
| 3 |
+
size 135488
|
coreml/hand_landmark_detector.mlpackage/Data/com.apple.CoreML/weights/weight.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d3b0a59b2cd25b3d8431a49282159f831acb5b749de0eec7542d50bcf85c909a
|
| 3 |
+
size 8035776
|
coreml/hand_landmark_detector.mlpackage/Manifest.json
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"fileFormatVersion": "1.0.0",
|
| 3 |
+
"itemInfoEntries": {
|
| 4 |
+
"92AA890C-BF1E-406F-99AD-CEBD001476F3": {
|
| 5 |
+
"author": "com.apple.CoreML",
|
| 6 |
+
"description": "CoreML Model Weights",
|
| 7 |
+
"name": "weights",
|
| 8 |
+
"path": "com.apple.CoreML/weights"
|
| 9 |
+
},
|
| 10 |
+
"CAE6CE42-BE83-49AC-AD79-CA03D33F641B": {
|
| 11 |
+
"author": "com.apple.CoreML",
|
| 12 |
+
"description": "CoreML Model Specification",
|
| 13 |
+
"name": "model.mlmodel",
|
| 14 |
+
"path": "com.apple.CoreML/model.mlmodel"
|
| 15 |
+
}
|
| 16 |
+
},
|
| 17 |
+
"rootModelIdentifier": "CAE6CE42-BE83-49AC-AD79-CA03D33F641B"
|
| 18 |
+
}
|
mediapipe-hand-coreml.tar
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:b80701c800ee166ef609e38d10761e3ac958a9637e41f8a6c961ebab098882e7
|
| 3 |
+
size 15350784
|