GCLing commited on
Commit
6d244f4
·
verified ·
1 Parent(s): 283d228

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -155,16 +155,17 @@ def build_interface():
155
  gr.Markdown("## 多模態情緒分析示例")
156
  with gr.Tabs():
157
  # 臉部 Tab
158
- if has_deepface:
159
- with gr.TabItem("臉部情緒"):
160
- gr.Markdown("### 臉部情緒 (即時 Webcam Streaming 分析)")
161
- with gr.Row():
162
- webcam = gr.components.Camera(streaming=True, type="numpy", label="攝像頭畫面")
163
- face_out = gr.Label(label="情緒分布")
164
- webcam.stream(fn=predict_face, inputs=webcam, outputs=face_out)
165
- else:
166
- with gr.TabItem("臉部情緒 (本地跳过)"):
167
- gr.Markdown("本地未安装 deepface,此功能本地跳过;Space 上可正常运行。")
 
168
 
169
  # 語音 Tab
170
  with gr.TabItem("語音情緒"):
 
155
  gr.Markdown("## 多模態情緒分析示例")
156
  with gr.Tabs():
157
  # 臉部 Tab
158
+ # 臉部 Tab
159
+ if has_deepface:
160
+ with gr.TabItem("臉部情緒"):
161
+ gr.Markdown("### 臉部情緒 (即時 Webcam Streaming 分析)")
162
+ with gr.Row():
163
+ # Video 捕获 Webcam
164
+ webcam = gr.Video(source="webcam", streaming=True, label="攝像頭畫面")
165
+ face_out = gr.Label(label="情緒分布")
166
+ # 这里 Video 返回的是视频流的临时文件或帧流,Gradio 会把每一帧传给 predict_face
167
+ webcam.stream(fn=predict_face, inputs=webcam, outputs=face_out)
168
+
169
 
170
  # 語音 Tab
171
  with gr.TabItem("語音情緒"):