peace4ever
commited on
Commit
•
018188f
1
Parent(s):
e1a9fd7
test again
Browse files
app.py
CHANGED
@@ -1,21 +1,25 @@
|
|
1 |
import streamlit as st
|
2 |
-
import torch
|
3 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoConfig
|
4 |
from transformers import pipeline
|
5 |
-
from PIL import Image
|
6 |
|
7 |
-
model_name = "peace4ever/roberta-large-finetuned-mongolian_v3"
|
8 |
-
pipeline = pipeline(task="sentiment-analysis", model=model_name)
|
9 |
|
10 |
st.title("Эерэг? Сөрөг эсвэл аль нь ч биш?")
|
11 |
text = st.text_area("Өгүүлбэр оруулна уу?")
|
12 |
|
13 |
if text is not None:
|
14 |
-
|
15 |
-
col1, col2 = st.columns(2)
|
16 |
predictions = pipeline(text)
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
|
21 |
# tokenizer = AutoTokenizer.from_pretrained(model_name)
|
|
|
1 |
import streamlit as st
|
2 |
+
import torch
|
3 |
from transformers import AutoTokenizer, AutoModelForSequenceClassification, AutoConfig
|
4 |
from transformers import pipeline
|
|
|
5 |
|
6 |
+
model_name = "peace4ever/roberta-large-finetuned-mongolian_v3"
|
7 |
+
pipeline = pipeline(task="sentiment-analysis", model=model_name) # Load pre-trained pipeline
|
8 |
|
9 |
st.title("Эерэг? Сөрөг эсвэл аль нь ч биш?")
|
10 |
text = st.text_area("Өгүүлбэр оруулна уу?")
|
11 |
|
12 |
if text is not None:
|
|
|
|
|
13 |
predictions = pipeline(text)
|
14 |
+
|
15 |
+
col1, col2 = st.columns(2)
|
16 |
+
col1.header("Sentiment")
|
17 |
+
col2.header("Probability")
|
18 |
+
|
19 |
+
for label, probability in zip(predictions[0]["label"], predictions[0]["score"]):
|
20 |
+
col1.write(label) # Display sentiment label (e.g., "POSITIVE", "NEGATIVE")
|
21 |
+
col2.write(f"{probability:.2f}") # Display probability with 2 decimal places
|
22 |
+
|
23 |
|
24 |
|
25 |
# tokenizer = AutoTokenizer.from_pretrained(model_name)
|