Created
October 13, 2023 19:25
-
-
Save cristianmenghi/393f170ae9e9baad7005318898fc5273 to your computer and use it in GitHub Desktop.
Remove background
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
from rembg import remove # pip install rembg | |
from PIL import Image | |
def main(): | |
parser = argparse.ArgumentParser(description="Remove background from an image using rembg") | |
parser.add_argument("input_path", help="Input image file path") | |
parser.add_argument("output_path", help="Output image file path") | |
args = parser.parse_args() | |
input_path = args.input_path | |
output_path = args.output_path | |
inp = Image.open(input_path) | |
output = remove(inp) | |
output.save(output_path) | |
print(f"Background removed and saved to {output_path}") | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment