|
|
|
""" |
|
Created on Fri Apr 19 16:58:55 2024 |
|
|
|
@author: phonoDS |
|
""" |
|
|
|
import streamlit as st |
|
from transformers import AutoTokenizer, AutoModelForSequenceClassification, pipeline |
|
import tensorflow as tf |
|
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR) |
|
|
|
|
|
saved_directory = "orYx-models/finetuned-roberta-leadership-sentiment-analysis" |
|
tokenizer = AutoTokenizer.from_pretrained(saved_directory) |
|
model = AutoModelForSequenceClassification.from_pretrained(saved_directory) |
|
nlp = pipeline("sentiment-analysis", 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.png", width=200, use_column_width=False) |
|
|
|
with col1: |
|
st.title("Sentiment Analysis Prototype Tool by orYx Models") |
|
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}%") |
|
|
|
|
|
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("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.") |
|
|