justadudewhohacks / face-api.js

JavaScript API for face detection and face recognition in the browser and nodejs with tensorflow.js
MIT License
16.67k stars 3.71k forks source link

Why is my app so fast with iPhone and slow with MacOS? #742

Open fabiensen opened 3 years ago

fabiensen commented 3 years ago

Hi

as many other users, I see that the very first recognition is successfully done after around ten seconds from the models loading.

I have the most common scenario: a canvas where images are saved from the webcam stream.

This actually happens with Chrome 87 on a MacBook Air 2019 with Big Sur installed. If I try the same webpage with my iPhone SE 2020 the first recognition happens in less than one second probably, with Safari.

I would have expected the opposite behavior. Is there any reason why iPhone is so faster than Mac? I don't think it is a GPU nor a WebGL stuff...

Thanks!

vladmandic commented 3 years ago

you haven't said which backend is used in both cases (webgl, wasm, cpu)? (and if wasm, if simd is enabled or not)

but in general, MacBook Air 2019 does not have a decidated GPU - it has integrated Intel UHD which is pretty bad.
on the other hand, iPhone SE 2020 has an actual decent GPU. so no surprise your phone is faster than notebook - if you're using webgl backend.

also note that fast vs slow is different than initialization time.
e.g, webgl shader initialization and upload can take quite a lot of time, but then run smooth after that - that is quite common for webgl backend with more complex models.

on the other hand, wasm backend has almost instant initialization but doesn't run anywhere as fast when compared to webgl on a good GPU.