Skip to content

Commit 8de3653

Browse files
authored
Update palm detection model from MediaPipe (2023feb) (#128)
* update to the latest palm detection model * quantize palm detection model * make palm aligned to center when resize * update benchmark for palm detection * update benchmark data * update readme * update a new quantized model * update readme
1 parent d2b302a commit 8de3653

15 files changed

+2078
-3033
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Guidelines:
3434
| [WeChatQRCode](./models/qrcode_wechatqrcode) | QR Code Detection and Parsing | 100x100 | 7.04 | 37.68 | --- | --- | --- |
3535
| [DaSiamRPN](./models/object_tracking_dasiamrpn) | Object Tracking | 1280x720 | 36.15 | 705.48 | 76.82 | --- | --- |
3636
| [YoutuReID](./models/person_reid_youtureid) | Person Re-Identification | 128x256 | 35.81 | 521.98 | 90.07 | 44.61 | --- |
37-
| [MP-PalmDet](./models/palm_detection_mediapipe) | Palm Detection | 256x256 | 15.57 | 168.37 | 50.64 | 62.45 | --- |
37+
| [MP-PalmDet](./models/palm_detection_mediapipe) | Palm Detection | 192x192 | 11.09 | 63.79 | 83.20 | 33.81 | --- |
3838
| [MP-HandPose](./models/handpose_estimation_mediapipe) | Hand Pose Estimation | 256x256 | 20.16 | 148.24 | 156.30 | 42.70 | --- |
3939

4040
\*: Models are quantized in per-channel mode, which run slower than per-tensor quantized models on NPU.

benchmark/config/palm_detection_mediapipe.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Benchmark:
55
path: "data/palm_detection_20230125"
66
files: ["palm1.jpg", "palm2.jpg", "palm3.jpg"]
77
sizes: # [[w1, h1], ...], Omit to run at original scale
8-
- [256, 256]
8+
- [192, 192]
99
metric:
1010
warmup: 30
1111
repeat: 10

models/handpose_estimation_mediapipe/demo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def visualize(image, hands, print_result=False):
9191

9292
if __name__ == '__main__':
9393
# palm detector
94-
palm_detector = MPPalmDet(modelPath='../palm_detection_mediapipe/palm_detection_mediapipe_2022may.onnx',
94+
palm_detector = MPPalmDet(modelPath='../palm_detection_mediapipe/palm_detection_mediapipe_2023feb.onnx',
9595
nmsThreshold=0.3,
9696
scoreThreshold=0.8,
9797
backendId=args.backend,

models/palm_detection_mediapipe/README.md

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# Palm detector from MediaPipe Handpose
22

3-
This model detects palm bounding boxes and palm landmarks, and is converted from Tensorflow-JS to ONNX using following tools:
3+
This model detects palm bounding boxes and palm landmarks, and is converted from TFLite to ONNX using following tools:
44

5-
- tfjs to tf_saved_model: https://github.com/patlevin/tfjs-to-tf/
6-
- tf_saved_model to ONNX: https://github.com/onnx/tensorflow-onnx
5+
- TFLite model to ONNX: https://github.com/onnx/tensorflow-onnx
76
- simplified by [onnx-simplifier](https://github.com/daquexian/onnx-simplifier)
7+
- SSD Anchors are generated from [GenMediaPipePalmDectionSSDAnchors](https://github.com/VimalMollyn/GenMediaPipePalmDectionSSDAnchors)
8+
89

910
## Demo
1011

@@ -31,3 +32,5 @@ All files in this directory are licensed under [Apache 2.0 License](./LICENSE).
3132
## Reference
3233

3334
- MediaPipe Handpose: https://github.com/tensorflow/tfjs-models/tree/master/handpose
35+
- MediaPipe hands model and model card: https://google.github.io/mediapipe/solutions/models.html#hands
36+
- Int8 model quantized with rgb evaluation set of FreiHAND: https://lmb.informatik.uni-freiburg.de/resources/datasets/FreihandDataset.en.html

models/palm_detection_mediapipe/demo.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ def str2bool(v):
2727

2828
parser = argparse.ArgumentParser(description='Hand Detector from MediaPipe')
2929
parser.add_argument('--input', '-i', type=str, help='Usage: Set path to the input image. Omit for using default camera.')
30-
parser.add_argument('--model', '-m', type=str, default='./palm_detection_mediapipe_2022may.onnx', help='Usage: Set model path, defaults to palm_detection_mediapipe_2022may.onnx.')
30+
parser.add_argument('--model', '-m', type=str, default='./palm_detection_mediapipe_2023feb.onnx', help='Usage: Set model path, defaults to palm_detection_mediapipe_2023feb.onnx.')
3131
parser.add_argument('--backend', '-b', type=int, default=backends[0], help=help_msg_backends.format(*backends))
3232
parser.add_argument('--target', '-t', type=int, default=targets[0], help=help_msg_targets.format(*targets))
33-
parser.add_argument('--score_threshold', type=float, default=0.99, help='Usage: Set the minimum needed confidence for the model to identify a palm, defaults to 0.99. Smaller values may result in faster detection, but will limit accuracy. Filter out faces of confidence < conf_threshold. An empirical score threshold for the quantized model is 0.49.')
33+
parser.add_argument('--score_threshold', type=float, default=0.8, help='Usage: Set the minimum needed confidence for the model to identify a palm, defaults to 0.8. Smaller values may result in faster detection, but will limit accuracy. Filter out faces of confidence < conf_threshold. An empirical score threshold for the quantized model is 0.49.')
3434
parser.add_argument('--nms_threshold', type=float, default=0.3, help='Usage: Suppress bounding boxes of iou >= nms_threshold. Default = 0.3.')
3535
parser.add_argument('--save', '-s', type=str, default=False, help='Usage: Set “True” to save file with results (i.e. bounding box, confidence level). Invalid in case of camera input. Default will be set to “False”.')
3636
parser.add_argument('--vis', '-v', type=str2bool, default=True, help='Usage: Default will be set to “True” and will open a new window to show results. Set to “False” to stop visualizations from being shown. Invalid in case of camera input.')

0 commit comments

Comments
 (0)