Posenet model inconsistent results: Node vs Browser
See original GitHub issueTo get help from the community, check out our Google group.
I ran the posenet model on node 8.11.3 and I am comparing results of the node implementation for a given image with the browser implementation for the same image.
The results are inconsistent. Am I missing something? Or Is this to be expected?
Here is my node implementation.
global.XMLHttpRequest = require("xhr2");
const tf = require('@tensorflow/tfjs');
require('@tensorflow/tfjs-node');
const fetch = require('node-fetch');
const {Image, createCanvas} = require('canvas');
const posenet = require('@tensorflow-models/posenet')
async function run() {
let img_path = 'ANY_IMAGE_URL';
let buffer = await fetch(img_path).then(res => res.buffer());
let img = new Image();
img.src = buffer;
const canvas = createCanvas(img.width,img.height);
canvas.getContext('2d').drawImage(img,0,0);
const imageScaleFactor = 0.5;
const flipHorizontal = false;
const outputStride = 8;
const multiplier = 0.5;
const net = await posenet.load(multiplier);
const pose = await net.estimateSinglePose(canvas, imageScaleFactor, flipHorizontal, outputStride);
console.log(pose);
return pose;
}
run();
NODE_RESULT:
{
"score":0.49880917983896594,
"keypoints":[
{
"score":0.964009702205658,
"part":"nose",
"position":{
"x":584.1284123357551,
"y":540.4772608240223
}
},
{
"score":0.9792177677154541,
"part":"leftEye",
"position":{
"x":605.033953373647,
"y":492.35327694003144
}
},
{
"score":0.9352774024009705,
"part":"rightEye",
"position":{
"x":554.98182878691,
"y":502.4654247774092
}
},
{
"score":0.8619629740715027,
"part":"leftEar",
"position":{
"x":654.1466329203885,
"y":516.7189273088338
}
},
{
"score":0.12242487072944641,
"part":"rightEar",
"position":{
"x":518.3222664865168,
"y":531.4258767239875
}
},
{
"score":0.39839959144592285,
"part":"leftShoulder",
"position":{
"x":753.1191716727424,
"y":696.705976944396
}
},
{
"score":0.6442915797233582,
"part":"rightShoulder",
"position":{
"x":471.280373605403,
"y":689.8485441580831
}
},
{
"score":0.9180301427841187,
"part":"leftElbow",
"position":{
"x":895.1230138391418,
"y":845.3166258401711
}
},
{
"score":0.929760217666626,
"part":"rightElbow",
"position":{
"x":297.96139968722963,
"y":814.5879274506809
}
},
{
"score":0.20664989948272705,
"part":"leftWrist",
"position":{
"x":390.43972649092785,
"y":970.6867716698673
}
},
{
"score":0.3140019476413727,
"part":"rightWrist",
"position":{
"x":386.6281021896843,
"y":972.8578296853178
}
},
{
"score":0.19098210334777832,
"part":"leftHip",
"position":{
"x":472.2402253290729,
"y":1026.7829016999826
}
},
{
"score":0.19772598147392273,
"part":"rightHip",
"position":{
"x":518.5166831746552,
"y":1029.4390766847068
}
},
{
"score":0.19201675057411194,
"part":"leftKnee",
"position":{
"x":664.483786053818,
"y":1456.2379157210196
}
},
{
"score":0.21349774301052094,
"part":"rightKnee",
"position":{
"x":495.78668012422276,
"y":1608.1637351606146
}
},
{
"score":0.21133828163146973,
"part":"leftAnkle",
"position":{
"x":685.1607353550086,
"y":1718.6341491358241
}
},
{
"score":0.20016910135746002,
"part":"rightAnkle",
"position":{
"x":683.8384805983751,
"y":1718.6952797660615
}
}
]
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible"
content="ie=edge">
<title>POSENET</title>
<script src="https://unpkg.com/@tensorflow/tfjs"></script>
<script src="https://unpkg.com/@tensorflow-models/posenet"></script>
</head>
<body>
<script>
const multiplier = 0.5;
const imageScaleFactor = 0.5;
const flipHorizontal = false;
const outputStride = 8;
let estimator = null;
function compute(src) {
const imageElement = new Image();
imageElement.src = src;
imageElement.crossOrigin = "Anonymous"
imageElement.onload = () => {
const canvas = document.createElement('canvas');
const ctx = canvas.getContext('2d');
canvas.width = imageElement.width;
canvas.height = imageElement.height;
ctx.drawImage(imageElement, 0, 0, canvas.width, canvas.height)
let imgdata = ctx.getImageData(0, 0, canvas.width, canvas.height);
posenet
.load(multiplier)
.then(function (net) {
if (!estimator) estimator = createEstimator(net);
return estimator(imgdata, imageScaleFactor, flipHorizontal, outputStride)
})
.then((resp) => {
console.log(JSON.stringify(resp));
})
}
}
function createEstimator(net) {
return function (imageElement, scaleFactor, flipHorizontal, outputStride) {
return net.estimateSinglePose(imageElement, scaleFactor, flipHorizontal, outputStride);
}
}
compute('SAME_IMAGE_URL')
</script>
</body>
</html>
BROWSER_RESULT:
{
"score":0.8681028520359713,
"keypoints":[
{
"score":0.9993013143539429,
"part":"nose",
"position":{
"x":578.9772613558526,
"y":531.6041130193785
}
},
{
"score":0.9997183680534363,
"part":"leftEye",
"position":{
"x":611.7083526511923,
"y":496.51715667554123
}
},
{
"score":0.9996011853218079,
"part":"rightEye",
"position":{
"x":551.8440553083223,
"y":502.5786637460719
}
},
{
"score":0.9673418998718262,
"part":"leftEar",
"position":{
"x":658.4875402129563,
"y":511.97225048555345
}
},
{
"score":0.6721202731132507,
"part":"rightEar",
"position":{
"x":519.1532856530139,
"y":512.3324056444221
}
},
{
"score":0.8626165390014648,
"part":"leftShoulder",
"position":{
"x":732.3887470257787,
"y":699.752749650838
}
},
{
"score":0.9294714331626892,
"part":"rightShoulder",
"position":{
"x":476.7100266447285,
"y":686.2188209235336
}
},
{
"score":0.9612163305282593,
"part":"leftElbow",
"position":{
"x":899.471788768789,
"y":843.1275232410964
}
},
{
"score":0.9578098654747009,
"part":"rightElbow",
"position":{
"x":298.8155607706043,
"y":823.8216600471369
}
},
{
"score":0.8985893726348877,
"part":"leftWrist",
"position":{
"x":804.0089537447619,
"y":991.5793307000699
}
},
{
"score":0.9297114610671997,
"part":"rightWrist",
"position":{
"x":388.29281428996694,
"y":990.1576139141062
}
},
{
"score":0.7482747435569763,
"part":"leftHip",
"position":{
"x":673.7793992629657,
"y":1070.5532308397346
}
},
{
"score":0.7607749104499817,
"part":"rightHip",
"position":{
"x":521.7338706150117,
"y":1047.567500109113
}
},
{
"score":0.9209008812904358,
"part":"leftKnee",
"position":{
"x":665.2541383625241,
"y":1438.8386407777584
}
},
{
"score":0.754119873046875,
"part":"rightKnee",
"position":{
"x":511.0992839204372,
"y":1440.0594120984638
}
},
{
"score":0.7490795850753784,
"part":"leftAnkle",
"position":{
"x":674.7143572911896,
"y":1719.4835948411314
}
},
{
"score":0.6471004486083984,
"part":"rightAnkle",
"position":{
"x":508.224646022602,
"y":1719.0399681389665
}
}
]
}
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Comparing MoveNet to PoseNet for Person Fall Detection
The model returns the coordinates of the 17 key points along with a confidence score. MoveNet: MoveNet is the latest generation pose estimation ......
Read more >Human Pose Estimation Using TensorFlow's PoseNet Model
Is it possible to identify the movement/pose of a human body by doing an analysis of images and/or video? The answer to this...
Read more >There is no position detail ("x","y") in posenet TensorFlow ...
I ran the posenet model on node v8.11.0. Here is the code that I have run. the output results do not show the...
Read more >[Updated] BodyPix: Real-time Person Segmentation in the ...
When we released PoseNet last year (the first model ever that allowed for body estimation (what a Kinect does) in the browser using...
Read more >Nonintrusive Fine-Grained Home Care Monitoring - MDPI
The pose maps either past or present can be viewed from the browser of ... We used a PoseNet model for single-person pose...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Any progress or updates on this issue? Were you able to reproduce this issue?
Closing this issue as the
tfjs-models/posenet
has been deprecated in favor oftfjs-models/posenet-detection
, please check the bennchmarktool to check the various backends here