Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,26 +1,27 @@
|
|
1 |
import gradio as gr
|
2 |
-
from transformers import pipeline
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
title="谞讬转讜讞 专讙砖讜转 讘注讘专讬转",
|
23 |
-
description="讛讻谞住 讟拽住讟 讘注讘专讬转 讜拽讘诇 谞讬转讜讞 专讙砖讜转"
|
24 |
)
|
25 |
|
26 |
-
|
|
|
1 |
import gradio as gr
|
2 |
+
from transformers import pipeline, AutoTokenizer, AutoModelForSequenceClassification
|
3 |
|
4 |
+
def analyze_text(text):
|
5 |
+
try:
|
6 |
+
tokenizer = AutoTokenizer.from_pretrained("avichr/heBERT_sentiment_analysis")
|
7 |
+
model = AutoModelForSequenceClassification.from_pretrained("avichr/heBERT_sentiment_analysis")
|
8 |
+
|
9 |
+
classifier = pipeline(
|
10 |
+
"sentiment-analysis",
|
11 |
+
model=model,
|
12 |
+
tokenizer=tokenizer
|
13 |
+
)
|
14 |
+
|
15 |
+
result = classifier(text)
|
16 |
+
return str(result)
|
17 |
+
except Exception as e:
|
18 |
+
return f"Error: {str(e)}"
|
19 |
|
20 |
+
interface = gr.Interface(
|
21 |
+
fn=analyze_text,
|
22 |
+
inputs=gr.Textbox(label="讛讻谞住 讟拽住讟 讘注讘专讬转"),
|
23 |
+
outputs=gr.Textbox(label="转讜爪讗讛"),
|
24 |
+
title="谞讬转讜讞 专讙砖讜转 讘注讘专讬转"
|
|
|
|
|
25 |
)
|
26 |
|
27 |
+
interface.launch()
|