Howosn commited on
Commit
75c7e73
1 Parent(s): fb42d8f

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ pip install transformers[sentencepiece]
2
+ import streamlit as st
3
+ from transformers import pipeline
4
+
5
+
6
+ # Load the summarization & translation model pipeline
7
+ tran_sum_pipe = pipeline("translation", model='utrobinmv/t5_summary_en_ru_zh_base_2048',return_all_scores=True)
8
+ sentiment_pipeline = pipeline("text-classification", model='Howosn/Sentiment_Model',return_all_scores=True)
9
+ #tokenizer = AutoTokenizer.from_pretrained('Howosn/Sentiment_Model', use_fast=False)
10
+
11
+ # Streamlit application title
12
+ st.title("Emotion analysis")
13
+ st.write("Turn Your Input Into Sentiment Score")
14
+
15
+ # Text input for the user to enter the text to analyze
16
+ text = st.text_area("Enter the text", "")
17
+
18
+ # Perform analysis result when the user clicks the "Analyse" button
19
+ if st.button("Analyse"):
20
+ # Perform text classification on the input text
21
+ trans_sum = tran_sum_pipe(text)[0]
22
+ results = sentiment_pipeline(trans_sum)[0]
23
+
24
+ # Display the classification result
25
+ max_score = float('-inf')
26
+ max_label = ''
27
+
28
+ for result in results:
29
+ if result['score'] > max_score:
30
+ max_score = result['score']
31
+ max_label = result['label']
32
+
33
+ st.write("Text:", text)
34
+ st.write("Label:", max_label)
35
+ st.write("Score:", max_score)