Spaces:
Running
Running
File size: 1,235 Bytes
ea98eb5 37cc2d6 ea98eb5 d4520ce b412e38 37cc2d6 ea98eb5 d4520ce 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 |
import streamlit as st
from transformers import pipeline
# Load the summarization & translation model pipeline
#tran_sum_pipe = pipeline("translation", model='utrobinmv/t5_summary_en_ru_zh_base_2048')
trans_pipe = pipeline("translation", model='liam168/trans-opus-mt-zh-en')
sentiment_pipeline = pipeline("text-classification", model='Howosn/Sentiment_Model',return_all_scores=True)
#tokenizer = AutoTokenizer.from_pretrained('Howosn/Sentiment_Model', use_fast=False)
# 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 = tran_pipe(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:", text)
st.write("Label:", max_label)
st.write("Score:", max_score) |