Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -50,7 +50,7 @@ def predict(image):
|
|
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,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 |
-
|
74 |
with open(f"{os.getcwd()}/output.md","w+") as f:
|
75 |
f.write(content)
|
76 |
f.close()
|
77 |
-
|
78 |
-
else:
|
79 |
-
file_path=""
|
80 |
|
81 |
-
return content,
|
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
|
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,
|
126 |
)
|
127 |
gr.Examples(
|
128 |
-
[["nougat.pdf", ""
|
129 |
-
inputs = [pdf_file, pdf_link
|
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,
|