Code
Let explain the code..
We start to create our HTML file and add our tensorflow js library and posenet model.
<html>
<head>
<!-- Load TensorFlow.js and Posenet Library-->
<meta charset="utf-8"/>
<script src="https://unpkg.com/@tensorflow/tfjs"></script>
<script src="https://unpkg.com/@tensorflow-models/posenet"></script>
</head>We define an image or a video input so it could be load in our ponsenet function.
We also need to define some parameters such as: imageScaleFactor, outputStride, flipHorizontal.
<body>
<img id="people" src="C:\Users\REY1GA\Documents\single.jpg" style="width: 600px; height: 600px;">
</body>
<script>
var imageScaleFactor = 0.5;
var outputStride = 16;
var flipHorizontal = false;
var imageElement = document.getElementById('people')
posenet.load().then(function(net){
return net.estimateSinglePose(imageElement,imageScaleFactor,flipHorizontal,outputStride)
}).then(function(pose){
console.log(pose);
})
</script>
</html>Our output we could see and mode developer in the console. Something like this:
If we want to make a multipose detection we need to make some changes on our function.
Last updated
Was this helpful?