Readit News logoReadit News
Posted by u/anduc a year ago
Show HN: Remove-bg – open-source remove background using WebGPUbannerify.co/tools/remove...
Yesterday,I saw a post in X asking for a self-hostable background remover service. I was thinking, can we make it work by using WebGPU? So it will run in the browser and doesn't require any server/queue to run

After a couple of hours, I created this and published the source code on https://github.com/ducan-ne/remove-bg

It's still new so welcome any ideas and contributions

Powered by WebGPU and Transformer.js (RMBG V1.4 model)

Birch-san · a year ago
feels like it could be nice to abide by the license terms https://bria.ai/bria-huggingface-model-license-agreement/

> 1.1 License. > BRIA grants Customer a time-limited, non-exclusive, non-sublicensable, personal and non-transferable right and license to install, deploy and use the Foundation Model for the sole purpose of evaluating and examining the Foundation Model. > The functionality of the Foundation Model is limited. Accordingly, Customer are not permitted to utilize the Foundation Model for purposes other than the testing and evaluation thereof.

> 1.2.Restrictions. Customer may not: > 1.2.2. sell, rent, lease, sublicense, distribute or lend the Foundation Model to others, in whole or in part, or host the Foundation Model for access or use by others.

> The Foundation Model made available through Hugging Face is intended for internal evaluation purposes and/or demonstration to potential customers only.

jfoster · a year ago
A lot of these AI licenses are a lot more restrictive than old school open source licenses were.

My company runs a bunch of similar web-based services and plan to do a background remover at some stage, but as far as I know there's no current models with a sufficiently permissive license that can also feasibly download & run in browsers.

sangnoir · a year ago
Meta's second Segment Anything Model (SAM2) has an Apache license. It only does segmenting, and needs additional elbow grease to distill it for browsers, so it's not turnkey, but it's freely licensed.
littlestymaar · a year ago
Keep in mind that whether or not a model can be copyrighted at all is still an open question.

Everyone publishing AI model is actually acting as if they owned copyright over it and as such are sharing it with a license, but there's no legal basis for such claim at this point, it's all about pretending and hoping the law will be changed later on to make their claim valid.

NewJazz · a year ago
Train on copyrighted material

Claim fair use

Release model

Claim copyright

Infinite copyright!

Mathnerd314 · a year ago
It is a 2024 model, for comparison https://github.com/danielgatis/rembg/ uses U2-Net which is open source from 2022. There is also https://github.com/ZhengPeng7/BiRefNet (another 2024 model, also open source), it's not too late to switch.
xdennis · a year ago
It's kind of silly to complain about not abiding by the model license when these models are trained on content not explicitly licensed for AI training.

You might say that the models were legally trained since no law mandates consent for AI training. But no law says that models are copyrightable either.

EMIRELADERO · a year ago
AI model weights are probably not even copyrightable.
thenickdude · a year ago
Surely they would at least be protected by Database Rights in the EU (not the US):

>The TRIPS Agreement requires that copyright protection extends to databases and other compilations if they constitute intellectual creation by virtue of the selection or arrangement of their contents, even if some or all of the contents do not themselves constitute materials protected by copyright

https://en.wikipedia.org/wiki/Database_right

Deleted Comment

giancarlostoro · a year ago
At some point the worlds going to need a Richard Stallman of AI who builds up a foundation that is usable and not in the total control of major corporations. With reasonable licensing. OpenAI was supposed to fit that mold.
Laaas · a year ago
The repo doesn’t include the model.
NewJazz · a year ago
Does the site not distribute it?
sva_ · a year ago
It would be cool if it could ask before loading the model, or at least indicate to me how large the download will be, as I'm on a metered connection right now.

But maybe that's just a me-problem.

Loughla · a year ago
After living with satellite Internet as the only option for about 15 years, now that I have fiber, I still catch myself declining downloads that are too big and opening the scheduler.

Old habits die hard.

And the modern Internet implicitly assumes the end user is not on a metered connection. Websites are fucking massive these days.

zamadatix · a year ago
Looks like ~4 MB, I think that's a fair size to not throw up warnings about (unless I'm missing something in the Network view of dev tools w/o cache). That said I wonder what people consider the "Click to enlarge (may take a while to load)" courtesy size to be in 2024.
sva_ · a year ago
> Looks like ~4 MB

You got me!

The model was 176 MB. Total pageload transferred 182 MB.

https://imgur.com/a/6xx3Lgu

It doesn't seem like "Disable cache" in the DevTools empties the Cache Storage.

lynguist · a year ago
I would probably consider 50 MB that size, or in the special case of metered connections 20 MB (for example downloading maps or so).
xnx · a year ago
Great to have local tools. Here's another one that uses the exact same combination of technologies: https://huggingface.co/spaces/Xenova/remove-background-web (Feb 2024)
anduc · a year ago
Exactly this, as mentioned in the post I've used the same technology with this playground (copied lots of code from here) What I do is mostly make the UX better

PS: WebGPU is the future

stavros · a year ago
Nice! This is the model it uses, for anyone curious (it's also mentioned in the description):

https://huggingface.co/briaai/RMBG-1.4

maven29 · a year ago
How does this compare to "segment anything" from Meta
m00x · a year ago
Much smaller and better at background removal, but doesn't segment everything.
ericol · a year ago
The very first image I uploaded (A model lighthouse with a very obvious background) gives just "Error".
dindresto · a year ago
Does your browser support WebGPU? https://webgpu.github.io/webgpu-samples/
anduc · a year ago
The error is ambiguous right now and I'll try to make it clearer (welcome for contributions) The idea is it fallbacks to not use webgpu if your browser is not supported, but it was made in 2 hours, bug is acceptable :)
san_dimitri · a year ago
Thanks for sharing this repo. While I don't have time to actively contribute to the code, I have been testing on images to share my feedback for future devs.

1. Background removal is working good on a lot of different types of images. This includes images with background, plain or white background, men, women, children, hair, and pets.

2. After background removal, the new image is warped in some areas. For example, I have a picture of a child eating ice-cream. The background was removed perfectly but left a lot of artifacts on the child. I can share those images for testing.

Please let me know if there are other areas I can test.

ivolimmen · a year ago
Well gave it 2 tries before giving up. Does not do anything in FireFox and in Chrome it also failed after loading some data. It told me to restart Chrome with some GPU unsafe flag.
anduc · a year ago
Hey there, sorry for the issue, does it show status "Error"? if so can you try to enable WebGPU using this flag "--enable-unsafe-webgpu --enable-features=Vulkan", if not it doesn't seems like a common error and I will spend more time on testing later

Feel free to raise an issue on Github to keep track progress, it helps open source a lot, or you can DM on x.com/duc__an anytime

anduc · a year ago
Someone mentioned > Looks like WEBGPU is only on nightly for FF, for now
hauschildt · a year ago
Hi,

nice work. I recently also published a WebGPU version of our browser-only background removal library. It's using the onnx-runtime under the hood. Weights are from isnet. It could also run birefnet – if there is some interest – however BirefNet weights are almost 1GB in size, which is a bit much to download I guess.

There is a blog post about it and also a CPU only version available.

https://img.ly/blog/browser-background-removal-using-onnx-ru...

Source is available at: https://github.com/imgly/background-removal-js

and on npm: @imgly/background-removal

Feel free to check it out!