Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -8,45 +8,24 @@ def app():
|
|
8 |
st.title("Text Summarization π€")
|
9 |
|
10 |
st.markdown("This is a Web application that Summarizes Text π")
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
st.cache(allow_output_mutation=True)
|
15 |
def facebook_bart_model():
|
16 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
17 |
return summarizer
|
18 |
summarizer= facebook_bart_model()
|
19 |
|
20 |
def text_summarizer(text):
|
21 |
-
a = summarizer(text, max_length=
|
22 |
return a[0]['summary_text']
|
23 |
|
24 |
|
25 |
# Check to see if a file has been uploaded
|
26 |
-
if
|
27 |
st.success("Summarizing Text, Please wait...")
|
28 |
# If it has then do the following:
|
29 |
-
|
30 |
-
|
31 |
-
df = pd.read_csv(upload_file)
|
32 |
-
|
33 |
-
# Create a section for the dataframe header
|
34 |
-
|
35 |
-
df1 = df.copy()
|
36 |
-
df1['summarized_text'] = df1['Dialog'].apply(text_summarizer)
|
37 |
-
|
38 |
-
df2 = df1[['Name','summarized_text']]
|
39 |
-
st.write(df2.head(5))
|
40 |
-
|
41 |
-
@st.cache
|
42 |
-
def convert_df(dataframe):
|
43 |
-
return dataframe.to_csv().encode('utf-8')
|
44 |
-
|
45 |
-
csv = convert_df(df2)
|
46 |
-
st.download_button(label="Download CSV", data=csv, file_name='summarized_output.csv', mime='text/csv')
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
|
51 |
|
52 |
|
|
|
8 |
st.title("Text Summarization π€")
|
9 |
|
10 |
st.markdown("This is a Web application that Summarizes Text π")
|
11 |
+
text=st.text_area('Enter Text')
|
12 |
+
|
|
|
|
|
13 |
def facebook_bart_model():
|
14 |
summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
|
15 |
return summarizer
|
16 |
summarizer= facebook_bart_model()
|
17 |
|
18 |
def text_summarizer(text):
|
19 |
+
a = summarizer(text, max_length=450, min_length=150, do_sample=False)
|
20 |
return a[0]['summary_text']
|
21 |
|
22 |
|
23 |
# Check to see if a file has been uploaded
|
24 |
+
if text:
|
25 |
st.success("Summarizing Text, Please wait...")
|
26 |
# If it has then do the following:
|
27 |
+
out=text.apply(text_summarizer)
|
28 |
+
st.json(out)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
|
30 |
|
31 |
|