File size: 830 Bytes
56a814d f0f5cb9 56a814d f0f5cb9 5187cb0 158eae5 56a814d 5187cb0 56a814d bb4fab0 5187cb0 4a38db1 8dd6bdd bb4fab0 5187cb0 bb4fab0 56a814d 5187cb0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
import gradio as gr
from rembg import remove
from PIL import Image
import io
import spaces
@spaces.GPU(duration=20)
def background_remover(input_image):
output_img = remove(input_image) # Remove the background using the rembg library
# No need to convert to BytesIO, just return the PIL Image object
return output_img
description = """
This app uses the rembg library to remove the background from uploaded images.
Simply upload your image and let the model do its work. Download the result immediately after!
"""
iface = gr.Interface(
fn=background_remover,
inputs=gr.Image(type='pil', label="Upload Image"),
outputs="image",
examples=["woman.jpg", "groot.jpg"],
title="✨ Background Remover",
description=description,
theme="soft"
)
# Launch the interface
iface.launch(share=True)
|