|
import streamlit as st |
|
from transformers import pipeline |
|
from transformers import AutoTokenizer, AutoModelForSequenceClassification |
|
|
|
|
|
|
|
|
|
|
|
tran_sum_pipe = pipeline("translation", model='utrobinmv/t5_summary_en_ru_zh_base_2048',return_all_scores=True) |
|
sentiment_pipeline = pipeline("text-classification", model='Howosn/Sentiment_Model',return_all_scores=True) |
|
tokenizer = T5Tokenizer.from_pretrained('utrobinmv/t5_summary_en_ru_zh_base_2048') |
|
|
|
|
|
st.title("Emotion analysis") |
|
st.write("Turn Your Input Into Sentiment Score") |
|
|
|
|
|
text = st.text_area("Enter the text", "") |
|
|
|
|
|
if st.button("Analyse"): |
|
|
|
trans_sum = tran_sum_pipe(text)[0] |
|
results = sentiment_pipeline(trans_sum)[0] |
|
|
|
|
|
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) |