Ramzan0553's picture
Create app.py
59dba31 verified
raw
history blame contribute delete
654 Bytes
import gradio as gr
from rembg import remove
from PIL import Image
import numpy as np
def remove_bg(input_image):
if input_image is None:
return None
input_image = Image.open(input_image).convert("RGBA") # Ensure RGBA format
output_image = remove(input_image) # Remove background
return output_image
iface = gr.Interface(
fn=remove_bg,
inputs=gr.Image(type="filepath", label="Upload an Image"),
outputs=gr.Image(type="pil", label="Background Removed Image"),
title="AI Background Remover",
description="Upload an image, and this tool will remove the background automatically.",
)
iface.launch(share=True)