xenova / transformers.js

State-of-the-art Machine Learning for the web. Run 🤗 Transformers directly in your browser, with no need for a server!
https://huggingface.co/docs/transformers.js
Apache License 2.0
11.33k stars 705 forks source link

Cannot download models on browser #942

Open JesusP2 opened 3 weeks ago

JesusP2 commented 3 weeks ago

System Info

transformers.js version: 2.17.2 browsers: all I've tried so far(firefox and chrome) OS: arch linux x86_64 node version: 20.17.0

Environment/Platform

Description

I'm trying to run some models on the browser but I don't think they are even getting downloaded, I've tried 2: Xenova/modnet and onnx-community/BiRefNet_lite but I got the same error. I managed to run it on node but not the browser. I get this error: image that points to this section of the code I believe: https://github.com/xenova/transformers.js/blob/main/src/utils/hub.js#L571

I'm running SAM (Xenova/slimsam-77-uniform) on a different worker but that one works perfectly fine, no idea if I'm doing something wrong for Birefnet/modnet.

Reproduction

1.- clone https://github.com/JesusP2/transformers-error-repro 2.- install dependencies (npm i) 3.- run the project (npm run dev) 4.- go to the website and upload an image

Also if you want to run the code on node run "node node.js" and that should run the model server-side(it works).

flatsiedatsie commented 3 weeks ago

That error message implies a 404 error, and the code it trying to load a 404 error HTML page as if it were JSON.

I'd check if that URL you're loading actually exists.

JesusP2 commented 3 weeks ago

Well yeah I see it's returning an HTML instead of json, that's why JSON.parse fails. My question is why is it doing this only when I run the code on the browser and not on node? the model exists 100%.

flatsiedatsie commented 3 weeks ago

Hmm. Could you try adding this to a htaccess file?

AddType text/javascript .js .ts .mjs .cjs
AddType application/wasm wasm

Do you have any browser plugins that might me over-protecting? uBlock origin? uMatrix? Brave Shields?

JesusP2 commented 3 weeks ago

what does that file do? and no, I've tried on a fresh chrome installation and I get the same error

flatsiedatsie commented 2 weeks ago

https://duckduckgo.com/?q=what+is+htaccess

JesusP2 commented 2 weeks ago

I asked because the only info I get is related to apache, which I didn't even mention in the post.

flatsiedatsie commented 2 weeks ago

why is it doing this only when I run the code on the browser and not on node?