rahulrana0001 commited on
Commit
7f7dfa6
·
1 Parent(s): a516992

Handle invalid/empty start_page_num inputs in jump_to_page function safely

Browse files
Files changed (1) hide show
  1. app.py +5 -1
app.py CHANGED
@@ -571,7 +571,11 @@ with gr.Blocks(title="Maya: Immersive Manga AI", css=CUSTOM_CSS) as demo:
571
  def jump_to_page(pdf, page_num_val):
572
  if not pdf:
573
  return gr.update(), "Upload a PDF first", 0
574
- page_idx = max(0, int(page_num_val) - 1)
 
 
 
 
575
  return load_comic_page(pdf, page_idx)
576
 
577
  start_page_num.submit(
 
571
  def jump_to_page(pdf, page_num_val):
572
  if not pdf:
573
  return gr.update(), "Upload a PDF first", 0
574
+ try:
575
+ val = int(page_num_val)
576
+ page_idx = max(0, val - 1)
577
+ except (ValueError, TypeError):
578
+ page_idx = 0
579
  return load_comic_page(pdf, page_idx)
580
 
581
  start_page_num.submit(