Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Many false detections while running on mobile device #47

Open
dajuric opened this issue Apr 11, 2021 · 2 comments
Open

Many false detections while running on mobile device #47

dajuric opened this issue Apr 11, 2021 · 2 comments

Comments

@dajuric
Copy link

dajuric commented Apr 11, 2021

The library runs fine on my laptop. However, when I run the online demo (even on provided images) on my mobile device (Samsung Galaxy S10e) I get a lot of false positives which confidences are 0.999.

Do you know what is happening ?

@victordibia
Copy link
Owner

victordibia commented Apr 11, 2021

Hi @dajuric ,

I am still trying to figure this out myself. On my IphoneX, detection on images work correctly in safari and chrome. Video struggles a bit (possibly due to low FPS) . I have not tested on Android, but would expect images to work corrrectly.

The one thing that comes to mind is that handtrack.js is designed to use a webgl backend (webgl should be available in most modern mobile/web browsers). When that is not available, I think it kicks all computation to cpu. That in itself should not result in a wild change in accuracy. There is also the issue with numeric precision on mobile webgl backends that can impact computations.

On mobile devices, WebGL might only support 16 bit floating point textures. However, most machine learning models are trained with 32 bit floating point weights and activations. This can cause precision issues when porting a model for a mobile device as 16 bit floating numbers can only represent numbers in the range [0.000000059605, 65504]. This means that you should be careful that weights and activations in your model do not exceed this range. To check whether the device supports 32 bit textures, check the value of tf.ENV.getBool('WEBGL_RENDER_FLOAT32_CAPABLE'), if this is false then the device only supports 16 bit floating point textures. You can use tf.ENV.getBool('WEBGL_RENDER_FLOAT32_ENABLED') to check if TensorFlow.js is currently using 32 bit textures.

What browser are you using on your Galaxy device? Perhaps we can check its supported numeric precision?
Also, the new version of handtrack.js seen in the demo (still ongoing work) provides a toggle for fp16 (medium) and int8 (small) quantized versions of the model. Does the mobile accuracy issue persist across all model sizes?

-V.

@dajuric
Copy link
Author

dajuric commented Apr 12, 2021

Hi Victor.

thanks for the response.
I am using Google Chrome (mobile) - version 89.

Regarding model sizes - I can not find the toggle in the referenced demo page. Once enabled, I will gladly test it.

P.S.
just for the reference, I wanted to mention the Hand-JS (I am the coo-creator) - the library was built a while ago. It has been built on older technology (not CNN) - it did not succeed unfortunately, but again I was not pushing hard due to other reasons. I can see that yours is totally different story. And I wish you good luck.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants