Spaces:
Runtime error
Runtime error
Switch to gr.Interface webcam version
Browse files
app.py
CHANGED
@@ -1,15 +1,19 @@
|
|
1 |
-
|
2 |
from deepface import DeepFace
|
3 |
|
4 |
def analyze_frame(frame):
|
|
|
5 |
result = DeepFace.analyze(frame, actions=['emotion'], enforce_detection=False)
|
6 |
return result['dominant_emotion']
|
7 |
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
13 |
|
14 |
if __name__=="__main__":
|
15 |
-
|
|
|
|
1 |
+
import gradio as gr
|
2 |
from deepface import DeepFace
|
3 |
|
4 |
def analyze_frame(frame):
|
5 |
+
# frame: numpy array from webcam
|
6 |
result = DeepFace.analyze(frame, actions=['emotion'], enforce_detection=False)
|
7 |
return result['dominant_emotion']
|
8 |
|
9 |
+
iface = gr.Interface(
|
10 |
+
fn=analyze_frame,
|
11 |
+
inputs=gr.Image(source="webcam", type="numpy", label="θ«ε°ζΊδ½ ηθ"),
|
12 |
+
outputs="text",
|
13 |
+
title="π± ζζ©η覽ε¨ε³ζθι¨ζ
η·εζ",
|
14 |
+
live=True
|
15 |
+
)
|
16 |
|
17 |
if __name__=="__main__":
|
18 |
+
# θΏθ‘ε¨ 0.0.0.0:7860οΌSpaces δΌθ½¬ε° HTTPS 443
|
19 |
+
iface.launch(server_name="0.0.0.0", server_port=7860)
|