File size: 1,563 Bytes
ea98eb5
 
8e3ef38
ea98eb5
7c11828
 
 
 
 
 
 
 
 
 
 
 
ea98eb5
b412e38
d9fc0db
ea98eb5
 
 
 
 
 
 
 
 
 
d9fc0db
d4520ce
 
ea98eb5
 
 
 
 
 
 
 
3e7688f
 
ea98eb5
 
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
import streamlit as st
from transformers import pipeline
from transformers import T5ForConditionalGeneration, T5Tokenizer

def tras_sum(input):
  model_name = 'utrobinmv/t5_summary_en_ru_zh_base_2048'
  model = T5ForConditionalGeneration.from_pretrained(model_name)
  tokenizer = T5Tokenizer.from_pretrained(model_name)
  # text summary generate
  prefix = 'summary to en: '
  src_text = prefix + input
  input_ids = tokenizer(src_text, return_tensors="pt")
  generated_tokens = model.generate(**input_ids)
  traslated_summary = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
  return traslated_summary

# Load the summarization & translation model pipeline
sentiment_pipeline = pipeline("text-classification", model='Howosn/Sentiment_Model',return_all_scores=True)

# Streamlit application title
st.title("Emotion analysis")
st.write("Turn Your Input Into Sentiment Score")

# Text input for the user to enter the text to analyze
text = st.text_area("Enter the text", "")

# Perform analysis result when the user clicks the "Analyse" button
if st.button("Analyse"):
    # Perform text classification on the input text
    trans = tras_sum(text)[0]
    results = sentiment_pipeline(trans)[0]
    
    # Display the classification result
    max_score = float('-inf')
    max_label = ''

    for result in results:
        if result['score'] > max_score:
            max_score = result['score']
            max_label = result['label']
            
    st.write("Text:", trans)
    st.write("Label:", max_label)
    st.write("Score:", max_score)