import gradio as gr from rembg import remove from PIL import Image import io def remove_background(input_image): # Convert the image to bytes img_byte_arr = io.BytesIO() input_image.save(img_byte_arr, format="PNG") img_byte_arr = img_byte_arr.getvalue() # Apply background removal using rembg output_bytes = remove(img_byte_arr) # Convert the output (bytes) back into a PIL image output_image = Image.open(io.BytesIO(output_bytes)) return output_image # Create the Gradio interface 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}" # Hide the footer ) # Launch the Gradio app demo.launch()