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)