Skip to content

Repository files navigation

Overview

Python demonstration code for mediapipe models (blazepalm/hand, blazeface, blazepose).

Instructions

Perform the following steps to execute on your platform, using tflite as example.

Replace "tflite" with other targets when applicable.

  1. Clone repository

    $ git clone https://github.com/AlbertaBeef/blaze_app_python

    $ cd blaze_app_python

  2. Select target

    $ cd tflite

  3. Download models

    $ cd models

    $ source ./get_tflite_models.sh

    $ cd ..

  4. Launch Application

    For hand landmarks :

    $ python3 blaze_detect_live.py --blaze hand

    Replace "hand" with "face" for face landmarks, or "pose" for body landmarks.

Launch Arguments

-Argument--ArgumentDescription
-h--helpshow this help message and exit
-i--inputVideo input device. Default is auto-detect (first usbcam)
-I--testimageUse test image as input (womand_hands.jpg). Default is usbcam
-b--blazeCommand seperated list of applications (hand, face, pose). Default is 'hand, face, pose'
-t--targetCommand seperated list of targets (blaze_tflite, blaze_pytorch, blaze_vitisai). Default is 'blaze_tflite,blaze_pytorch,blaze_vitisai,blaze_hailo'
-p--pipelineCommand seperated list of pipelines (Use --list to get list of targets). Default is 'all'
-l--listList pipelines
-d--debugEnable Debug Mode. Default is off
-w--withoutviewDisable Output Viewing. Default is on
-z--profilelogEnable Profile Log Mode. Default is off
-Z--profileviewEnable Profile View Mode. Default is off
-f--fpsEnable FPS Display. Default is off

Run-Time Options

KeyDescription
ppause video ...
ccontinue ...
sstep one frame at a time ...
wtake a photo ...
ttoggle between test image and live video
htoggle horizontal mirror on input
atoggle detection overlay on/off
btoggle roi overlay on/off
ltoggle landmarks overlay on/off
dtoggle debug image on/off
etoggle scores image on/off
ftoggle FPS display on/off
vtoggle verbose on/off
ztoggle profile log on/off
ytoggle profile view on/off

Supported Frameworks

The blaze_app_python demo provides a common code base for comparing models inferenced from the following frameworks:

Supported Models

The following specific models are supported.

TFLite models

Detection Models

