Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1294

Python • TIL: remove image background with rembg

$
0
0
Saw this on twitter and tried:
https://twitter.com/Raynerdwebsdev/stat ... 0965515372

I used crop of fullscreen screenshot as input (test.png):
test.png

Then did install rembg:

Code:

~/venv/bin/pip install rembg
And used it:

Code:

pi@raspberrypi5:~ $ ~/venv/bin/python rembg_demo.py test.png pi@raspberrypi5:~ $ cat rembg_demo.py from rembg import removefrom PIL import Imagefrom sys import argvinput = Image.open(argv[1])output = remove(input)output.save("_"+argv[1])pi@raspberrypi5:~ $ 

Result is "_test.png":
_test.png

Statistics: Posted by HermannSW — Fri Apr 12, 2024 8:28 am



Viewing all articles
Browse latest Browse all 1294

Trending Articles