Spaces:
Runtime error
Runtime error
first commit
Browse files
app.py
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import shutil
|
2 |
+
import gradio as gr
|
3 |
+
from PIL import Image
|
4 |
+
import sys, os
|
5 |
+
from rembg import remove
|
6 |
+
|
7 |
+
|
8 |
+
def run_rembg(img):
|
9 |
+
output = remove(img)
|
10 |
+
return output
|
11 |
+
|
12 |
+
|
13 |
+
if __name__=="__main__":
|
14 |
+
|
15 |
+
|
16 |
+
with gr.Blocks() as demo:
|
17 |
+
|
18 |
+
gr.Markdown(
|
19 |
+
"""
|
20 |
+
<center><h1>Image Matting using U<sup>2</sup>-Net</h1></center>
|
21 |
+
"""
|
22 |
+
)
|
23 |
+
with gr.Row():
|
24 |
+
with gr.Column():
|
25 |
+
gr.Markdown(
|
26 |
+
"""
|
27 |
+
Input Image
|
28 |
+
"""
|
29 |
+
)
|
30 |
+
image_input = gr.Image(type="numpy", label=" ")
|
31 |
+
with gr.Column():
|
32 |
+
gr.Markdown(
|
33 |
+
"""
|
34 |
+
Output Image
|
35 |
+
"""
|
36 |
+
)
|
37 |
+
image_output = gr.Image(type="numpy", label=" ")
|
38 |
+
|
39 |
+
btn = gr.Button("Run!")
|
40 |
+
|
41 |
+
btn.click(
|
42 |
+
fn=run_rembg,
|
43 |
+
inputs=image_input,
|
44 |
+
outputs=image_output,
|
45 |
+
api_name="imageMatting"
|
46 |
+
)
|
47 |
+
|
48 |
+
gr.Markdown(
|
49 |
+
"""
|
50 |
+
---
|
51 |
+
<b>Acknowledgments</b>
|
52 |
+
- Library
|
53 |
+
- Library Git hub : [danielgatis/rembg](https://github.com/danielgatis/rembg)
|
54 |
+
- Cloned on 2023/3/12
|
55 |
+
- Algorithm
|
56 |
+
- Library Git hub : [U<sup>2</sup>-Net](https://github.com/xuebinqin/U-2-Net)
|
57 |
+
|
58 |
+
"""
|
59 |
+
)
|
60 |
+
|
61 |
+
demo.launch(
|
62 |
+
favicon_path="./assets/ハサミのフリーアイコン.png"
|
63 |
+
)
|
assets//343/203/217/343/202/265/343/203/237/343/201/256/343/203/225/343/203/252/343/203/274/343/202/242/343/202/244/343/202/263/343/203/263.png
ADDED
![]() |
requirements.txt
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
aiofiles==23.1.0
|
2 |
+
aiohttp==3.8.4
|
3 |
+
aiosignal==1.3.1
|
4 |
+
altair==4.2.2
|
5 |
+
anyio==3.6.2
|
6 |
+
appdirs==1.4.4
|
7 |
+
async-timeout==4.0.2
|
8 |
+
asyncer==0.0.2
|
9 |
+
attrs==22.2.0
|
10 |
+
blessed==1.20.0
|
11 |
+
certifi==2022.12.7
|
12 |
+
charset-normalizer==3.1.0
|
13 |
+
click==8.1.3
|
14 |
+
codefind==0.1.3
|
15 |
+
coloredlogs==15.0.1
|
16 |
+
contourpy==1.0.7
|
17 |
+
cycler==0.11.0
|
18 |
+
entrypoints==0.4
|
19 |
+
fastapi==0.87.0
|
20 |
+
ffmpy==0.3.0
|
21 |
+
filetype==1.2.0
|
22 |
+
flatbuffers==23.3.3
|
23 |
+
fonttools==4.39.0
|
24 |
+
frozenlist==1.3.3
|
25 |
+
fsspec==2023.3.0
|
26 |
+
gradio==3.20.1
|
27 |
+
h11==0.14.0
|
28 |
+
httpcore==0.16.3
|
29 |
+
httpx==0.23.3
|
30 |
+
humanfriendly==10.0
|
31 |
+
idna==3.4
|
32 |
+
ImageHash==4.3.1
|
33 |
+
imageio==2.26.0
|
34 |
+
importlib-resources==5.12.0
|
35 |
+
Jinja2==3.1.2
|
36 |
+
jsonschema==4.17.3
|
37 |
+
jurigged==0.5.5
|
38 |
+
kiwisolver==1.4.4
|
39 |
+
lazy_loader==0.1
|
40 |
+
linkify-it-py==2.0.0
|
41 |
+
llvmlite==0.39.1
|
42 |
+
markdown-it-py==2.2.0
|
43 |
+
MarkupSafe==2.1.2
|
44 |
+
matplotlib==3.7.1
|
45 |
+
mdit-py-plugins==0.3.3
|
46 |
+
mdurl==0.1.2
|
47 |
+
mpmath==1.3.0
|
48 |
+
multidict==6.0.4
|
49 |
+
networkx==3.0
|
50 |
+
numba==0.56.4
|
51 |
+
numpy==1.23.5
|
52 |
+
onnxruntime==1.13.1
|
53 |
+
opencv-python-headless==4.6.0.66
|
54 |
+
orjson==3.8.7
|
55 |
+
ovld==0.3.2
|
56 |
+
packaging==23.0
|
57 |
+
pandas==1.5.3
|
58 |
+
Pillow==9.3.0
|
59 |
+
pooch==1.6.0
|
60 |
+
protobuf==4.22.1
|
61 |
+
pycryptodome==3.17
|
62 |
+
pydantic==1.10.6
|
63 |
+
pydub==0.25.1
|
64 |
+
PyMatting==1.1.8
|
65 |
+
pyparsing==3.0.9
|
66 |
+
pyrsistent==0.19.3
|
67 |
+
python-dateutil==2.8.2
|
68 |
+
python-multipart==0.0.6
|
69 |
+
pytz==2022.7.1
|
70 |
+
PyWavelets==1.4.1
|
71 |
+
PyYAML==6.0
|
72 |
+
rembg==2.0.30
|
73 |
+
requests==2.28.2
|
74 |
+
rfc3986==1.5.0
|
75 |
+
scikit-image==0.19.3
|
76 |
+
scipy==1.9.3
|
77 |
+
six==1.16.0
|
78 |
+
sniffio==1.3.0
|
79 |
+
starlette==0.21.0
|
80 |
+
sympy==1.11.1
|
81 |
+
tifffile==2023.2.28
|
82 |
+
toolz==0.12.0
|
83 |
+
torch==1.13.1
|
84 |
+
torchvision==0.14.1
|
85 |
+
tqdm==4.64.1
|
86 |
+
typing_extensions==4.5.0
|
87 |
+
uc-micro-py==1.0.1
|
88 |
+
urllib3==1.26.15
|
89 |
+
uvicorn==0.20.0
|
90 |
+
watchdog==2.1.9
|
91 |
+
wcwidth==0.2.6
|
92 |
+
websockets==10.4
|
93 |
+
yarl==1.8.2
|
94 |
+
zipp==3.15.0
|