| | import gradio as gr |
| | from rembg import remove |
| | from PIL import Image |
| | import io |
| |
|
| | def remove_background(input_image): |
| | |
| | img_byte_arr = io.BytesIO() |
| | input_image.save(img_byte_arr, format="PNG") |
| | img_byte_arr = img_byte_arr.getvalue() |
| |
|
| | |
| | output_bytes = remove(img_byte_arr) |
| |
|
| | |
| | output_image = Image.open(io.BytesIO(output_bytes)) |
| | return output_image |
| |
|
| | |
| | demo = gr.Interface( |
| | fn=remove_background, |
| | inputs=gr.Image(type="pil", label="Upload an image or Use Camera",sources="upload"), |
| | outputs=gr.Image(label="Processed Image",show_share_button=False, show_fullscreen_button=False), |
| | css="footer {visibility: hidden}" |
| | ) |
| |
|
| | |
| | demo.launch() |