Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,19 @@
|
|
1 |
import spaces
|
2 |
import gradio as gr
|
3 |
from transparent_background import Remover
|
|
|
|
|
4 |
|
5 |
@spaces.GPU
|
6 |
def remove_background(image):
|
7 |
remover = Remover()
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
return output
|
10 |
|
11 |
iface = gr.Interface(
|
@@ -17,4 +25,4 @@ iface = gr.Interface(
|
|
17 |
)
|
18 |
|
19 |
if __name__ == "__main__":
|
20 |
-
iface.launch()
|
|
|
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(
|
|
|
25 |
)
|
26 |
|
27 |
if __name__ == "__main__":
|
28 |
+
iface.launch()
|