Switch to full style
Open source and other free graphics applications
Post a reply

REMBG - an open source offline usable background removal AI

Mon May 16, 2022 9:20 pm

https://github.com/devlovers-id/sapulatar-qt
https://github.com/danielgatis/rembg

Image

This is my magic tool that banishes the Creative Cloud.

Re: REMBG - an open source offline usable background removal AI

Tue May 17, 2022 2:50 am

This looks interesting. Convert a short clip of a human being walking into a folder of PNGs using ffmpeg. Then use REMBG on every PNG. Then apply a 'make people metal' filter on each PNG so it looks like a robot walking.

Oh that's right you can't because GEGL-graph is not a command line app and its also pretty buggy.

Re: REMBG - an open source offline usable background removal AI

Tue May 17, 2022 8:25 am

You can use and call GEGL in the command line, though.

Re: REMBG - an open source offline usable background removal AI

Tue May 17, 2022 5:55 pm

You can use and call GEGL in the command line, though.


gegl --list-all (the list of filters)
gegl --info gegl:crop (the operations for each filter)
https://gegl.org/operations/ (the online list)

Unfortunately many of the filters and operations don't work in gegl graph. The online list often doesn't work in both gegl graph or gegl cli.
So using gegl cli is like assembly programing.

G'MIC cli is not easy to use but GEGL cli is very hard to use. I have processed a video clip with gegl cli.

Re: REMBG - an open source offline usable background removal AI

Tue May 17, 2022 10:02 pm

I never said it was pretty. And it's even harder, because unlike GMIC, it has absolutely NO (ZERO) documentation, to boot.

Re: REMBG - an open source offline usable background removal AI

Wed May 18, 2022 3:54 am

If anyone is interested gegl lens works pretty good in gegl graph.
Try this:
apply-lens refraction-index=1.4 keep-surroundings=true

Turn the refraction index up or down and change 'keep-surroundings' to false.
I just used it on over 600 frames and all good. It seems to need no alpha channel but as mahvin said 'no manual' :)

Re: REMBG - an open source offline usable background removal AI

Thu May 19, 2022 12:27 am

Installed REMBG and I can say it's not trivial. It uses many python packages to assemble a python-torch-artificial-intelligence stack. Luckily I had a spare hdd and some experience with neural networks.

On Ubuntu 'jammy' I had to install an earlier python 3.9. Then you need a 'model' file from a google drive and the developers git page has a command to remove the background from a png and it doesn't work.
Anyway it can be made to work. This is my first attempt with a difficult image.

Image

Image

That's pretty cool I think. I didn't use the gui 'sapulatar-qt' because I don't think I need it. I will try this on a png vid series.

Re: REMBG - an open source offline usable background removal AI

Thu May 19, 2022 4:46 am

I've been playing with rembg as well. It's not perfect, but pretty darn good just the same...

in.jpg
in.jpg (253.41 KiB) Viewed 8341 times


out.png
out.png (708.23 KiB) Viewed 8341 times

Re: REMBG - an open source offline usable background removal AI

Thu May 19, 2022 9:03 am

A while ago I've posted my rembg setup on gimp-forum.net using anaconda here
https://www.gimp-forum.net/Thread-Remov ... 4#pid22354.
It's done on a linux mint machine. Still runs fine, have to use the nouveau graphics driver though as the nvidia one throws errors. But I can live with that.

Re: REMBG - an open source offline usable background removal AI

Thu May 19, 2022 7:21 pm

Hi racer-x. That rembg worked very well on the bird. I like the way it included a branch in the foreground.

Hi nelo. Interesting what you did with anaconda. Here is a simple script that does all the PNGs in a folder and puts them in a subfolder.

Code:
#!/bin/bash
mkdir ./done
rembg --p ./ ./done/


Save as 'REMBGfolder.sh' make it exe and run like this: ./REMBGfolder.sh

rembg gives a nice progress bar when running the script. On this box it tells me it's using python 3.10 but it still works OK. Some edges are a bit fuzzy and it misses content here and there but it's possible to enhance the images first. It's surprisingly fast as well. :)

Re: REMBG - an open source offline usable background removal AI

Fri May 20, 2022 4:36 am

Thanks Tas for posting the batch script. It doesn't work here as it is written, but this edited one does.
Code:
#!/bin/bash
mkdir ./done
rembg p ./ ./done/

Re: REMBG - an open source offline usable background removal AI

Sat May 21, 2022 3:51 am

Hi racer, the P (path) seems different on different systems. I experimented a bit today. I installed anaconda following nelo's excellent instructions. Its good to have a python in your local directory and turn it on and off. I went back to the original because it works the same. This system seems to be using python 3.10 and its backward compatible. (so far)

I tried a different 'model' that I got from here. Looks like the models are quite targetted. I tried the 'human segment' model that is probably good for human forms but not so good for hair. There are also 'portrait' and 'cloth' models that I haven't used. They all go in /.u2net/

This is the batch script I used for the models.

Code:
#!/bin/bash
mkdir ./done
rembg -m u2net_human_seg -p ./ ./done/


You will have to change the 'p' to suit your system.

Re: REMBG - an open source offline usable background removal AI

Sat May 21, 2022 7:01 pm

Trying to choose a model file that suits the content. This surfer girl clip is matched with the human segment model file. I did over 600 frames and not all are top quality but here is what it can do.

Image

Image
Post a reply