import gradio as gr from transformers import pipeline from PIL import Image def remove_background(image): pipe = pipeline('image-segmentation', model='briaai/RMBG-1.4', trust_remote_code=True) pillow_mask = pipe(image, return_mask=True) pillow_image = pipe(image) return pillow_image # Create interface app = gr.Interface( fn=remove_background, inputs=gr.Image(type='pil'), outputs=gr.Image(type='pil', format='png'), title='Remove image background', description='Remove backgrounds from photos automatically in seconds - 100% free, no watermarks, works on any device!' ) # CSS to hide footer and adjust margins app.css = """ footer {visibility: hidden !important;} .gr-footer {display: none !important;} .gradio-container {margin-bottom: 0 !important;} """ # Launch with minimal options if __name__ == "__main__": app.launch(share=True)