fsmoreir commited on
Commit
4805dc8
·
verified ·
1 Parent(s): e1065f1

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -32,13 +32,13 @@ def nougat_ocr(file_name):
32
  subprocess.run(cli_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
33
 
34
  def predict(pdf_file, pdf_link):
35
- if pdf_file is None and pdf_link == '':
36
  return "No data provided. Upload a pdf file or provide a pdf link and try again!", "", ""
37
 
38
- if pdf_file is None:
39
- file_name = get_pdf(pdf_link)
40
- else:
41
  file_name = pdf_file.name
 
 
42
 
43
  # Call nougat
44
  nougat_ocr(file_name)
@@ -77,9 +77,9 @@ with gr.Blocks(css=css) as demo:
77
  gr.HTML("<h3><center>Lukas Blecher et al. <a href='https://arxiv.org/pdf/2308.13418.pdf' target='_blank'>Paper</a>, <a href='https://facebookresearch.github.io/nougat/'>Project</a><center></h3>")
78
 
79
  with gr.Row():
80
- mkd = gr.Markdown('<h4><center>Upload a PDF</center></h4>', scale=1)
81
- mkd = gr.Markdown('<h4><center><i>OR</i></center></h4>', scale=1)
82
- mkd = gr.Markdown('<h4><center>Provide a PDF link</center></h4>', scale=1)
83
 
84
  with gr.Row(equal_height=True):
85
  pdf_file = gr.File(label='PDF📃', file_count='single', scale=1)
@@ -96,7 +96,7 @@ with gr.Blocks(css=css) as demo:
96
  download_link = gr.File(elem_id='download-link', visible=False)
97
 
98
  btn.click(fn=predict, inputs=[pdf_file, pdf_link], outputs=[parsed_output, markdown_hidden, download_link], _js=js_auto_copy)
99
- clr.click(lambda: (gr.update(value=None), gr.update(value=None), gr.update(value=None)), [], [pdf_file, pdf_link, parsed_output, markdown_hidden, download_link])
100
  dwn.click(None, [download_link], None)
101
 
102
  # Enable queueing for request handling
 
32
  subprocess.run(cli_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
33
 
34
  def predict(pdf_file, pdf_link):
35
+ if pdf_file is None and not pdf_link:
36
  return "No data provided. Upload a pdf file or provide a pdf link and try again!", "", ""
37
 
38
+ if pdf_file is not None:
 
 
39
  file_name = pdf_file.name
40
+ else:
41
+ file_name = get_pdf(pdf_link)
42
 
43
  # Call nougat
44
  nougat_ocr(file_name)
 
77
  gr.HTML("<h3><center>Lukas Blecher et al. <a href='https://arxiv.org/pdf/2308.13418.pdf' target='_blank'>Paper</a>, <a href='https://facebookresearch.github.io/nougat/'>Project</a><center></h3>")
78
 
79
  with gr.Row():
80
+ gr.Markdown('<h4><center>Upload a PDF</center></h4>', scale=1)
81
+ gr.Markdown('<h4><center><i>OR</i></center></h4>', scale=1)
82
+ gr.Markdown('<h4><center>Provide a PDF link</center></h4>', scale=1)
83
 
84
  with gr.Row(equal_height=True):
85
  pdf_file = gr.File(label='PDF📃', file_count='single', scale=1)
 
96
  download_link = gr.File(elem_id='download-link', visible=False)
97
 
98
  btn.click(fn=predict, inputs=[pdf_file, pdf_link], outputs=[parsed_output, markdown_hidden, download_link], _js=js_auto_copy)
99
+ clr.click(lambda: (gr.update(value=None), gr.update(value=None), gr.update(value=None), gr.update(value=None)), [], [pdf_file, pdf_link, parsed_output, markdown_hidden, download_link])
100
  dwn.click(None, [download_link], None)
101
 
102
  # Enable queueing for request handling