Spaces:
Running
Running
File size: 1,129 Bytes
811ee7c |
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 |
import streamlit as st
from transformers import pipeline
import torch
import torch.nn.functional as F
def main():
models = ["distilbert-base-uncased-finetuned-sst-2-english","cardiffnlp/twitter-roberta-base-sentiment","finiteautomata/bertweet-base-sentiment-analysis","papluca/xlm-roberta-base-language-detection","cardiffnlp/twitter-roberta-base-sentiment-latest","yiyanghkust/finbert-tone","ProsusAI/finbert","j-hartmann/emotion-english-distilroberta-base"]
st.title("Streamlit Sentiment Analysis App ")
st.header("Sentiments analysis using Trnasformers by 🤗")
st.header("Jozef Janosko - CS 482, Milestone 2")
st.text("Input a test string for sentiment analysis.")
input=st.text_input("input string","Here is a default string. I love machine learning!")
model = st.selectbox("Select Model...", models)
st.text("Result using "+model+": ")
st.text(str(sentiment_Analysis(input,model)))
def sentiment_Analysis(input, model):
classifier = pipeline("sentiment-analysis",model)
ret=classifier(input)
return ret
if __name__ == '__main__' :
main() |