hand-pose-detection: 'tfjs-webgl' backend returns NaN values
System information
- OS Platform and Distribution: iOS 15.7.2
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: iPhone 7 Plus
- TensorFlow.js installed from (npm or script link): @tensorflow-models/hand-pose-detection
- TensorFlow.js version (use command below): 4.1.0
- Browser version: Safari 15.7.2
- Tensorflow.js Converter Version: 4.1.0
Describe the current behavior I'm setting the hand-pose-detection model following the https://storage.googleapis.com/tfjs-models/demos/hand-pose-detection/index.html?model=mediapipe_hands example
In my code, setting the mediapipe runtime works fine, although setting the 'tfjs-webgl' runtime returns NaN values of x,y coordinates.
Detector initialization:
detectorConfig = {
runtime: 'tfjs',
modelType: 'full',
maxHands: 1
}
handDetector = await handPoseDetection.createDetector(model, detectorConfig)
Estimate hand data:
try {
handData = await handDetector.estimateHands(sourceElement,
{flipHorizontal: isFlipHorizontal} // flipHorizontal: false, if we want the result to flip horizontaly. Defaults is set to false.
)
} catch (error) {
handDetector.dispose()
handDetector = null
alert(error)
}
Logged detector output:
Tensorflow environment flags:
I would appreciate any suggestion on how to fix this issue. Maybe I'm missing some other detector configuration or setting? Thanks!
HI @mikkamikka could you provide your codes? Then I could reproduce the error to debug it.
Hi @Linchenn, thank you for your response. I made a demo that reproduces the bug. You can have a look at it here https://codesandbox.io/p/github/mikkamikka/hand-pose-tfjs/draft/fast-water?file=%2Fsrc%2Findex.js&workspace=%257B%2522activeFileId%2522%253A%2522clcewpkrf000n7pi0d4a08ru6%2522%252C%2522openFiles%2522%253A%255B%255D%252C%2522sidebarPanel%2522%253A%2522EXPLORER%2522%252C%2522gitSidebarPanel%2522%253A%2522COMMIT%2522%252C%2522spaces%2522%253A%257B%2522clcexpmmp00d3356inev0xfp0%2522%253A%257B%2522key%2522%253A%2522clcexpmmp00d3356inev0xfp0%2522%252C%2522name%2522%253A%2522Default%2522%252C%2522devtools%2522%253A%255B%257B%2522key%2522%253A%2522clcexpmmp00d4356i2kv1o1r7%2522%252C%2522type%2522%253A%2522PROJECT_SETUP%2522%252C%2522isMinimized%2522%253Afalse%257D%252C%257B%2522type%2522%253A%2522TASK_LOG%2522%252C%2522taskId%2522%253A%2522build%2522%252C%2522key%2522%253A%2522clcexpy7h00h1356ixi0bmbpn%2522%252C%2522isMinimized%2522%253Afalse%257D%255D%257D%257D%252C%2522currentSpace%2522%253A%2522clcexpmmp00d3356inev0xfp0%2522%252C%2522spacesOrder%2522%253A%255B%2522clcexpmmp00d3356inev0xfp0%2522%255D%257D
@Linchenn I am having the same problem. The mp backend works fine, the tfjs returns NaN values.
@tomermesser @mikkamikka did you find a solution here? Have got the exact same problem and it would be cool to understand what is behind it.
@tomermesser @mikkamikka did you find a solution here? Have got the exact same problem and it would be cool to understand what is behind it.
@Linchenn a bump on this. I have been specifically requested to use the tfjs runtime if possible but this issue is making it unfeasible. I get a similar issue with face detection, but it returns 0 instead of NaN. Both are find with the mediapipe runtime
Sorry for the delayed reply. It's weird, it looks like our online demo works for tfjs-webgl. I could not access your previous codesandbox codes, so could you help me check it?
@Linchenn no worries - can you point me to the demo and I will look at that? It wasn't me that made a sandbox before but I will attempt to make a minimal reproducible and send it to you to check out. I went deep into the code provided in the package using the debugger, but it looked like whatever was going wrong was in the minified/transpiled code so I couldn't tell what the issue was
I think the demo code is here, https://github.com/tensorflow/tfjs-models/tree/master/hand-pose-detection/demos/live_video. Here is the guide, https://github.com/tensorflow/tfjs-models/tree/master/hand-pose-detection/demos.
Hi, @mikkamikka, @kiranmarshall
Apologize for the delayed response, May I know your issue got resolved or still are you looking for help with your issue ? if yes, If you could provide me with a minimal code example that reproduces the issue, it would be very helpful in debugging the problem. Thank you!
Hi @gaikwadrahul8 - good news is that I managed to get it working, but bad news is I've no idea how. This was a few weeks ago and I had bigger fish to fry at that point to be able to get deep into the debugger to see what was going on. I do remember starting by making a minimal reproducible, and it just sort of worked at that point.
One issue I am having now is that I am unable to use a tensor to carry out inference on the model - instead I need to convert it to an ImageBitmap. When supplying a 3d tensor the package is not throwing any errors about incorrect tensor size etc., it's just not returning any results. Again, this isn't pressing, but if you have any inside knowledge that could steer me it would be super useful! Thanks for your time so far.
This issue has been marked stale because it has no recent activity since 7 days. It will be closed if no further activity occurs. Thank you.
This issue was closed due to lack of activity after being marked stale for past 7 days.
+1 here. I noticed that when I use video with height and width as 100% it works but if I try to set to anything smaller it causes NaNs to be returned.