Upload 3 files
Browse files- README.md +4 -7
- app.py +29 -0
- requirements.txt +1 -0
README.md
CHANGED
|
@@ -1,14 +1,11 @@
|
|
| 1 |
---
|
| 2 |
title: Image Background Remover
|
| 3 |
emoji: 📉
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
-
license:
|
| 11 |
-
short_description: Give you Best result
|
| 12 |
---
|
| 13 |
-
|
| 14 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
|
| 1 |
---
|
| 2 |
title: Image Background Remover
|
| 3 |
emoji: 📉
|
| 4 |
+
colorFrom: gray
|
| 5 |
+
colorTo: red
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.36.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
+
license: mit
|
|
|
|
| 11 |
---
|
|
|
|
|
|
app.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import spaces
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from transparent_background import Remover
|
| 4 |
+
from PIL import Image
|
| 5 |
+
import numpy as np
|
| 6 |
+
|
| 7 |
+
@spaces.GPU
|
| 8 |
+
def remove_background(image):
|
| 9 |
+
remover = Remover()
|
| 10 |
+
if isinstance(image, Image.Image):
|
| 11 |
+
output = remover.process(image)
|
| 12 |
+
elif isinstance(image, np.ndarray):
|
| 13 |
+
image_pil = Image.fromarray(image)
|
| 14 |
+
output = remover.process(image_pil)
|
| 15 |
+
else:
|
| 16 |
+
raise TypeError("Unsupported image type")
|
| 17 |
+
return output
|
| 18 |
+
|
| 19 |
+
iface = gr.Interface(
|
| 20 |
+
fn=remove_background,
|
| 21 |
+
inputs=gr.Image(label="Upload Image"),
|
| 22 |
+
outputs=gr.Image(label="Output Image"),
|
| 23 |
+
title="Image Background Remover",
|
| 24 |
+
description="Sorry for the inconvenience. The model is currently running on the CPU, which might affect performance. We appreciate your understanding.",
|
| 25 |
+
theme="Yntec/HaleyCH_Theme_Orange"
|
| 26 |
+
)
|
| 27 |
+
|
| 28 |
+
if __name__ == "__main__":
|
| 29 |
+
iface.launch()
|
requirements.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
transparent-background
|