# Author: Ricardo Lisboa Santos # Creation date: 2024-01-10 import streamlit as st import time import AI.sentiment_analysis as ai def run(): st.set_page_config(page_title="Sentiment Analysis", page_icon="📈") # setSidebar() # st.write('Sentiment Analysis') st.markdown("# Sentiment Analysis") input = st.text_input('Enter your prompt here.') if st.button('Click me to run'): progress_bar = st.sidebar.progress(0) status_text = st.sidebar.empty() loading_text='Loading Model' with st.spinner(text=loading_text): status_text.text("Getting Device") device = ai.getDevice("cpu") progress_bar.progress(30) status_text.text("Loading Model") model = ai.loadClassifier(device) progress_bar.progress(60) status_text.text("Classifying") output = ai.classify(model, input) progress_bar.progress(90) ai.clearCache("cpu", model) progress_bar.progress(100) status_text.text("Done") if output[0].get('label') == 'NEGATIVE': st.error(' 😔 ' + output[0].get('label')) elif output[0].get('label') == 'POSITIVE': st.success(' 😃 ' + output[0].get('label')) # def setSidebar(): # st.sidebar.header("Sentiment Analysis") # st.sidebar.write( # """This demo illustrates a combination of plotting and animation with # Streamlit. We're generating a bunch of random numbers in a loop for around # 5 seconds. Enjoy!""" # ) if __name__ == '__main__': run()