Google News
logo
ml5.js - Interview Questions
What is PoseNet in ml5.js?
PoseNet is a machine learning model that allows for Real-time Human Pose Estimation.
 
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.
 
The original PoseNet model was ported to TensorFlow.js by Dan Oved. 

Quickstart
const video = document.getElementById('video');

// Create a new poseNet method
const poseNet = ml5.poseNet(video, modelLoaded);

// When the model is loaded
function modelLoaded() {
  console.log('Model Loaded!');
}
// Listen to new 'pose' events
poseNet.on('pose', (results) => {
  poses = results;
});
 
Initialize : There are a couple ways to initialize ml5.poseNet.
// Initialize with video, type and callback
const poseNet = ml5.poseNet(?video, ?type, ?callback);
// OR Initialize with video, options and callback
const poseNet = ml5.poseNet(?video, ?options, ?callback);
// OR Initialize WITHOUT video. Just options and callback here
const poseNet = ml5.poseNet(?callback, ?options);
 
Parameters : 
video : OPTIONAL. Optional HTMLVideoElement input to run poses on.
 
type : OPTIONAL. A String value to run single or multiple estimation. Changes the detectionType property of the options. Default is multiple.
 
callback : OPTIONAL. A function that is called when the model is loaded.
 
options : OPTIONAL. A object that contains properties that effect the posenet model accuracy, results, etc.
{
  architecture: 'MobileNetV1',
  imageScaleFactor: 0.3,
  outputStride: 16,
  flipHorizontal: false,
  minConfidence: 0.5,
  maxPoseDetections: 5,
  scoreThreshold: 0.5,
  nmsRadius: 20,
  detectionType: 'multiple',
  inputResolution: 513,
  multiplier: 0.75,
  quantBytes: 2,
};
Advertisement