MrGanesh commited on
Commit
64a36e0
Β·
1 Parent(s): 6d3173c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -27
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
- upload_file = st.file_uploader('Upload a file containing Text data')
12
- button = st.button("Summarize")
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=150, min_length=30, do_sample=False)
22
  return a[0]['summary_text']
23
 
24
 
25
  # Check to see if a file has been uploaded
26
- if upload_file is not None and button:
27
  st.success("Summarizing Text, Please wait...")
28
  # If it has then do the following:
29
-
30
- # Read the file to a dataframe using pandas
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