Similarity comparison on Frontend or Backend ? For optimum performance #145
-
What I want build:
**How **: My plan:
Why:
The Problem: Note: my first project so any suggestion will be welcomed. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
NodeJS is single-threaded, but you can use a preinitialized pool of worker processes and See That way you can even say to user 'you're number xx in the queue` without ever blocking the server or the response to the client
In theory, you could break down compare operation so server only finds rough matches and then generates JSON of those to send to the client which then does in-detail processing. Also, best to process JSON in a web-worker thread in a browser so not to block the frontend UI at all |
Beta Was this translation helpful? Give feedback.
-
Hi. I am the maintainer of HomeGallery, a self hosted open source photo web gallery and would like to share my experience on that topic: I extract similarity vector on the backend and do the similarity comparison on the frontend. I support image similarity AKA reverse image search and face similarity. For the image similarity I did some investigation to reduce the data to fit into the browser with 87 bytes per image resulting a good balance between size and result. As example checkout the similarity of buildings on my demo gallery. 1.3 GB raw JSON data was reduced to 11 MB for 100,000 image set. The comparison (100,000 comparisons) takes less than 500ms on recent mobile devices. For face similarity I am using face-api from @vladmandic (thanks again!). However I did not investigate into web optimization and the data is more or less original JSON, also the used version is quite old (0.13.3). Here the time is quite similar for a comparison. Depending on your use case I guess it should be possible to get and process half million face similarity vectors into a recent browser. The similar vector should be browser optimized with a reduced data as @vladmandic proposed. If you have more than half million face vectors I suggest a backend solution. |
Beta Was this translation helpful? Give feedback.
NodeJS is single-threaded, but you can use a preinitialized pool of worker processes and
send each request to worker with currently lowest load
See
demo/nodejs/node-multiproces.js
anddemo/nodejs/node-multiprocess-worker.js
for exampleThat way you can even say to user 'you're number xx in the queue` without ever blocking the server or the response to the client
In theory, you could break down compare operation so server only finds rough m…