Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,8 +2,19 @@ import streamlit as st
|
|
| 2 |
from transformers import pipeline
|
| 3 |
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
# Load the summarization & translation model pipeline
|
| 6 |
-
tran_sum_pipe = pipeline("translation", model='utrobinmv/t5_summary_en_ru_zh_base_2048',return_all_scores=True)
|
| 7 |
sentiment_pipeline = pipeline("text-classification", model='Howosn/Sentiment_Model',return_all_scores=True)
|
| 8 |
|
| 9 |
# Streamlit application title
|
|
@@ -28,6 +39,5 @@ if st.button("Analyse"):
|
|
| 28 |
max_score = result['score']
|
| 29 |
max_label = result['label']
|
| 30 |
|
| 31 |
-
st.write("Text:", trans)
|
| 32 |
st.write("Label:", max_label)
|
| 33 |
st.write("Score:", max_score)
|
|
|
|
| 2 |
from transformers import pipeline
|
| 3 |
from transformers import T5ForConditionalGeneration, T5Tokenizer
|
| 4 |
|
| 5 |
+
def tras_sum(input):
|
| 6 |
+
model_name = 'utrobinmv/t5_summary_en_ru_zh_base_2048'
|
| 7 |
+
model = T5ForConditionalGeneration.from_pretrained(model_name)
|
| 8 |
+
tokenizer = T5Tokenizer.from_pretrained(model_name)
|
| 9 |
+
# text summary generate
|
| 10 |
+
prefix = 'summary to en: '
|
| 11 |
+
src_text = prefix + input
|
| 12 |
+
input_ids = tokenizer(src_text, return_tensors="pt")
|
| 13 |
+
generated_tokens = model.generate(**input_ids)
|
| 14 |
+
traslated_summary = tokenizer.batch_decode(generated_tokens, skip_special_tokens=True)
|
| 15 |
+
return traslated_summary
|
| 16 |
+
|
| 17 |
# Load the summarization & translation model pipeline
|
|
|
|
| 18 |
sentiment_pipeline = pipeline("text-classification", model='Howosn/Sentiment_Model',return_all_scores=True)
|
| 19 |
|
| 20 |
# Streamlit application title
|
|
|
|
| 39 |
max_score = result['score']
|
| 40 |
max_label = result['label']
|
| 41 |
|
|
|
|
| 42 |
st.write("Label:", max_label)
|
| 43 |
st.write("Score:", max_score)
|