Spaces:
Runtime error
Runtime error
VarshithaChennamsetti
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -5,13 +5,13 @@ from transformers import AutoTokenizer, AutoModelForSequenceClassification
|
|
5 |
|
6 |
# Get Input
|
7 |
models = {"Distilbert": "distilbert-base-uncased-finetuned-sst-2-english", "roBERTa" : "cardiffnlp/twitter-roberta-base-sentiment", "Bert" : "finiteautomata/bertweet-base-sentiment-analysis"}
|
8 |
-
text = st.text_area('
|
9 |
model_name = st.selectbox("What model do you wanna use?", ("Distilbert", "roBERTa", "Bert"))
|
10 |
|
11 |
# Default Model - DistilBert
|
12 |
-
if text and
|
13 |
model = AutoModelForSequenceClassification.from_pretrained(models[model_name])
|
14 |
tokenizer = AutoTokenizer.from_pretrained(models[model_name])
|
15 |
classifier = pipeline('sentiment-analysis', model = model, tokenizer = tokenizer)
|
16 |
out = classifier(text)
|
17 |
-
st.json(out)
|
|
|
5 |
|
6 |
# Get Input
|
7 |
models = {"Distilbert": "distilbert-base-uncased-finetuned-sst-2-english", "roBERTa" : "cardiffnlp/twitter-roberta-base-sentiment", "Bert" : "finiteautomata/bertweet-base-sentiment-analysis"}
|
8 |
+
text = st.text_area('Text to analyze', "On the review aggregation website Rotten Tomatoes, The Super Mario Bros Movie has a critics score of just 54 per cent positive, marking it as Rotten.")
|
9 |
model_name = st.selectbox("What model do you wanna use?", ("Distilbert", "roBERTa", "Bert"))
|
10 |
|
11 |
# Default Model - DistilBert
|
12 |
+
if text and st.button('Submit!'):
|
13 |
model = AutoModelForSequenceClassification.from_pretrained(models[model_name])
|
14 |
tokenizer = AutoTokenizer.from_pretrained(models[model_name])
|
15 |
classifier = pipeline('sentiment-analysis', model = model, tokenizer = tokenizer)
|
16 |
out = classifier(text)
|
17 |
+
st.json(out)
|