GCLing commited on
Commit
034eede
·
verified ·
1 Parent(s): 6d244f4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -154,17 +154,19 @@ def build_interface():
154
  with gr.Blocks() as demo:
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
 
154
  with gr.Blocks() as demo:
155
  gr.Markdown("## 多模態情緒分析示例")
156
  with gr.Tabs():
157
+ # 臉部 Tab,仅当 has_deepface=True 时显示
158
+ if has_deepface:
159
+ with gr.TabItem("臉部情緒"):
160
+ gr.Markdown("### 臉部情緒 (即時 Webcam Streaming 分析)")
161
+ with gr.Row():
162
+ # 用 Video 捕获 Webcam
163
+ webcam = gr.Video(source="webcam", streaming=True, label="攝像頭畫面")
164
+ face_out = gr.Label(label="情緒分布")
165
+ webcam.stream(fn=predict_face, inputs=webcam, outputs=face_out)
166
+ else:
167
+ # 如果本地缺少 deepface,可给用户提示
168
+ with gr.TabItem("臉部情緒 (跳過)"):
169
+ gr.Markdown
170
 
171
 
172
  # 語音 Tab