rexoscare commited on
Commit
f3e8e8f
1 Parent(s): 17315f9

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -0
app.py CHANGED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+
5
+ @st.cache(allow_output_mutation=True)
6
+ def summarize_model():
7
+ model = pipeline("summarization")
8
+ return model
9
+
10
+
11
+ summ = summarize_model()
12
+ st.title("Summarize Your Text")
13
+ st.subheader("Paste any article in the text area below and click on the 'Summarize Text' button to get the summarized textual data")
14
+ st.subheader("This application is using HuggingFace's transformers pre-trained model for text summarization.")
15
+ sentence = st.text_area('Paste your copied data here...', height=100)
16
+ button = st.button("Summarize Text")
17
+ max_lengthy = st.sidebar.slider('Maximum summary length (words)', min_value=30, max_value=700, value=100, step=10)
18
+ num_beamer = st.sidebar.slider('Speed vs quality of Summary (1 is fastest but less accurate)', min_value=1, max_value=8, value=4, step=1)
19
+ with st.spinner("Summarizing..."):
20
+ if button and sentence:
21
+ summary = summ(sentence, max_length = max_lengthy, min_length = 50, num_beams=num_beamer, do_sample=True,early_stopping=True, repetition_penalty=1.5, length_penalty=1.5)[0]
22
+ st.write(summary['summary_text'])