Spaces:
Sleeping
Sleeping
| from rembg import remove | |
| from PIL import Image | |
| import io | |
| import gradio as gr | |
| def remove_bg(image): | |
| img_bytes = io.BytesIO() | |
| image.save(img_bytes, format="PNG") | |
| img_bytes = img_bytes.getvalue() | |
| result = remove(img_bytes) | |
| return Image.open(io.BytesIO(result)) | |
| app = gr.Interface( | |
| fn=remove_bg, | |
| inputs=gr.Image(type="pil", label="Upload Image"), | |
| outputs=gr.Image(type="pil", label="Background Removed"), | |
| title="🧹 Free Background Remover", | |
| description="Upload an image and remove the background instantly for free!", | |
| ) | |
| # launch the gradio app normally (API will auto-exist at /api/predict/) | |
| app.launch(server_name="0.0.0.0", server_port=7860) | |