import streamlit as st import numpy as np import torch import transformers @st.cache_resource def get_model(): model = transformers.AutoModelForSequenceClassification.from_pretrained("Kwasiasomani/Finetuned-Distilbert-base-model") tokenizer = transformers.AutoTokenizer.from_pretrained("Kwasiasomani/Finetuned-Distilbert-base-model") return tokenizer,model tokenizer, model = get_model() button = st.button('analyze') user_input = st.text_area(''' How Positive or Negative is your Text?,Enter some text and we'll tell you if it has a positive, negative, or neutral sentiment!''') # Define the Helper function label = { 0: 'Negative', 1: 'Neutral', 2: 'Positive' } if user_input and button: test_input = tokenizer([user_input],return_tensors='pt') # Test output output = model(**test_input) st.write('Logits:',output.logits) predicted_class = np.argmax(output.logits.detach().numpy()) st.write('prediction:',label[predicted_class[0]])