merve HF staff commited on
Commit
c615442
β€’
1 Parent(s): 04a08ae

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -12
app.py CHANGED
@@ -50,7 +50,7 @@ def predict(image):
50
 
51
 
52
 
53
- def inference(pdf_file, pdf_link, file_btn):
54
  if pdf_file is None:
55
  if pdf_link == '':
56
  print("No file is uploaded and No link is provided")
@@ -70,15 +70,13 @@ def inference(pdf_file, pdf_link, file_btn):
70
 
71
  content = sequence.replace(r'\(', '$').replace(r'\)', '$').replace(r'\[', '$$').replace(r'\]', '$$')
72
 
73
- if file_btn:
74
  with open(f"{os.getcwd()}/output.md","w+") as f:
75
  f.write(content)
76
  f.close()
77
- file_path = f"{os.getcwd()}/output.md"
78
- else:
79
- file_path=""
80
 
81
- return content, file_path
82
 
83
 
84
  css = """
@@ -104,8 +102,6 @@ with gr.Blocks(css=css) as demo:
104
  with gr.Row(equal_height=True):
105
  pdf_file = gr.File(label='PDF πŸ“‘', file_count='single', scale=1)
106
  pdf_link = gr.Textbox(placeholder='Enter an arxiv link here', label='Link to PaperπŸ”—', scale=1)
107
- with gr.Row():
108
- file_btn = gr.Checkbox(value=True, label='Download output as file πŸ“‘')
109
  with gr.Row():
110
  btn = gr.Button('Run Nougat 🍫')
111
  with gr.Row():
@@ -116,17 +112,17 @@ with gr.Blocks(css=css) as demo:
116
  parsed_output = gr.Markdown(elem_id='mkd', value='Output Text πŸ“')
117
  output_file = gr.File(file_types = ["txt"], label="Output File πŸ“‘")
118
 
119
- btn.click(inference, [pdf_file, pdf_link, file_btn], [parsed_output, output_file])
120
  clr.click(lambda : (gr.update(value=None),
121
  gr.update(value=None),
122
  gr.update(value=None),
123
  gr.update(value=None)),
124
  [],
125
- [pdf_file, pdf_link, file_btn, parsed_output, output_file]
126
  )
127
  gr.Examples(
128
- [["nougat.pdf", "", True], [None, "https://arxiv.org/pdf/2308.08316.pdf", True]],
129
- inputs = [pdf_file, pdf_link, file_btn],
130
  outputs = [parsed_output, output_file],
131
  fn=inference,
132
  cache_examples=True,
 
50
 
51
 
52
 
53
+ def inference(pdf_file, pdf_link):
54
  if pdf_file is None:
55
  if pdf_link == '':
56
  print("No file is uploaded and No link is provided")
 
70
 
71
  content = sequence.replace(r'\(', '$').replace(r'\)', '$').replace(r'\[', '$$').replace(r'\]', '$$')
72
 
73
+
74
  with open(f"{os.getcwd()}/output.md","w+") as f:
75
  f.write(content)
76
  f.close()
77
+
 
 
78
 
79
+ return content, f"{os.getcwd()}/output.md"
80
 
81
 
82
  css = """
 
102
  with gr.Row(equal_height=True):
103
  pdf_file = gr.File(label='PDF πŸ“‘', file_count='single', scale=1)
104
  pdf_link = gr.Textbox(placeholder='Enter an arxiv link here', label='Link to PaperπŸ”—', scale=1)
 
 
105
  with gr.Row():
106
  btn = gr.Button('Run Nougat 🍫')
107
  with gr.Row():
 
112
  parsed_output = gr.Markdown(elem_id='mkd', value='Output Text πŸ“')
113
  output_file = gr.File(file_types = ["txt"], label="Output File πŸ“‘")
114
 
115
+ btn.click(inference, [pdf_file, pdf_link], [parsed_output, output_file])
116
  clr.click(lambda : (gr.update(value=None),
117
  gr.update(value=None),
118
  gr.update(value=None),
119
  gr.update(value=None)),
120
  [],
121
+ [pdf_file, pdf_link, parsed_output, output_file]
122
  )
123
  gr.Examples(
124
+ [["nougat.pdf", ""], [None, "https://arxiv.org/pdf/2308.08316.pdf"]],
125
+ inputs = [pdf_file, pdf_link],
126
  outputs = [parsed_output, output_file],
127
  fn=inference,
128
  cache_examples=True,