Human Pose Estimation (using TensorFlow.js with PoseNet Model) Version

Linux Build Windows Build NSP Status Test Coverage Dependency Status devDependencies Status

The quickest way to get start with Human Pose Estimation (using TensorFlow.js with PoseNet Model), just clone the project:

$ git clone https://github.com/arjunkhetia/Human-Pose-Estimation.git

Install dependencies:

$ npm install

Start the angular app at http://localhost:4200/:

$ npm start

TensorFlow.js

TensorFlow is an open source software library for numerical computation using data flow graphs. The graph nodes represent mathematical operations, while the graph edges represent the multidimensional data arrays (tensors) that flow between them. TensorFlow.js is a library for developing and training ML models in JavaScript, and deploying in browser or on Node.js.

import * as tfjs from '@tensorflow/tfjs';

PoseNet

PoseNet can be used to estimate either a single pose or multiple poses, meaning there is a version of the algorithm that can detect only one person in an image/video and one version that can detect multiple persons in an image/video.

This TensorFlow.js model does not require you to know about machine learning. It can take as input any browser-based image elements (,

// Loads MobileNetV1 based PoseNet
const net = await posenet.load({
  architecture: 'MobileNetV1',
  outputStride: 16,
  inputResolution: 513,
  multiplier: 0.75
});
/// Loads ResNet based PoseNet
const net = await posenet.load({
  architecture: 'ResNet50',
  outputStride: 32,
  inputResolution: 257,
  quantBytes: 2
});

Sinple Person Detection

import * as posenet from '@tensorflow-models/posenet';

async function estimatePoseOnImage(imageElement) {
  // load the posenet model from a checkpoint
  const net = await posenet.load();

  const poses = await net.estimatePoses(imageElement, {
    flipHorizontal: false,
    decodingMethod: 'single-person'
  });
  const pose = poses[0]
  return pose;
}

const imageElement = document.getElementById('cat');

const pose = estimatePoseOnImage(imageElement);

console.log(pose);

Multi Person Detection

import * as posenet from '@tensorflow-models/posenet';

async function estimateMultiplePosesOnImage(imageElement) {
  const net = await posenet.load();

  // estimate poses
  const poses = await net.estimatePoses(imageElement, {
        flipHorizontal: false,
        maxPoseDetections: 2,
        scoreThreshold: 0.6,
        nmsRadius: 20});

  return poses;
}

const imageElement = document.getElementById('people');

const poses = estimateMultiplePosesOnImage(imageElement);

console.log(poses);

Image Mode -

Single Person with Keypoints

1

Single Person with Keypoints & Skeleton

2

Single Person with Keypoints, Skeleton & Bounding Box

3

Multi Person with Keypoints & Skeleton

4

Multi Person with Keypoints, Skeleton & Bounding Box

5

Video Mode -

Single Person with Keypoints & Skeleton

6

Single Person with Keypoints, Skeleton & Bounding Box

7

ResNet based PoseNet Model (high estimation accuracy) -

Single Person with Keypoints & Skeleton

8