Skip to content

Instantly share code, notes, and snippets.

@alonsoir
Created August 26, 2024 17:10
Show Gist options
  • Save alonsoir/f9493d323b256e167f7040fffdb2f9e4 to your computer and use it in GitHub Desktop.
Save alonsoir/f9493d323b256e167f7040fffdb2f9e4 to your computer and use it in GitHub Desktop.
from rembg import remove
from PIL import Image
## Path for input and output image
input_img = 'spiderman_with_bg.jpeg'
output_img = 'spiderman_without_bg.png'
## loading and removing background
inp = Image.open(input_img)
output = remove(inp)
## Saving background removed image to same location as input image
output.save(output_img)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment