Commit
·
c8538a0
1
Parent(s):
0c1226f
111
Browse files- __pycache__/my_uie.cpython-310.pyc +0 -0
- app.py +10 -4
- my_uie.py +13 -4
- result_face.mp4 +0 -0
- result_hm.mp4 +0 -0
__pycache__/my_uie.cpython-310.pyc
CHANGED
|
Binary files a/__pycache__/my_uie.cpython-310.pyc and b/__pycache__/my_uie.cpython-310.pyc differ
|
|
|
app.py
CHANGED
|
@@ -15,8 +15,8 @@ from app.authors import AUTHORS
|
|
| 15 |
from app.app_utils import preprocess_image_and_predict, preprocess_video_and_predict
|
| 16 |
|
| 17 |
def text_emo_analysize(text):
|
| 18 |
-
|
| 19 |
-
return
|
| 20 |
|
| 21 |
def clear_static_info():
|
| 22 |
return (
|
|
@@ -65,8 +65,14 @@ with gr.Blocks(css="app.css") as demo:
|
|
| 65 |
gr.Markdown("文本情感分析")
|
| 66 |
text_input = gr.Textbox(lines=2, placeholder='在这里输入文本')
|
| 67 |
text_submit_button = gr.Button("提交文本情感分析")
|
| 68 |
-
|
| 69 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
|
| 72 |
|
|
|
|
| 15 |
from app.app_utils import preprocess_image_and_predict, preprocess_video_and_predict
|
| 16 |
|
| 17 |
def text_emo_analysize(text):
|
| 18 |
+
text_outcome1,text_outcome2 = my_uie.text_emo_analysize(text)
|
| 19 |
+
return text_outcome1,text_outcome2
|
| 20 |
|
| 21 |
def clear_static_info():
|
| 22 |
return (
|
|
|
|
| 65 |
gr.Markdown("文本情感分析")
|
| 66 |
text_input = gr.Textbox(lines=2, placeholder='在这里输入文本')
|
| 67 |
text_submit_button = gr.Button("提交文本情感分析")
|
| 68 |
+
|
| 69 |
+
# 增加两个输出框
|
| 70 |
+
text_output_1 = gr.Textbox(label="文本情感")
|
| 71 |
+
text_output_2 = gr.Textbox(label="情感概率")
|
| 72 |
+
|
| 73 |
+
# 让按钮处理两个输出
|
| 74 |
+
text_submit_button.click(text_emo_analysize, inputs=text_input, outputs=[text_output_1, text_output_2])
|
| 75 |
+
|
| 76 |
|
| 77 |
|
| 78 |
|
my_uie.py
CHANGED
|
@@ -1,7 +1,16 @@
|
|
| 1 |
from paddlenlp import Taskflow
|
|
|
|
| 2 |
def text_emo_analysize(text):
|
| 3 |
senta = Taskflow("sentiment_analysis", model="skep_ernie_1.0_large_ch")
|
| 4 |
-
result=senta(text)
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
from paddlenlp import Taskflow
|
| 2 |
+
|
| 3 |
def text_emo_analysize(text):
|
| 4 |
senta = Taskflow("sentiment_analysis", model="skep_ernie_1.0_large_ch")
|
| 5 |
+
result = senta(text)[0] # 获取第一个结果
|
| 6 |
+
# 创建两个输出框
|
| 7 |
+
output_1 = {"文本": result['text'], "情感": "积极" if result['label'] == "positive" else "消极"}
|
| 8 |
+
output_2 = {"概率": result['score']}
|
| 9 |
+
|
| 10 |
+
# 打印两个输出框
|
| 11 |
+
print(output_1)
|
| 12 |
+
print(output_2)
|
| 13 |
+
|
| 14 |
+
return output_1, output_2
|
| 15 |
+
|
| 16 |
+
text_emo_analysize("不开心")
|
result_face.mp4
CHANGED
|
Binary files a/result_face.mp4 and b/result_face.mp4 differ
|
|
|
result_hm.mp4
CHANGED
|
Binary files a/result_hm.mp4 and b/result_hm.mp4 differ
|
|
|