Spaces:
Runtime error
Runtime error
sentiment model
Browse files
app.py
CHANGED
|
@@ -1,22 +1,15 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
| 4 |
-
pipe = pipeline('sentiment-analysis')
|
| 5 |
text = st.text_area('enter some text!')
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
st.json(out)
|
| 10 |
-
|
| 11 |
-
# text = st.text_area('enter some text!')
|
| 12 |
|
| 13 |
-
|
| 14 |
-
# preds = classifier(text, top_k=None)
|
| 15 |
|
| 16 |
-
|
|
|
|
| 17 |
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
# if text:
|
| 22 |
-
# st.json(sorted_preds)
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
from transformers import pipeline
|
| 3 |
|
|
|
|
| 4 |
text = st.text_area('enter some text!')
|
| 5 |
|
| 6 |
+
classifier = pipeline("text-classification", model="hun3359/klue-bert-base-sentiment")
|
| 7 |
+
preds = classifier(text, top_k=None)
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
+
sorted_preds = sorted(preds, key=lambda x: x['score'], reverse=True)
|
|
|
|
| 10 |
|
| 11 |
+
for item in sorted_preds:
|
| 12 |
+
item['score'] = round(item['score'], 5)
|
| 13 |
|
| 14 |
+
if text:
|
| 15 |
+
st.json(sorted_preds)
|
|
|
|
|
|
|
|
|