Spaces:
Running
on
Zero
Running
on
Zero
amirgame197
commited on
Commit
•
ba4d1a9
1
Parent(s):
fead55d
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,35 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
return "Hello " + name + "!!"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
iface = gr.Interface(fn=
|
7 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
import cv2
|
3 |
+
import numpy as np
|
4 |
|
5 |
+
from PIL import Image
|
6 |
+
from transparent_background import Remover
|
7 |
+
|
8 |
+
# Load model
|
9 |
+
remover = Remover() # default setting
|
10 |
+
remover = Remover(mode='fast', jit=True, device='cuda:0', ckpt='~/latest.pth') # custom setting
|
11 |
+
remover = Remover(mode='base-nightly') # nightly release checkpoint
|
12 |
+
|
13 |
+
# Usage for image
|
14 |
+
|
15 |
+
|
16 |
+
|
17 |
+
def doo(image):
|
18 |
return "Hello " + name + "!!"
|
19 |
+
img = Image.fromarray(image).convert('RGB') # read image
|
20 |
+
out = remover.process(img) # default setting - transparent background
|
21 |
+
out = remover.process(img, type='rgba') # same as above
|
22 |
+
out = remover.process(img, type='map') # object map only
|
23 |
+
out = remover.process(img, type='green') # image matting - green screen
|
24 |
+
out = remover.process(img, type='white') # change backround with white color
|
25 |
+
out = remover.process(img, type=[255, 0, 0]) # change background with color code [255, 0, 0]
|
26 |
+
out = remover.process(img, type='blur') # blur background
|
27 |
+
out = remover.process(img, type='overlay') # overlay object map onto the image
|
28 |
+
out = remover.process(img, type='samples/background.jpg') # use another image as a background
|
29 |
+
|
30 |
+
out = remover.process(img, threshold=0.5) # use threhold parameter for hard prediction.
|
31 |
+
|
32 |
+
out.save('output.png') # save result
|
33 |
|
34 |
+
iface = gr.Interface(fn=doo, inputs="image", outputs="image")
|
35 |
iface.launch()
|