abdullahalioo's picture
Update app.py
db67721 verified
raw
history blame
1.05 kB
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
# Custom CSS to hide Gradio branding and adjust margins
app = gr.Interface(
fn=remove_background,
inputs=gr.components.Image(type='pil'),
outputs=gr.components.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!'
)
# Remove Gradio footer and API options
app.css = """
footer {display: none !important;}
.gradio-container {margin-bottom: 0 !important;}
"""
if __name__ == "__main__":
app.launch(
share=True, # Optional: Remove if you don't need sharing
show_api=False, # Hides the "Use via API" option
show_tips=False # Disables Gradio tips for cleaner UI
)