|
import streamlit as st |
|
|
|
import tensorflow as tf |
|
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR) |
|
from transformers import XLMRobertaTokenizer, AutoModelForSequenceClassification, pipeline |
|
|
|
|
|
tokenizer = XLMRobertaTokenizer.from_pretrained("cardiffnlp/twitter-xlm-roberta-base-sentiment") |
|
model = AutoModelForSequenceClassification.from_pretrained("cardiffnlp/twitter-xlm-roberta-base-sentiment") |
|
|
|
|
|
nlp = pipeline("text-classification", model=model, tokenizer=tokenizer) |
|
|
|
|
|
def analyze_sentiment(text): |
|
result = nlp(text) |
|
return result[0]['label'], result[0]['score'] |
|
|
|
|
|
st.set_page_config(page_title="Sentiment Analysis", layout="wide") |
|
col1, col2 = st.columns([6, 1]) |
|
|
|
|
|
|
|
with col2: |
|
st.image("https://huggingface.co/spaces/orYx-models/Leadership-sentiment-analyzer/resolve/main/oryx_logo%20(2).png", width=200, use_column_width=False) |
|
|
|
with col1: |
|
|
|
|
|
st.markdown("This sentiment analysis model serves as a testing prototype, specifically developed for LDS to assess the variability and precision of OrYx Models' sentiment analysis tool.") |
|
st.markdown(" ") |
|
st.markdown("All feedback gathered from LDS, including both structured and unstructured data, will be incorporated into the model to enhance its domain specificity and maximize accuracy.") |
|
|
|
|
|
st.title("Sentiment Analysis Prototype Tool by orYx Models (De)") |
|
user_input = st.text_area("Enter text to analyze:", height=200) |
|
|
|
submit_button = st.button("Analyze") |
|
|
|
if submit_button and user_input: |
|
sentiment, score = analyze_sentiment(user_input) |
|
st.markdown("Sentiment Analysis Result:") |
|
st.write(f"Sentiment: {sentiment}") |
|
st.write(f"Confidence: {score*100:.2f}%") |