Spaces:
Running
Running
tomas-gajarsky
commited on
Commit
·
899c524
1
Parent(s):
8f4f456
Update app.py
Browse files
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import gradio as gr
|
2 |
import torchvision
|
3 |
from facetorch import FaceAnalyzer
|
@@ -17,9 +18,14 @@ def inference(path_image):
|
|
17 |
include_tensors=cfg.include_tensors,
|
18 |
path_output=None,
|
19 |
)
|
|
|
20 |
pil_image = torchvision.transforms.functional.to_pil_image(response.img)
|
21 |
|
22 |
-
|
|
|
|
|
|
|
|
|
23 |
return out_tuple
|
24 |
|
25 |
|
@@ -30,7 +36,10 @@ article = "<p style='text-align: center'><a href='https://github.com/tomas-gajar
|
|
30 |
demo=gr.Interface(
|
31 |
inference,
|
32 |
[gr.inputs.Image(label="Input", type="filepath")],
|
33 |
-
[gr.outputs.Image(type="pil", label="Output"),
|
|
|
|
|
|
|
34 |
title=title,
|
35 |
description=description,
|
36 |
article=article,
|
|
|
1 |
+
import json
|
2 |
import gradio as gr
|
3 |
import torchvision
|
4 |
from facetorch import FaceAnalyzer
|
|
|
18 |
include_tensors=cfg.include_tensors,
|
19 |
path_output=None,
|
20 |
)
|
21 |
+
|
22 |
pil_image = torchvision.transforms.functional.to_pil_image(response.img)
|
23 |
|
24 |
+
fer_dict_str = str({face.indx: face.preds["fer"].label for face in response.faces})
|
25 |
+
deepfake_dict_str = str({face.indx: face.preds["deepfake"].label for face in response.faces})
|
26 |
+
response_str = str(response)
|
27 |
+
|
28 |
+
out_tuple = (pil_image, fer_dict_str, deepfake_dict_str, response_str)
|
29 |
return out_tuple
|
30 |
|
31 |
|
|
|
36 |
demo=gr.Interface(
|
37 |
inference,
|
38 |
[gr.inputs.Image(label="Input", type="filepath")],
|
39 |
+
[gr.outputs.Image(type="pil", label="Output"),
|
40 |
+
gr.outputs.Textbox(label="Facial Expression Recognition"),
|
41 |
+
gr.outputs.Textbox(label="DeepFake Detection"),
|
42 |
+
gr.outputs.Textbox(label="Response")],
|
43 |
title=title,
|
44 |
description=description,
|
45 |
article=article,
|