Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,12 +1,23 @@
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
# Load the summarization & translation model pipeline
|
6 |
#tran_sum_pipe = pipeline("translation", model='utrobinmv/t5_summary_en_ru_zh_base_2048')
|
7 |
-
trans_pipe = pipeline("translation", model='liam168/trans-opus-mt-zh-en')
|
8 |
sentiment_pipeline = pipeline("text-classification", model='Howosn/Sentiment_Model',return_all_scores=True)
|
9 |
-
|
10 |
|
11 |
# Streamlit application title
|
12 |
st.title("Emotion analysis")
|
@@ -18,7 +29,7 @@ text = st.text_area("Enter the text", "")
|
|
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 =
|
22 |
results = sentiment_pipeline(trans)[0]
|
23 |
|
24 |
# Display the classification result
|
|
|
1 |
import streamlit as st
|
2 |
from transformers import pipeline
|
3 |
|
4 |
+
def tras_sum(input):
|
5 |
+
model_name = 'utrobinmv/t5_summary_en_ru_zh_base_2048'
|
6 |
+
model = T5ForConditionalGeneration.from_pretrained(model_name)
|
7 |
+
tokenizer = T5Tokenizer.from_pretrained(model_name)
|
8 |
+
# text summary generate
|
9 |
+
prefix = 'summary to en: '
|
10 |
+
src_text = prefix + input
|
11 |
+
input_ids = tokenizer(src_text, return_tensors="pt")
|
12 |
+
generated_tokens = model.generate(**input_ids)
|
13 |
+
traslated_summary = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
|
14 |
+
return traslated_summary
|
15 |
+
|
16 |
# Load the summarization & translation model pipeline
|
17 |
#tran_sum_pipe = pipeline("translation", model='utrobinmv/t5_summary_en_ru_zh_base_2048')
|
18 |
+
#trans_pipe = pipeline("translation", model='liam168/trans-opus-mt-zh-en')
|
19 |
sentiment_pipeline = pipeline("text-classification", model='Howosn/Sentiment_Model',return_all_scores=True)
|
20 |
+
|
21 |
|
22 |
# Streamlit application title
|
23 |
st.title("Emotion analysis")
|
|
|
29 |
# Perform analysis result when the user clicks the "Analyse" button
|
30 |
if st.button("Analyse"):
|
31 |
# Perform text classification on the input text
|
32 |
+
trans = tras_sum(text)[0]
|
33 |
results = sentiment_pipeline(trans)[0]
|
34 |
|
35 |
# Display the classification result
|