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.

Bad performance for browsers

See original GitHub issue

I have found that performance is terribly slow for browsers. But that’s the case at least if you use windows. Tested right on the face-api site example : https://justadudewhohacks.github.io/face-api.js/face_recognition . I tested it on several different windows machines. It takes roughly 25 seconds to recognise faces. https://user-images.githubusercontent.com/30739218/101359816-b224bf00-3894-11eb-801a-31e1c3bbfe4a.gif

On linux it works quite alright, taking 3 seconds with the example above. However there is one caveat. It works alright on chrome at this moment. For firefox there is a bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1678652 https://bugzilla.mozilla.org/show_bug.cgi?id=1679671

In short, for firefox v83, there was a fix applied to how failIfMajorPerformanceCaveat property works. Now if a library uses failIfMajorPerformanceCaveat: true then webgl context creation fails and the library falls back to CPU, which is rather slow. However, that’s true for linux only for now. On windows it still uses webgl, and still rather slow (20-30 seconds) for any browser.

I am not sure if that’s the issue of face-api.js or tensorflow itself

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:12

github_iconTop GitHub Comments

1reaction
vladmandiccommented, Dec 16, 2020

i’m not sure i understand as this example is not complete. is analyzeVideo async function? if yes, then you have race scenario that is reduced a bit by having a delay between frames.

why not put a promise in analyzeVideo and then do something like:

analyzeVideo(videoEl, mode, faceDetectorOptions).then(() => requestAnimationFrame(() => pullAndPostFrameTimer(videoEl, mode));

or easier to read with async/await

await analyzeVideo(videoEl, mode, faceDetectorOptions);
requestAnimationFrame(() => pullAndPostFrameTimer(videoEl, mode));

that way loop will run as fast as possible and there is no race.

1reaction
vladmandiccommented, Dec 15, 2020

face-api.js includes bundled tfjs-core.

If you don’t even look at the code, look at sizes - face-api on its own is ~200kb, remaining ~600kb is tfjs-core.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Speed Up Chrome, Firefox & Other Browsers - Avast
Check the speed of your internet · Update your browser · Remove unnecessary extensions and plugins · Clear your browser cookies and cache...
Read more >
Troubleshoot Chrome Browser performance issues
Is Chrome running too slow or using too much memory? Here's how to troubleshoot Chrome Browser performance issues on Microsoft ® Windows ®...
Read more >
Speed Up Chrome, Firefox & IE | Slow Browser Fixes - AVG
There are many reasons why your web browser is slow. You might have too many tabs open, a bloatware buildup, or weak Wi-Fi....
Read more >
Sluggish Browser? Here's How to Speed Up Google Chrome
Sluggish Browser? Here's How to Speed Up Google Chrome · Check Your Internet Speed · Update to the Latest Version of Chrome ·...
Read more >
Slow performance, unexpected responses and ... - Solve CRM
Slow performance, unexpected responses and troubleshooting browser related issues. · Firefox open History > Clear recent history > choose “Time range to clear: ......
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