vladmandic / face-api

FaceAPI: AI-powered Face Detection & Rotation Tracking, Face Description & Recognition, Age & Gender & Emotion Prediction for Browser and NodeJS using TensorFlow/JS
https://vladmandic.github.io/face-api/demo/webcam.html
MIT License
852 stars 153 forks source link

Missing node-wasm.js demo in main branch #108

Closed zavalyshyn closed 2 years ago

zavalyshyn commented 2 years ago

Issue Description It's not an issue per se, but still. Is there a specific reason why node-wasm.js demo cannot be found in demo folder anymore? The 1.5 tag used to have that file, but not the latest branch.

Thanks for your hard work!

zavalyshyn commented 2 years ago

It seems that wasm backend is twice slower than a tensorflow one. Is this a reason?

$ node test2.cjs 
2022-05-15 22:28:09.275342: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  SSE3 SSE4.1 SSE4.2 AVX AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
FaceAPI single-process test
Version: TensorFlow/JS 3.17.0 FaceAPI 1.6.8 Backend: **tensorflow**
Loading FaceAPI models
Image: de2ec9469a726be80e135e2bbeb5de6b-86264658.jpeg Detected faces: 1
Label: sheldon (0.51)
Image: sheldon.jpeg Detected faces: 1
Label: unknown (0.65)
Processed 2 images in **780** ms
$ node test2.cjs 
2022-05-15 22:29:39.602250: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  SSE3 SSE4.1 SSE4.2 AVX AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
FaceAPI single-process test
Threads:  1
Version: TensorFlow/JS 3.17.0 FaceAPI 1.6.8 Backend: **wasm**
Loading FaceAPI models
Image: de2ec9469a726be80e135e2bbeb5de6b-86264658.jpeg Detected faces: 1
Label: sheldon (0.51)
Image: sheldon.jpeg Detected faces: 1
Label: unknown (0.65)
Processed 2 images in **1663** ms
vladmandic commented 2 years ago

i've removed the demo simply because there was no demand for it.
and if you take old demo, it still works with latest face-api.

and yes, wasm is slower than tfjs-node that has a binary binding to native tensorflow.so.

only reason to have tfjs-backend-wasm in nodejs is to either experiment (which is why i added it) or to run it on a cpu architecture which is not supported by tfjs-node (in which case you'd still need to compile wasm files manually, but that is much easier than compiling and binding tfjs-node)

zavalyshyn commented 2 years ago

Thanks for your explanation. I'm closing this issue.