VersionModelInput SizeScoresBoxesCommentsSourceModel Link
v0.07Palm256*25629442944x18BBox + 7 keypointsmetalwhale/hand_trackingpalm_detection_without_custom_op.tflite
v0.10Palm (Lite)192*19220162016x18BBox + 7 keypointsgoogle/mediapipepalm_detection_full.tflite
v0.10Palm (Full)192*19220162016x18BBox + 7 keypointsgoogle/mediapipepalm_detection_full.tflite
v0.07Face (Front Camera)256*256896896x16BBox + 6 keypointsgoogle/mediapipe/v0.7.11face_detection_front.tflite
v0.07Face (Back Camera)256*256896896x16BBox + 6 keypointsgoogle/mediapipe/v0.7.11face_detection_back.tflite
v0.10Face (Short Range)128*128896896x16BBox + 6 keypointsgoogle/mediapipeface_detection_short_range.tflite
v0.10Face (Full Range)128*128896896x16BBox + 6 keypointsmgoogle/mediapipeface_detection_full_range.tflite
v0.10Face (Full Range Sparse)128*128896896x16BBox + 6 keypointsgoogle/mediapipeface_detection_full_range_sparse.tflite
v0.07Pose128*128896896x12BBox + 4 keypointspose_detection_v0_07.tflite](https://avtinc.sharepoint.com/:u:/t/ET-Downloads/EQ_OekMvLOhKtg8423P_NhMBdG3L8dbZdEqrDN5ZeHRYHw?e=2m6jMm)
v0.10Pose224*22422542254x12BBox + 4 keypointsgoogle/mediapipepose_detection.tflite

Landmarks Models

VersionModelInput SizeFlagLandmarksCommentsSourceModel Link
v0.07Hand256*256121x321 keypoints (x,y,score)google/mediapipe/v0.7.11hand_landmark.tflite
v0.10Hand (Lite)224*22412016x1821 keypoints (x,y,score)google/mediapipehand_landmark_lite.tflite
v0.10Hand (Full)224*22412016x1821 keypoints (x,y,score)google/mediapipehand_landmark_full.tflite
v0.07Face256*2561896x16468 keypoints (x,y,score)google/mediapipe/v0.7.11face_landmark.tflite
v0.10Face192*1921896x16468 keypoints (x,y,score)google/mediapipeface_landmark.tflite
v0.10Pose (Full Body, Lite)256*256139x539 keypoints (x,y,z,visibility,presence)google/mediapipepose_landmark_lite.tflite
v0.07Pose (Upper Body)256*256139x531 keypoints (x,y,z,visibility,presence)pose_landmark_v0_07_upper_body.tflite
v0.10Pose (Full Body, Full)256*256139x539 keypoints (x,y,z,visibility,presence)google/mediapipepose_landmark_full.tflite
v0.10Pose (Full Body, Heavy)256*256139x539 keypoints (x,y,z,visibility,presence)google/mediapipepose_landmark_heavy.tflite
PyTorch models

Detection Models

VersionTypeInput SizeScoresBoxesCommentsSourceModel Link
v0.07Palm256*25629442944x18BBox + 7 keypointszmurez/MediaPipePytorchblazepalm.pth
v0.07Face (Front Camera)128*128896896x16BBox + 6 keypointszmurez/MediaPipePytorchblazeface.pth
v0.07Face (Back Camera)256*256896896x16BBox + 6 keypointszmurez/MediaPipePytorchblazefaceback.pth
v0.07Pose128*128896896x12BBox + 4 keypointszmurez/MediaPipePytorchblazepose.pth

Landmarks Models

VersionTypeInput SizeFlagLandmarksCommentsSourceModel Link
v0.07Hand256*256121x321 keypoints (x,y,score)zmurez/MediaPipePytorchblazehand_landmark.pth
v0.07Face192*1921896x16468 keypoints (x,y,score)zmurez/MediaPipePytorchblazeface_landmark.pth
v0.07Pose (Upper Body)256*256139x531 keypoints (x,y,z,visibility,presence)zmurez/MediaPipePytorchblazepose_landmark.pth

Profiling

Profiling Results for the following pipelines on various platforms

TypePipelineDetector ModelLandmark Model
handtfl_hand_v0_07blaze_tflite/models/palm_detection_without_custom_op.tfliteblaze_tflite/models/hand_landmark_v0_07.tflite
handtfl_hand_v0_10_liteblaze_tflite/models/palm_detection_lite.tfliteblaze_tflite/models/hand_landmark_lite.tflite
handtfl_hand_v0_10_fullblaze_tflite/models/palm_detection_full.tfliteblaze_tflite/models/hand_landmark_full.tflite
handpyt_hand_v0_07blaze_pytorch/models/blazepalm.pthblaze_pytorch/models/blazehand_landmark.pth
handvai_hand_v0_07blaze_vitisai/models/blazepalm/{DPU}/blazepalm.xmodelblaze_vitisai/models/blazehandlandmark/{DPU}/blazehandlandmark.xmodel
handhai_hand_v0_07blaze_hailo/models/palm_detection_v0_07.hefblaze_hailo/models/hand_landmark_v0_07.hef
handhai_hand_v0_10_liteblaze_hailo/models/palm_detection_lite.hefblaze_hailo/models/hand_landmark_lite.hef
handhai_hand_v0_10_fullblaze_hailo/models/palm_detection_full.hefblaze_hailo/models/hand_landmark_full.hef
facetfl_face_front_v0_07blaze_tflite/models/face_detection_front_v0_07.tfliteblaze_tflite/models/face_landmark_v0_07.tflite
facetfl_face_back_v0_07blaze_tflite/models/face_detection_back_v0_07.tfliteblaze_tflite/models/face_landmark_v0_07.tflite
facetfl_face_v0_10_shortblaze_tflite/models/face_detection_short_range.tfliteblaze_tflite/models/face_landmark.tflite
facetfl_face_v0_10_fullblaze_tflite/models/face_detection_full_range.tfliteblaze_tflite/models/face_landmark.tflite
facetfl_face_v0_10_sparseblaze_tflite/models/face_detection_full_range_sparse.tfliteblaze_tflite/models/face_landmark.tflite
facepyt_face_v0_07_frontblaze_pytorch/models/blazeface.pthblaze_pytorch/models/blazeface_landmark.pth
facepyt_face_v0_07_backblaze_pytorch/models/blazefaceback.pthblaze_pytorch/models/blazeface_landmark.pth
facehai_face_v0_10_shortblaze_hailo/models/face_detection_short_range.hefblaze_hailo/models/face_landmark.hef
facehai_face_v0_10_fullblaze_hailo/models/face_detection_full_range.hefblaze_hailo/models/face_landmark.hef
posetfl_pose_v0_10_liteblaze_tflite/models/pose_detection.tfliteblaze_tflite/models/pose_landmark_lite.tflite
posetfl_pose_v0_10_fullblaze_tflite/models/pose_detection.tfliteblaze_tflite/models/pose_landmark_full.tflite
posetfl_pose_v0_10_heavyblaze_tflite/models/pose_detection.tfliteblaze_tflite/models/pose_landmark_heavy.tflite
posetfl_pose_v0_07_upperblaze_tflite/models/pose_detection_v0_07.tfliteblaze_tflite/models/pose_landmark_v0_07_upper_body.tflite
posetflq_pose_v0_07_upperblaze_tflite_quant/models/pose_detection_128x128_full_integer_quant.tfliteblaze_tflite_quant/models/pose_landmark_upper_body_256x256_full_integer_quant.tflite
posetflh_pose_v0_07_upperblaze_tflite/models/pose_detection_v0_07.tfliteblaze_tflite_quant/models/pose_landmark_upper_body_256x256_full_integer_quant.tflite
posetflq_pose_v0_10_upperblaze_tflite_quant/models/pose_detection_full_quant.tfliteblaze_tflite_quant/models/pose_landmark_full_quant.tflite
posepyt_pose_v0_07blaze_pytorch/models/blazepose.pthblaze_pytorch/models/blazepose_landmark.pth
posehai_pose_v0_10_liteblaze_tflite/models/pose_detection.tfliteblaze_hailo/models/pose_landmark_lite.hef

Where {DPU} corresponds to the DPU architecture for Vitis-AI targets.

Workstation (HP Z4 G4) with AMD Radeon Pro W7900 GPU

Latency

Frame Rate (estimated from total latency)

Laptop (ZBook)

Latency

Frame Rate (estimated from total latency)

ZUBoard with B512 DPU

Latency

Frame Rate (estimated from total latency)

References

The blaze_app_python demo is based on the following work:

The following articles provide detailed information on Accelerating MediaPipe:

About

Python application demonstration code for mediapipe models (blazepalm/hand, blazeface, blazepose).

Resources

Stars

30 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages