Spaces:
Running
Running
Upload 3 files
Browse files- README.md +14 -0
- app.py +37 -0
- requirements.txt +4 -0
README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
title: RMBG
|
3 |
+
emoji: 🪄
|
4 |
+
colorFrom: green
|
5 |
+
colorTo: yellow
|
6 |
+
sdk: gradio
|
7 |
+
sdk_version: 5.9.1
|
8 |
+
app_file: app.py
|
9 |
+
pinned: false
|
10 |
+
license: creativeml-openrail-m
|
11 |
+
header: mini
|
12 |
+
---
|
13 |
+
|
14 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
app.py
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from rembg import remove
|
3 |
+
|
4 |
+
# Custom CSS for styling
|
5 |
+
css = '''
|
6 |
+
.gradio-container { max-width: 1200px !important; }
|
7 |
+
h1 { text-align: center; }
|
8 |
+
footer { visibility: hidden; }
|
9 |
+
'''
|
10 |
+
|
11 |
+
# Function to remove background
|
12 |
+
def segment(image):
|
13 |
+
"""
|
14 |
+
Removes the background from the input image.
|
15 |
+
|
16 |
+
Args:
|
17 |
+
image: An image file uploaded by the user.
|
18 |
+
|
19 |
+
Returns:
|
20 |
+
The image with its background removed.
|
21 |
+
"""
|
22 |
+
return remove(image)
|
23 |
+
|
24 |
+
# Gradio Interface
|
25 |
+
demo = gr.Interface(
|
26 |
+
fn=segment,
|
27 |
+
inputs=gr.Image(label="Input Image", interactive=True),
|
28 |
+
outputs=gr.Image(label="Result Image"),
|
29 |
+
title="RMBG",
|
30 |
+
description="Upload an image to remove its background automatically!",
|
31 |
+
css=css,
|
32 |
+
theme="bethecloud/storj_theme" # Ensure this theme is available or remove it
|
33 |
+
)
|
34 |
+
|
35 |
+
# Launch the app
|
36 |
+
if __name__ == "__main__":
|
37 |
+
demo.launch(show_api=False)
|
requirements.txt
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
gradio
|
2 |
+
rembg
|
3 |
+
onnxruntime
|
4 |
+
pillow
|