File size: 596 Bytes
5d86a34
3b2f5a6
 
 
5d86a34
3b2f5a6
 
 
5d86a34
 
 
 
 
 
 
3b2f5a6
7443e37
5d86a34
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import gradio as gr
from deepface import DeepFace

def analyze_frame(frame):
    # frame: numpy array from webcam
    result = DeepFace.analyze(frame, actions=['emotion'], enforce_detection=False)
    return result['dominant_emotion']

iface = gr.Interface(
    fn=analyze_frame,
    inputs=gr.Image(source="webcam", type="numpy", label="請對準你的臉"),
    outputs="text",
    title="📱 手機瀏覽器即時臉部情緒分析",
    live=True
)

if __name__=="__main__":
    # 运行在 0.0.0.0:7860,Spaces 会转到 HTTPS 443
    iface.launch(server_name="0.0.0.0", server_port=7860)