Coder Social home page Coder Social logo

blazepalm's Introduction

BlazePalm

BlazePalm is a fast, light-weight 2-part hand landmark detector from Google Research. Read more, Paper on arXiv

A pretrained model is available as part of Google's MediaPipe framework.

Besides a bounding box, BlazePalm also predicts 21 3D keypoints for hand landmarks (5 fingers x 4 keypoints + 1 wrist)

Because BlazePalm is designed for use on mobile devices, the pretrained model is in TFLite format. However, I wanted to use it in PyTorch and not TensorFlow. I also ported the PyTorch model to CoreML because the model is made for phones.

There are 2 parts to the model:

  1. Hand detector. It is a classic single shot detector(SSD).
  2. Landmark detector. After getting the hands from the hand detector, we crop them and pass them through the landmark detector to get the 3D landmarks.

Inside this repo

Essential ML files:

  • ML/blazepalm.py: defines the PalmDetector class that finds the bounding box for the hands in an image.

  • ML/palmdetector.pth: the weights for the trained model for PalmDetector

  • ML/genanchors.py: creates anchor boxes and saves them as a binary file (ML/anchors.npy)

  • ML/anchors.npy: lookup table with anchor boxes for PalmDetector

  • ML/export_detector.py: For converting the PyTorch model of PalmDetector to CoreML.

  • ML/handlandmarks.py: defines the HandLandmarks class that finds the 3D landmarks for a hand.

  • ML/HandLandmarks.pth: the weights for the trained model for HandLandmarks

  • ML/export_landmarks.py: For converting the PyTorch model of HandLandmarks to CoreML.

ML Notebooks:

  • ML/ConvertPalmDetector.ipynb: loads the weights from the TFLite model of PalmDetector and converts them to PyTorch format (ML/palmdetector.pth)

  • ML/ConvertHandDetector.ipynb: loads the weights from the TFLite model of HandLandmarks and converts them to PyTorch format (ML/HandLandmarks.pth)

iOS CoreML App

  • App/

Detections

CoreML

Each hand detection has 2 SIMD2 vectors(bounding box) and 1 Float number(confidence):

  • The first 4 numbers describe the bounding box corners:

    • xmin, ymin, xmax, ymax
  • These are normalized coordinates (between 0 and 1).

  • SIMD2 is used for faster vector math.

  • The final number is the confidence score that this detection really is a hand.

Each landmark detection has 21 SIMD3 vectors(landmarks) and 1 Float number(confidence):

  • These are normalized coordinates (between 0 and 1).

  • SIMD3 is used for faster vector math.

  • The final number is the confidence score that this detection really is a hand.

PyTorch

Each hand detection has 4 Floats(bounding box) and 1 Float number(confidence) as defined in the CoreML section. Each landmark detection has 21 Floats(landmarks) and 1 Float number(confidence) as defined in the CoreML section.

blazepalm's People

Contributors

vidursatija avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.