Jonny001 commited on
Commit
e439db2
β€’
1 Parent(s): 1a08d15

Upload 3 files

Browse files
Files changed (3) hide show
  1. README.md +4 -7
  2. app.py +29 -0
  3. requirements.txt +1 -0
README.md CHANGED
@@ -1,14 +1,11 @@
1
  ---
2
  title: Image Background Remover
3
  emoji: πŸ“‰
4
- colorFrom: yellow
5
- colorTo: purple
6
  sdk: gradio
7
- sdk_version: 5.5.0
8
  app_file: app.py
9
  pinned: false
10
- license: apache-2.0
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