import gradio as gr from rembg import remove from PIL import Image def remove_bg(image_path): if image_path is None: return None image = Image.open(image_path) # ✅ Open the image from the file path output = remove(image) return output # Creating Gradio interface iface = gr.Interface( fn=remove_bg, inputs=gr.Image(type="filepath"), # ✅ Make sure Gradio passes the file path outputs=gr.Image(type="pil"), title="AI Background Remover", description="Upload an image and remove its background automatically!", ) iface.launch()