Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,7 +1,44 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
2 |
|
3 |
-
def greet(name):
|
4 |
-
return "Hello " + name + "!!"
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
import my_uie
|
3 |
+
import face_emo_analysize
|
4 |
|
|
|
|
|
5 |
|
6 |
+
def text_emo_analysize(text):
|
7 |
+
text_outcome = my_uie.emo_analy(text)
|
8 |
+
return text_outcome
|
9 |
+
|
10 |
+
|
11 |
+
def face_emo_analyze():
|
12 |
+
# 假设 face_emo_analysize.face_emo_analysize() 会打开摄像头并捕获表情
|
13 |
+
face_outcome = face_emo_analysize.face_emo_analysize()
|
14 |
+
return face_outcome
|
15 |
+
|
16 |
+
|
17 |
+
# 创建Gradio界面
|
18 |
+
with gr.Blocks() as demo:
|
19 |
+
gr.Markdown("# 情感分析应用")
|
20 |
+
gr.Markdown("输入信息,获取情感分析结果。")
|
21 |
+
|
22 |
+
with gr.Row():
|
23 |
+
with gr.Column():
|
24 |
+
text_input = gr.Textbox(lines=2, placeholder='在这里输入文本')
|
25 |
+
text_submit_button = gr.Button("提交文本情感分析")
|
26 |
+
text_output = gr.Textbox(label="文本情感分析结果")
|
27 |
+
|
28 |
+
with gr.Row():
|
29 |
+
face_button = gr.Button("执行面部情感分析")
|
30 |
+
face_output = gr.Textbox(label="面部情感分析结果")
|
31 |
+
|
32 |
+
|
33 |
+
def on_face_button_click():
|
34 |
+
|
35 |
+
|
36 |
+
# 调用 face_emo_analyze 函数并返回结果
|
37 |
+
face_outcome = face_emo_analyze()
|
38 |
+
return face_outcome
|
39 |
+
|
40 |
+
|
41 |
+
face_button.click(on_face_button_click, inputs=None, outputs=face_output)
|
42 |
+
text_submit_button.click(text_emo_analysize, inputs=text_input, outputs=text_output)
|
43 |
+
|
44 |
+
demo.launch()
|