MJ
Potential fix for markdown format
824c411
raw
history blame
1.1 kB
import streamlit as st
from transformers import pipeline
def run_model(text_in, model_in):
classifier = pipeline(task="sentiment-analysis",
model=model_in)
analysis = classifier(text_in)
to_output = ""
for output in analysis:
to_output += "Sentiment: ", output["label"], " Confidence Score: ", "{0:.2f}".format(
output["score"] * 100), "\n"
global markdown_text
markdown_text = to_output
models_available = {"Roberta Large English": "siebert/sentiment-roberta-large-english",
"Generic": "Seethal/sentiment_analysis_generic_dataset",
"Twitter Roberta": "cardiffnlp/twitter-roberta-base-sentiment"}
st.title("Sentiment Analysis Web Application")
text_input = st.text_area(
label="Enter the text to analyze", value="I Love Pizza")
model_picked = st.selectbox(
"Choose a model to run on", options=models_available.keys())
st.button("Submit", on_click=run_model, args=(
text_input, models_available[model_picked]))
if len(markdown_text) > 0:
st.markdown(body=markdown_text)