arad1367 commited on
Commit
6f86b8b
Β·
verified Β·
1 Parent(s): 83b518c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -2
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=30)
34
  def summarize(input_type, input_text, uploaded_file):
35
  try:
36
  if input_type == "Text":
@@ -43,10 +43,14 @@ def summarize(input_type, input_text, uploaded_file):
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;">
 
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":
 
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 gradio.exceptions.Error as e:
47
+ if "GPU task aborted" in str(e):
48
+ return "The summarization process took too long and was aborted. Please try again with a smaller input."
49
+ else:
50
+ return "There was a problem summarizing the text. Please try again later."
51
  except Exception as e:
52
  return "There was a problem summarizing the text. Please try again later."
53
 
 
54
  # Define the footer
55
  footer = """
56
  <div style="text-align: center; margin-top: 20px;">