Wootang01 commited on
Commit
7840062
1 Parent(s): 7996b1c

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -0
app.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+ import gc
4
+
5
+ st.header("Sentiment Analysis")
6
+ st.subheader("Input text. Submit. The machine will classify the text as positive, negative and neutral and display probabilities.")
7
+ st.caption("Input text and press control + enter.")
8
+
9
+ classifier = pipeline("zero-shot classification", model='facebook/bart-large-mnli')
10
+
11
+ text = st.text_area("Input text and press control + enter.")
12
+ candidate_labels = ['positive', 'negative', 'neutral']
13
+
14
+ if text:
15
+ out = classifier(text, candidate_labels)
16
+ st.json(out)
17
+ del out
18
+ gc.collect()