import streamlit as st import transformers import torch from transformers import AutoTokenizer, AutoModelForSequenceClassification # Load the model and tokenizer tokenizer = AutoTokenizer.from_pretrained("Justin-J/finetuned_sentiment_modell") model = AutoModelForSequenceClassification.from_pretrained("Justin-J/finetuned_sentiment_modell") # Define the function for sentiment analysis @st.cache_resource def predict_sentiment(text): # Load the pipeline. pipeline = transformers.pipeline("sentiment-analysis") # Predict the sentiment. prediction = pipeline(text) sentiment = prediction[0]["label"] score = prediction[0]["score"] return sentiment, score # Setting the page configurations st.set_page_config( page_title="Sentiment Analysis App", page_icon=":smile:", layout="wide", initial_sidebar_state="auto", ) # Add description and title st.write(""" # How Positive or Negative is your Text? Enter some text and we'll tell you if it has a positive, negative, or neutral sentiment! """) # Add Image Tags st.markdown( """