Update app.py
Browse files
app.py
CHANGED
|
@@ -155,16 +155,17 @@ def build_interface():
|
|
| 155 |
gr.Markdown("## 多模態情緒分析示例")
|
| 156 |
with gr.Tabs():
|
| 157 |
# 臉部 Tab
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
|
|
|
| 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("語音情緒"):
|