Update app.py
Browse files
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 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
|
|
|
|
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
|