LunaYi commited on
Commit
f520c17
·
1 Parent(s): 0ae7b40

sentiment model

Browse files
Files changed (1) hide show
  1. app.py +7 -14
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
- if text:
8
- out = pipe(text)
9
- st.json(out)
10
-
11
- # text = st.text_area('enter some text!')
12
 
13
- # classifier = pipeline("text-classification", model="hun3359/klue-bert-base-sentiment")
14
- # preds = classifier(text, top_k=None)
15
 
16
- # sorted_preds = sorted(preds, key=lambda x: x['score'], reverse=True)
 
17
 
18
- # for item in sorted_preds:
19
- # item['score'] = round(item['score'], 5)
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)