Transformer js
Posted by underwatercr312@reddit | LocalLLaMA | View on Reddit | 3 comments
Hi guys, a little application built with Svelte and local AI using Transformers.js. If you have a dedicated GPU, please let me know if this works fine — it should be fast to process. This use ai models to remove bg image and upscale images. If you know a better background-removal model than briaai/RMBG-1.4 that doesn’t require a Hugging Face access token, please let me know.
-
Repo -> https://github.com/ian0x-S2/jpg.ai
-
Demo -> https://jpg-ai.vercel.app/
stefferri@reddit
We did exactly this in an Obsidian plugin using Transformers.js v4. At startup we probe `navigator.gpu.requestAdapter()`, if it returns non-null we use the WebGPU execution provider, otherwise we fall back to CPU with `dtype: "q8"`. The q8 fallback was necessary anyway because fp32 on WASM was triggering `std::bad_alloc` on larger models (768-dim).
Worth knowing: WebGPU EP bypasses the WASM runtime entirely, which also avoids the SafeInt overflow in onnxruntime-web 1.26.0 for 768-dim models. Might be relevant if you're upscaling large images.
Repo: https://github.com/istefox/obsidian-mcp-connector
WaveCut@reddit
Well, it works! Not the fastest on my M2 Max MacBook, but does the job both for upscale and background removal.
underwatercr312@reddit (OP)
Thanks for the feedback maybe I need to put a fallback to webgpu