Spaces:
Runtime error
Runtime error
inclusive-ml
commited on
Commit
·
cdfa181
1
Parent(s):
2caf5af
initial commit
Browse files- app.py +18 -0
- requirements.txt +2 -0
app.py
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
@st.cache(allow_output_mutation=True)
|
4 |
+
def summarize_model():
|
5 |
+
model = pipeline("summarization")
|
6 |
+
return model
|
7 |
+
summ = summarize_model()
|
8 |
+
st.title("Summarize Your Text")
|
9 |
+
st.subheader("Paste any article in the text area below and click on the 'Summarize Text' button to get the summarized textual data")
|
10 |
+
st.subheader("This application is using HuggingFace's transformers pre-trained model for text summarization.")
|
11 |
+
sentence = st.text_area('Paste your copied data here...', height=100)
|
12 |
+
button = st.button("Summarize Text")
|
13 |
+
max_lengthy = st.sidebar.slider('Maximum summary length (words)', min_value=30, max_value=700, value=100, step=10)
|
14 |
+
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)
|
15 |
+
with st.spinner("Summarizing..."):
|
16 |
+
if button and sentence:
|
17 |
+
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]
|
18 |
+
st.write(summary['summary_text'])
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
tensorflow==2.3.0
|
2 |
+
transformers
|