Spaces:
Build error
Build error
yangwu
commited on
Commit
•
0ba02e5
1
Parent(s):
7130bbb
add app.py
Browse files
app.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import requests
|
3 |
+
|
4 |
+
|
5 |
+
def predict(name):
|
6 |
+
url = 'http://81.70.158.155:5005/predict'
|
7 |
+
with open(img, 'rb') as f:
|
8 |
+
r = requests.post(url, files = {'image' : f})
|
9 |
+
ret = json.loads(r.text)
|
10 |
+
|
11 |
+
# image level cls score
|
12 |
+
pred_cls_score = ret['cls_score']
|
13 |
+
pred_seg = json.loads(ret['result'])
|
14 |
+
pred_seg = np.array(pred_seg, dtype=np.uint8)
|
15 |
+
|
16 |
+
return pred_seg
|
17 |
+
|
18 |
+
|
19 |
+
|
20 |
+
gr.Interface(
|
21 |
+
predict,
|
22 |
+
inputs=gr.inputs.Image(label="Upload image to detect", type="filepath"),
|
23 |
+
outputs='image',
|
24 |
+
title="Forged? Or Not?",
|
25 |
+
).launch()
|