question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Slow in nodejs project

See original GitHub issue

Hello!

I am trying to setup simple face detection in nodejs env. Out of the box everything run fine with the exception of speed. It takes 12+ seconds for a single face detection.

require('@tensorflow/tfjs-node')

is included!

On execution i see:

cpu backend was already registered. Reusing existing backend

then

Hi there 👋. Looks like you are running TensorFlow.js in Node.js. To speed things up dramatically, install our node backend, which binds to TensorFlow C++, by running npm i @tensorflow/tfjs-node, or npm i @tensorflow/tfjs-node-gpu if you have CUDA. Then call require(‘@tensorflow/tfjs-node’); (-gpu suffix for CUDA) at the start of your program. Visit https://github.com/tensorflow/tfjs-node for more details.

When i install older versions of the two packages:

npm install @tensorflow/tfjs-node@0.3.0 face-api.js@0.14.3

there is significant speed improvement, BUT i need age and gender detection , which is not present below face-api.js < 0.20.0

I also tryed: @tensorflow/tfjs-node version 1.0.2

but then i get:

(node:29723) UnhandledPromiseRejectionWarning: TypeError: tfc.ENV.findBackend is not a function at nodeBackend (/home/pi/testproject/node_modules/@tensorflow/tfjs- node/dist/ops/op_utils.js:25:28)

How can i use age and gender recognition and get faster speed under nodejs?

Environment Raspberry Pi Node: v8.10.0 face-api.js: 0.20.0 / 0.14.3 @tensorflow/tfjs-node: 1.1.2 / 1.0.2 / 0.3.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
justadudewhohackscommented, Jun 5, 2019

@tensorflow/tfjs-node 1.0.2 + @tensorflow/tfjs-core 1.0.3 should work with face-api.js 0.20.0. This is the setup that the nodejs examples use. The error message you posted might indicate, that you are not using tfjs-core 1.0.3.

1reaction
0x6c23commented, Sep 23, 2019

I’m getting following error, please help to resolve

cpu backend was already registered. Reusing existing backend factory. Platform node has already been set. Overwriting the platform with [object Object]. node-pre-gyp info This Node instance does not support builds for N-API version 4 node-pre-gyp info This Node instance does not support builds for N-API version 4 module.js:549 throw err; ^

Error: Cannot find module ‘D:\bench_work_space\GCH\face-expressions\face-expressions\facetest\node_modules@tensorflow\tfjs-node\lib\napi-v3\tfjs_binding.node’ at Function.Module._resolveFilename (module.js:547:15) at Function.Module._load (module.js:474:25) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at Object. (D:\bench_work_space\GCH\face-expressions\face-expressions\facetest\node_modules@tensorflow\tfjs-node\dist\index.js:44:16) at Module._compile (module.js:652:30) at Object.Module._extensions…js (module.js:663:10) at Module.load (module.js:565:32) at tryModuleLoad (module.js:505:12) at Function.Module._load (module.js:497:3)

Same issue here. Impossible to include @tensorflow. It installs without errors. Tried many versions. Still not able to include.

Read more comments on GitHub >

github_iconTop Results From Across the Web

This is why your Node.js application is slow
Many performance-related issues in Node.js applications have to do with how promises are implemented. Yes, you read that right.
Read more >
7 Ways to Improve Node.js Performance at Scale
3. Use Timeouts When Dealing with I/O Operations · 4. Don't Serve Static Assets with Node.js · 5. Use Clustering to Improve Throughput...
Read more >
Why is Node.js and JavaScript so slow? - Quora
The conclusion is that Node.js is slower than C++, but faster (except for 2 benchmarks) than Python.
Read more >
Faster expressjs Apps — Why is your nodejs app slow
Starting nodejs server is slow, or starting test cases is really slow. The code structure may be to blame. The leading cause of...
Read more >
7 ways to improve Node.js performance at scale
7 ways to improve Node.js performance at scale · 1. Frontend tooling · 2. SSL/TLS and HTTP/2 · 3. Caching · 4. Optimizing...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found