Commit
·
89467ee
1
Parent(s):
6b29f91
Upload app.py
Browse files
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
os.system("/usr/local/bin/python -m pip install --upgrade pip")
|
3 |
+
import gradio as gr
|
4 |
+
from rembg import remove
|
5 |
+
import cv2
|
6 |
+
|
7 |
+
def inference(img):
|
8 |
+
input_img = cv2.imread(img)
|
9 |
+
output = remove(input_img[:, :, [2,1,0]])
|
10 |
+
return output
|
11 |
+
|
12 |
+
title = "照片去背景App"
|
13 |
+
|
14 |
+
description = "上传需要去背景的图片,点击Submit,稍等片刻,右侧Output将去背景后的主体另存为即可。"
|
15 |
+
|
16 |
+
article = "<p style='text-align: center'><a href='https://mp.weixin.qq.com/s?__biz=MzA4MjYwMTc5Nw==&mid=2648966119&idx=1&sn=c086db1ff0293b32e539dd5df7159e22&chksm=879391cdb0e418dbacb9fae512019d00921f9a9c96b495e2d1c37b930698abc0757d4df0a15d&token=474570519&lang=zh_CN#rd' target='_blank'>关注我的公众号,学习更多</a></p><center><img src='https://api.visitorbadge.io/api/visitors?path=https%3A%2F%2Fwww.github.com%2Ftjxj%2Fgithub-visitor-badge&countColor=%23263759' alt='visitor badge'></center>"
|
17 |
+
|
18 |
+
|
19 |
+
gr.Interface(
|
20 |
+
inference,
|
21 |
+
gr.inputs.Image(type="filepath", label="Input"),
|
22 |
+
gr.outputs.Image(type="pil", label="Output"),
|
23 |
+
title=title,
|
24 |
+
description=description,
|
25 |
+
article=article
|
26 |
+
).launch()
|