adinarayana commited on
Commit
fbcc2a4
·
verified ·
1 Parent(s): 0691efc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -23,9 +23,9 @@ def preprocess_text(element):
23
  else:
24
  return ""
25
 
26
- def get_openai_response(text, max_length=100, model="t5-small"):
27
  summarizer = pipeline("summarization", model=model)
28
- return summarizer(text, min_length=max_length)
29
 
30
  ## Streamlit app
31
 
@@ -34,8 +34,8 @@ st.header("PDF Summarizer")
34
 
35
  # User options
36
  st.subheader("Settings")
37
- # min_summary_length = st.slider("Minimum Summary Length", min_value=50, max_value=500, value=100)
38
- max_summary_length = st.slider("Maximum Summary Length", min_value=50, max_value=500, value=100)
39
  summarization_model = st.selectbox("Summarization Model", ["t5-small", "facebook/bart-large-cnn"])
40
 
41
  # File upload and processing
@@ -50,7 +50,7 @@ if uploaded_file is not None:
50
  submit = st.button("Generate Summary")
51
  if submit:
52
  with st.spinner("Summarizing..."):
53
- response = get_openai_response(text, max_length=max_summary_length, model=summarization_model)
54
  st.subheader("Summary")
55
  st.write(response[0]["summary_text"])
56
  else:
 
23
  else:
24
  return ""
25
 
26
+ def get_openai_response(text, min_length=100, model="t5-small"):
27
  summarizer = pipeline("summarization", model=model)
28
+ return summarizer(text, min_length=min_length)
29
 
30
  ## Streamlit app
31
 
 
34
 
35
  # User options
36
  st.subheader("Settings")
37
+ min_summary_length = st.slider("Minimum Summary Length", min_value=50, max_value=500, value=100)
38
+ # max_summary_length = st.slider("Maximum Summary Length", min_value=50, max_value=500, value=100)
39
  summarization_model = st.selectbox("Summarization Model", ["t5-small", "facebook/bart-large-cnn"])
40
 
41
  # File upload and processing
 
50
  submit = st.button("Generate Summary")
51
  if submit:
52
  with st.spinner("Summarizing..."):
53
+ response = get_openai_response(text, min_length=min_summary_length, model=summarization_model)
54
  st.subheader("Summary")
55
  st.write(response[0]["summary_text"])
56
  else: