Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,18 +3,29 @@ from transformers import pipeline
|
|
| 3 |
from PIL import Image
|
| 4 |
|
| 5 |
def remove_background(image):
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
|
|
|
|
| 11 |
app = gr.Interface(
|
| 12 |
-
fn=
|
| 13 |
-
inputs=
|
| 14 |
-
outputs=
|
| 15 |
-
title=
|
| 16 |
-
description=
|
| 17 |
)
|
| 18 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
if __name__ == "__main__":
|
| 20 |
-
app.launch(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
from PIL import Image
|
| 4 |
|
| 5 |
def remove_background(image):
|
| 6 |
+
pipe = pipeline('image-segmentation', model='briaai/RMBG-1.4', trust_remote_code=True)
|
| 7 |
+
pillow_mask = pipe(image, return_mask=True)
|
| 8 |
+
pillow_image = pipe(image)
|
| 9 |
+
return pillow_image
|
| 10 |
|
| 11 |
+
# Custom CSS to hide Gradio branding and adjust margins
|
| 12 |
app = gr.Interface(
|
| 13 |
+
fn=remove_background,
|
| 14 |
+
inputs=gr.components.Image(type='pil'),
|
| 15 |
+
outputs=gr.components.Image(type='pil', format='png'),
|
| 16 |
+
title='Remove image background',
|
| 17 |
+
description='Remove backgrounds from photos automatically in seconds - 100% free, no watermarks, works on any device!'
|
| 18 |
)
|
| 19 |
|
| 20 |
+
# Remove Gradio footer and API options
|
| 21 |
+
app.css = """
|
| 22 |
+
footer {display: none !important;}
|
| 23 |
+
.gradio-container {margin-bottom: 0 !important;}
|
| 24 |
+
"""
|
| 25 |
+
|
| 26 |
if __name__ == "__main__":
|
| 27 |
+
app.launch(
|
| 28 |
+
share=True, # Optional: Remove if you don't need sharing
|
| 29 |
+
show_api=False, # Hides the "Use via API" option
|
| 30 |
+
show_tips=False # Disables Gradio tips for cleaner UI
|
| 31 |
+
)
|