Member-only story
Remove photo background by Python
Nov 28, 2022
Here is a simple way to remove the background of an image.
Requirements
python: >3.7, <3.11Installation
CPU support:
pip install rembgGPU support:
pip install rembg[gpu]Main code here:
Press enter or click to view image in full size![]()
from rembg import remove
from PIL import Image
input= "source.jpg"
out = "out.png"
Im = Image.open(input)
Out = remove(Im)
Out.save(out)Press enter or click to view image in full size![]()
Enjoy!
