Update app.py
Browse files
app.py
CHANGED
|
@@ -6,8 +6,8 @@ import io, base64, os
|
|
| 6 |
|
| 7 |
PORT = int(os.environ.get("PORT", 7860))
|
| 8 |
|
| 9 |
-
#
|
| 10 |
-
session = new_session("
|
| 11 |
|
| 12 |
def process(image):
|
| 13 |
if image is None:
|
|
@@ -18,7 +18,7 @@ def process(image):
|
|
| 18 |
image.save(buf, format="PNG")
|
| 19 |
input_bytes = buf.getvalue()
|
| 20 |
|
| 21 |
-
# Background removal
|
| 22 |
output_bytes = remove(
|
| 23 |
input_bytes,
|
| 24 |
session=session,
|
|
@@ -28,7 +28,7 @@ def process(image):
|
|
| 28 |
# Bytes → PIL
|
| 29 |
out_img = Image.open(io.BytesIO(output_bytes)).convert("RGBA")
|
| 30 |
|
| 31 |
-
# PIL → base64
|
| 32 |
out_buf = io.BytesIO()
|
| 33 |
out_img.save(out_buf, format="PNG")
|
| 34 |
b64 = base64.b64encode(out_buf.getvalue()).decode()
|
|
@@ -48,7 +48,7 @@ def process(image):
|
|
| 48 |
|
| 49 |
|
| 50 |
with gr.Blocks(
|
| 51 |
-
title="Xlnk Rmbg –
|
| 52 |
css="""
|
| 53 |
body { background:#0b0f19; }
|
| 54 |
h1, h2, p { color:white; }
|
|
@@ -57,9 +57,10 @@ with gr.Blocks(
|
|
| 57 |
|
| 58 |
gr.Markdown("""
|
| 59 |
# ✂️ Xlnk Rmbg
|
| 60 |
-
**
|
| 61 |
|
| 62 |
-
Drag & drop
|
|
|
|
| 63 |
""")
|
| 64 |
|
| 65 |
with gr.Row():
|
|
@@ -76,9 +77,9 @@ with gr.Blocks(
|
|
| 76 |
|
| 77 |
gr.Markdown("""
|
| 78 |
### 🔒 Privacy
|
| 79 |
-
- Images
|
| 80 |
-
- Nothing
|
| 81 |
-
- Open-source
|
| 82 |
""")
|
| 83 |
|
| 84 |
demo.launch(
|
|
|
|
| 6 |
|
| 7 |
PORT = int(os.environ.get("PORT", 7860))
|
| 8 |
|
| 9 |
+
# 🧠 FULL MODEL (not lite)
|
| 10 |
+
session = new_session("u2net")
|
| 11 |
|
| 12 |
def process(image):
|
| 13 |
if image is None:
|
|
|
|
| 18 |
image.save(buf, format="PNG")
|
| 19 |
input_bytes = buf.getvalue()
|
| 20 |
|
| 21 |
+
# Background removal (FULL U²-Net)
|
| 22 |
output_bytes = remove(
|
| 23 |
input_bytes,
|
| 24 |
session=session,
|
|
|
|
| 28 |
# Bytes → PIL
|
| 29 |
out_img = Image.open(io.BytesIO(output_bytes)).convert("RGBA")
|
| 30 |
|
| 31 |
+
# PIL → base64 (auto-download)
|
| 32 |
out_buf = io.BytesIO()
|
| 33 |
out_img.save(out_buf, format="PNG")
|
| 34 |
b64 = base64.b64encode(out_buf.getvalue()).decode()
|
|
|
|
| 48 |
|
| 49 |
|
| 50 |
with gr.Blocks(
|
| 51 |
+
title="Xlnk Rmbg – AI Background Remover",
|
| 52 |
css="""
|
| 53 |
body { background:#0b0f19; }
|
| 54 |
h1, h2, p { color:white; }
|
|
|
|
| 57 |
|
| 58 |
gr.Markdown("""
|
| 59 |
# ✂️ Xlnk Rmbg
|
| 60 |
+
**High-Quality AI Background Removal (U²-Net)**
|
| 61 |
|
| 62 |
+
Drag & drop → preview → auto-download
|
| 63 |
+
No storage. No tracking.
|
| 64 |
""")
|
| 65 |
|
| 66 |
with gr.Row():
|
|
|
|
| 77 |
|
| 78 |
gr.Markdown("""
|
| 79 |
### 🔒 Privacy
|
| 80 |
+
- Images processed in memory
|
| 81 |
+
- Nothing saved
|
| 82 |
+
- Open-source (Rembg + U²-Net)
|
| 83 |
""")
|
| 84 |
|
| 85 |
demo.launch(
|