File size: 1,960 Bytes
67583c1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# -*- coding: utf-8 -*-
"""
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)

# Load pre-trained model and tokenizer
saved_directory = "C:/Users/phonoDS/FineTuned_Roberta_Sentiment_Analysis"
tokenizer = AutoTokenizer.from_pretrained(saved_directory)
model = AutoModelForSequenceClassification.from_pretrained(saved_directory)
nlp = pipeline("sentiment-analysis", model=model, tokenizer=tokenizer)

# Define function to analyze sentiment
def analyze_sentiment(text):
    result = nlp(text)
    return result[0]['label'], result[0]['score']

# Streamlit UI
st.set_page_config(page_title="Sentiment Analysis", layout="wide")
col1, col2 = st.columns([6, 1])  # Divide the screen into two columns

with col2:  # Right-aligned column for the logo
    st.image("C:/Users/phonoDS/Downloads/oryx_logo.png", width=200, use_column_width=False)  # Provide the path to your company logo

with col1:  # Main content area
    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}%")
    
    # Text titles below the text box
    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.")