Sitemap

Remove Image Background in with less than 5 lines of code

mlapi
Jul 31, 2024

In this, we will use rembg python package to remove image background.

from rembg import remove 
from PIL import Image

# load image and process it
inp = Image.open('with-background.jpg')
output = remove(inp)

# save it as .png
output.save('without-background.png')

This will take about 5 to 7 secs to remove background the file.

NOTE - .jpeg or .jpg images will be only saved as .png

--

--

mlapi
mlapi

No responses yet