Spaces:
Sleeping
Sleeping
File size: 1,165 Bytes
fe5faf3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
import streamlit as st
from transformers import AutoTokenizer , AutoModelForSequenceClassification
import torch
tokenizer = AutoTokenizer.from_pretrained('nlptown/bert-base-multilingual-uncased-sentiment')
model = AutoModelForSequenceClassification.from_pretrained('nlptown/bert-base-multilingual-uncased-sentiment')
st.set_page_config(
page_title="NLP WEB APP"
)
st.title("SENTIMENT ANALYZER")
st.sidebar.success("Select a page above")
message= st.text_input("ENTER THE MESSAGE")
if st.button("PREDICT"):
tokens = tokenizer.encode(message , return_tensors='pt')
output = model(tokens)
result = int(torch.argmax(output.logits))+1
if result==1:
st.header("TOO MUCH NEGATIVE STATEMENT")
st.header("RATING : ⭐ ")
elif result==2:
st.header("NEGATIVE STATEMENT")
st.header("RATING : ⭐⭐")
elif result==3:
st.header("NEUTRAL STATEMENT")
st.header("RATING : ⭐⭐⭐")
elif result==4:
st.header("POSITIVE STATEMENT")
st.header("RATING : ⭐⭐⭐⭐ ")
elif result==5:
st.header("TOO MUCH POSITIVE STATEMENT")
st.header("RATING : ⭐⭐⭐⭐⭐ ")
|