Spaces:
Runtime error
Runtime error
Commit
·
a943db9
1
Parent(s):
9433c3a
Added secrets
Browse files
app.py
CHANGED
@@ -8,6 +8,7 @@ import io
|
|
8 |
import json
|
9 |
from numba import jit
|
10 |
import matplotlib.pyplot as plt
|
|
|
11 |
|
12 |
|
13 |
examples = ["examples/0002_01_00_01_55.jpg",
|
@@ -21,10 +22,10 @@ examples = ["examples/0002_01_00_01_55.jpg",
|
|
21 |
|
22 |
|
23 |
async def spoof_trigger(b64):
|
24 |
-
url =
|
25 |
payload = {"img": b64}
|
26 |
headers = {
|
27 |
-
'x-functions-key': '
|
28 |
'Content-Type': 'text/plain'
|
29 |
}
|
30 |
|
@@ -57,16 +58,16 @@ async def predict_image(img):
|
|
57 |
# print(json.loads(res))
|
58 |
spoof_res = json.loads(res)['spoof_res']
|
59 |
annotated_image = json.loads(res)['annotated_image']
|
60 |
-
conf_score = float( json.loads(spoof_res)['
|
61 |
|
62 |
# img_base64 to plot
|
63 |
img = Image.open(io.BytesIO(base64.b64decode(annotated_image)))
|
64 |
# img save
|
65 |
-
img.save("cache/img.jpg")
|
66 |
|
67 |
-
confidences = {'Real':
|
68 |
|
69 |
-
return (confidences,
|
70 |
|
71 |
|
72 |
with gr.Blocks(title="Spoof-Demo", css="#custom_header {min-height: 3rem; text-align: center} #custom_title {min-height: 3rem; text-align: center}") as demo :
|
|
|
8 |
import json
|
9 |
from numba import jit
|
10 |
import matplotlib.pyplot as plt
|
11 |
+
import os
|
12 |
|
13 |
|
14 |
examples = ["examples/0002_01_00_01_55.jpg",
|
|
|
22 |
|
23 |
|
24 |
async def spoof_trigger(b64):
|
25 |
+
url = os.getenv('url')
|
26 |
payload = {"img": b64}
|
27 |
headers = {
|
28 |
+
'x-functions-key': os.getenv('token'),
|
29 |
'Content-Type': 'text/plain'
|
30 |
}
|
31 |
|
|
|
58 |
# print(json.loads(res))
|
59 |
spoof_res = json.loads(res)['spoof_res']
|
60 |
annotated_image = json.loads(res)['annotated_image']
|
61 |
+
conf_score = float( json.loads(spoof_res)['confidence_score2'])
|
62 |
|
63 |
# img_base64 to plot
|
64 |
img = Image.open(io.BytesIO(base64.b64decode(annotated_image)))
|
65 |
# img save
|
66 |
+
# img.save("cache/img.jpg")
|
67 |
|
68 |
+
confidences = {'Real': conf_score, 'Fake': 1-conf_score}
|
69 |
|
70 |
+
return (confidences,img)
|
71 |
|
72 |
|
73 |
with gr.Blocks(title="Spoof-Demo", css="#custom_header {min-height: 3rem; text-align: center} #custom_title {min-height: 3rem; text-align: center}") as demo :
|