Spaces:
Paused
Paused
added examples
Browse files
app.py
CHANGED
@@ -100,6 +100,10 @@ def predict1(pdf_file):
|
|
100 |
|
101 |
return content
|
102 |
|
|
|
|
|
|
|
|
|
103 |
css = """
|
104 |
#mkd {
|
105 |
height: 500px;
|
@@ -119,13 +123,12 @@ with gr.Blocks(css=css) as demo:
|
|
119 |
|
120 |
with gr.Row(equal_height=True):
|
121 |
pdf_file = gr.File(label='PDF📃', file_count='single', scale=1)
|
122 |
-
|
123 |
-
pdf_link = gr.Textbox(placeholder='Enter an arxiv link here', label='PDF link🔗🌐', scale=1)
|
124 |
|
125 |
with gr.Row():
|
126 |
btn = gr.Button('Run NOUGAT🍫')
|
127 |
clr = gr.Button('Clear🚿')
|
128 |
-
parsed_output = gr.Markdown(elem_id='mkd', value='OCR Output
|
129 |
|
130 |
btn.click(predict, [pdf_file, pdf_link], parsed_output )
|
131 |
clr.click(lambda : (gr.update(value=None),
|
@@ -135,23 +138,14 @@ with gr.Blocks(css=css) as demo:
|
|
135 |
[pdf_file, pdf_link, parsed_output]
|
136 |
)
|
137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
demo.queue()
|
139 |
demo.launch(debug=True)
|
140 |
-
|
141 |
-
with gr.Blocks(css=css) as demo1:
|
142 |
-
gr.HTML("<h1><center>Nougat: Neural Optical Understanding for Academic Documents<center><h1>")
|
143 |
-
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>")
|
144 |
-
|
145 |
-
with gr.Row():
|
146 |
-
pdf_file = gr.File(label='Upload a PDF', scale=1)
|
147 |
-
mkd = gr.Markdown('<h2><center><i>OR</i></center></h2>',scale=1)
|
148 |
-
pdf_link = gr.Textbox(placeholder='Enter an arxiv link here', label='Provide a link', scale=1)
|
149 |
-
|
150 |
-
btn = gr.Button()
|
151 |
-
parsed_output = gr.Markdown(elem_id='mkd')
|
152 |
-
|
153 |
-
btn.click(predict, pdf_file, parsed_output )
|
154 |
-
|
155 |
-
#demo.queue()
|
156 |
-
#demo.launch(debug=True)
|
157 |
-
|
|
|
100 |
|
101 |
return content
|
102 |
|
103 |
+
def process_example(pdf_file,pdf_link):
|
104 |
+
ocr_content = paper_read(pdf_file,pdf_link)
|
105 |
+
return ocr_content
|
106 |
+
|
107 |
css = """
|
108 |
#mkd {
|
109 |
height: 500px;
|
|
|
123 |
|
124 |
with gr.Row(equal_height=True):
|
125 |
pdf_file = gr.File(label='PDF📃', file_count='single', scale=1)
|
126 |
+
pdf_link = gr.Textbox(placeholder='Enter an Arxiv link here', label='PDF link🔗🌐', scale=1)
|
|
|
127 |
|
128 |
with gr.Row():
|
129 |
btn = gr.Button('Run NOUGAT🍫')
|
130 |
clr = gr.Button('Clear🚿')
|
131 |
+
parsed_output = gr.Markdown(elem_id='mkd', value='📃🔤OCR Output')
|
132 |
|
133 |
btn.click(predict, [pdf_file, pdf_link], parsed_output )
|
134 |
clr.click(lambda : (gr.update(value=None),
|
|
|
138 |
[pdf_file, pdf_link, parsed_output]
|
139 |
)
|
140 |
|
141 |
+
gr.Examples(
|
142 |
+
[["input/nougat.pdf", ""], [None, "https://arxiv.org/pdf/2308.08316.pdf"]],
|
143 |
+
inputs = [pdf_file, pdf_link],
|
144 |
+
outputs = parsed_output,
|
145 |
+
fn=process_example,
|
146 |
+
cache_examples=True,
|
147 |
+
label='Click on any Examples below to get Nougat OCR results quickly:'
|
148 |
+
)
|
149 |
+
|
150 |
demo.queue()
|
151 |
demo.launch(debug=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|