Spaces:
Running
Running
requirements.txt
Browse filestransformers
torch
app.py
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
# 讬爪讬专转 诪讜讚诇 诇谞讬转讜讞 专讙砖讜转
|
5 |
+
sentiment_analysis = pipeline(
|
6 |
+
"sentiment-analysis",
|
7 |
+
model="avichr/heBERT_sentiment_analysis",
|
8 |
+
tokenizer="avichr/heBERT_sentiment_analysis",
|
9 |
+
return_all_scores = True
|
10 |
+
)
|
11 |
+
|
12 |
+
# 驻讜谞拽爪讬讛 诇谞讬转讜讞 讛讟拽住讟
|
13 |
+
def analyze_sentiment(text):
|
14 |
+
results = sentiment_analysis(text)[0]
|
15 |
+
return {r['label']: f"{r['score']:.2%}" for r in results}
|
16 |
+
|
17 |
+
# 讬爪讬专转 讛诪诪砖拽
|
18 |
+
iface = gr.Interface(
|
19 |
+
fn=analyze_sentiment,
|
20 |
+
inputs="text",
|
21 |
+
outputs="label",
|
22 |
+
title="谞讬转讜讞 专讙砖讜转 讘注讘专讬转",
|
23 |
+
description="讛讻谞住 讟拽住讟 讘注讘专讬转 讜拽讘诇 谞讬转讜讞 专讙砖讜转"
|
24 |
+
)
|
25 |
+
|
26 |
+
iface.launch()
|