arad1367 commited on
Commit
83b518c
Β·
verified Β·
1 Parent(s): 534e523

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -30,7 +30,7 @@ def summarize_pdf(pdf_file, model):
30
  text += page.get_text()
31
  return summarize_text(text, model)
32
 
33
- @spaces.GPU(duration=60)
34
  def summarize(input_type, input_text, uploaded_file):
35
  try:
36
  if input_type == "Text":
@@ -38,9 +38,15 @@ def summarize(input_type, input_text, uploaded_file):
38
  else:
39
  summary = summarize_pdf(uploaded_file, summarizer)
40
  return summary
 
 
 
 
 
41
  except Exception as e:
42
  return "There was a problem summarizing the text. Please try again later."
43
 
 
44
  # Define the footer
45
  footer = """
46
  <div style="text-align: center; margin-top: 20px;">
 
30
  text += page.get_text()
31
  return summarize_text(text, model)
32
 
33
+ @spaces.GPU(duration=30)
34
  def summarize(input_type, input_text, uploaded_file):
35
  try:
36
  if input_type == "Text":
 
38
  else:
39
  summary = summarize_pdf(uploaded_file, summarizer)
40
  return summary
41
+ except RuntimeError as e:
42
+ if "CUDA out of memory" in str(e):
43
+ return "There was a problem summarizing the text due to insufficient GPU memory. Please try again with a smaller input."
44
+ else:
45
+ return "There was a problem summarizing the text. Please try again later."
46
  except Exception as e:
47
  return "There was a problem summarizing the text. Please try again later."
48
 
49
+
50
  # Define the footer
51
  footer = """
52
  <div style="text-align: center; margin-top: 20px;">