|
import streamlit as st |
|
import streamlit.components.v1 as com |
|
|
|
from transformers import AutoModelForSequenceClassification,AutoTokenizer, AutoConfig |
|
import numpy as np |
|
|
|
from scipy.special import softmax |
|
from transformers import pipeline |
|
|
|
|
|
|
|
|
|
|
|
pipe=pipeline(model="Junr-syl/sentiments_analysis_DISTILBERT") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
st.set_page_config(page_title='Sentiments Analysis',page_icon='π',layout='centered') |
|
|
|
|
|
com.iframe("https://embed.lottiefiles.com/animation/149093") |
|
st.markdown("<h1 style='text-align: center'> Tweet Sentiments </h1>",unsafe_allow_html=True) |
|
|
|
|
|
with st.form(key='tweet',clear_on_submit=True): |
|
text=st.text_area('Copy and paste a tweet or type one',placeholder='I find it quite amusing how people ignore the effects of not taking the vaccine') |
|
submit=st.form_submit_button('submit') |
|
|
|
|
|
col1,col2,col3=st.columns(3) |
|
col1.title('Sentiment Emoji') |
|
col2.title('How this user feels about the vaccine') |
|
col3.title('Confidence of this prediction') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
output=pipe(text) |
|
output_dict=output[0] |
|
lable=output_dict['label'] |
|
score=output_dict['score'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if lable=='NEGATIVE': |
|
with col1: |
|
com.iframe("https://embed.lottiefiles.com/animation/125694") |
|
col2.write('NEGATIVE') |
|
col3.write(f'{score*100:.2f}%') |
|
elif lable=='POSITIVE': |
|
with col1: |
|
com.iframe("https://embed.lottiefiles.com/animation/148485") |
|
col2.write('POSITIVE') |
|
col3.write(f'{score*100:.2f}%') |
|
else: |
|
with col1: |
|
com.iframe("https://embed.lottiefiles.com/animation/136052") |
|
col2.write('NEUTRAL') |
|
col3.write(f'{score*100:.2f}%') |
|
|
|
|
|
|