-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
tfjs-node does not implement kernel FlipLeftRight #4066
Comments
@vladmandic can you please check for a similar issue here |
There is no version conflict and I'm running latest TFJS 2.6.0. Just to confirm, I created a simple test that only has And I did note the issue #3883 that clearly lists that forwardFunc is not implemented in And it's easy to check: nm -D node_modules/@tensorflow/tfjs-node/deps/lib/libtensorflow.so | grep forwardFunc function is not present in tensorflow.so shared library which is the backend for |
I'm going to rename this issue, because the underlying issue is that as mentioned in #3883 blazeface and handpose run kernels that are not implemented in the node.js backend. The error message is a bit confusing to that can be improved as well. I'll file a separate issue for that. |
i understand the need for better error message, but will this feature request to actually implement kernel function stay open and eventually be completed? |
I'll try and get an update on this. |
I get with node-gpu on Windows 10 |
i've tested with tfjs 3.0.0 and error message is improved:
now the remaining part is to actually implement function @rthadur @tafsiri and plans for implementing this? the issue is open and not even assigned. |
Usually feature request are prioritized by the team and are assigned later , hopefully it will get picked up soon. I am tagging this for contributions welcome if any one interested. |
@rthadur I am interested in implementing this if you're still accepting external contributors. |
@DCtheTall please go-ahead , thanks for your interest. |
@rthadur you're welcome! I was wondering if there is a place in tfjs-node which would be a good example of how you typically implement new kernel functions for Node.JS. Just an example of what to go off of should be enough for me to hack something together for a PR |
Thank you @DCtheTall! This PR might be a good example of adding missing ops to node JS, and this doc might also be helpful. Really appreciate it! |
@jinjingforever thank you for the links. This should be all I need to get started! |
@rthadur @jinjingforever I have opened a #5261 which implements this function for Node.JS. Lmk if anything else needs to be done. |
Thank you @DCtheTall for the PR! |
This change will be available in next release , thank you so much @DCtheTall for your contribution. |
Sorry, thanks to @mattsoulanille, looks like the underlying TF C API (1.15) doesn't support this op. It is not supported in the latest version (2.5) either. What is the right approach to support this kind of ops? (@pyu10055 @lina128 @mattsoulanille). Thanks! |
Hi @jinjingforever, I see that there's a ScaleAndTranslate in the c API: https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/scale-and-translate Can we use that for FlipLeftAndRight? |
If ImageProjectiveTransformV3 is available in the c API, it's even better, it's easier to express flip with an Affine transformation matrix: https://www.tensorflow.org/api_docs/python/tf/raw_ops/ImageProjectiveTransformV3 |
Thank you @lina128! I checked the code and looks like the scale factors have to be greater than 0. So it probably cannot be used to flip an image. And looks like ImageProjectiveTransformV3 is not available in the C API. Maybe we could use "reverse" to do the flip, i.e. reverse on the 'H' dimension: Also, there might be a bug in the current tfjs flipLeftRight implementations that might need to be fixed first. Will discuss with @lina128 offline. |
reverse sounds good to me. |
@lina128 thanks for the reply. I'd be happy to assist if I can with any other work needed to reland my original PR |
Thanks @DCtheTall! I am working on a fix for the existing implementations in other backends and related tests. After that is merged, it would be great if you could help refactor your PR to use "reverse" to implement flipLeftRight in node. Really appreciate it! |
@jinjingforever SGTM. Let me know when your change has merged and I can refactor my PR accordingly |
Hi @DCtheTall, I've merged my PR. Now you can try implementing flipLeftRight using reverse. The PR also updated the tests. You can test your changes locally by running Thank you! Really appreciate your help! |
@jinjingforever @lina128 I just uploaded a PR that implements the kernel using reverse. Let me know if this is what you had in mind 😄 |
Both BlazeFace and HandDetector models work just fine in NodeJS using tensorflow backend
The issue is in how post-processing is done in JS code which uses
FlipLeftRight
kernel func to reorient input for better second-pass detection.So if you use tfjs examples, you'll run into this issue
Unfortunately, those models are internally used by several others as well such as
FaceMesh
andHandSkeleton
which makes list of affected models quite long.Request is to implement
FlipLeftRight
in tfjs-node - expectation is to have feature parity between main backends.Also, is there a matrix of implemented features per backend?
Environment: TFJS 3.6.0 on Ubuntu 20.04
The text was updated successfully, but these errors were encountered: