vladmandic/human

Using in a chrome extension

alganzory opened this issue · 1 comments

Firstly, thank you so much @vladmandic for the great work, this project is awesome and I hope it gets more exposure!

so, how do I use this in a chrome extension?

The chrome extension I am building scans images in the DOM, detects faces, then draws something back on the dom

I am currently doing everything in a content script and importing from npm and using a bundler (vite)

but I have been pulling my hair trying to setup a web worker but seems like it's impossible with manifest v3, I really don't know..

I am also trying to maybe delegate the detection work to a background service worker but I am not even able to import Human cause all the different ways of importing return some sort of error, either 'document not defined' when trying the browser methods or 'require' not defined when using the node.js method and importing like this (note I am assigning the type of the background service to module just to be able to use import cause require isn't allowed either)

import * as HumanPackge from './human.node.js'
var Human = HumanPackge.default;

So please tell me :
1- Is there a way to use web worker (please bear with me, I am somewhat new to the world of chrome extensions)
2- If no.1 isn't possible, is there a way to use background service worker
3- What backend and models do you recommend using to make sure the extension isn't slow or heavy on the browser

Thank you

i haven't done any chrome extensions development in a while, but when i was experimenting with it i always had massive problems with bundlers and only way to load any complex library inside extension service worker or webworker was by doing ondemand load of old-school iife js version of the package. so not import or require or script tags.

note on issue vs discussion - do not create issues for general questions!