Spaces:
Running
on
L40S
Running
on
L40S
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,7 +39,7 @@ except Exception as e:
|
|
| 39 |
from gradio_pdf import PDF
|
| 40 |
import gradio as gr
|
| 41 |
|
| 42 |
-
from mineru.cli.common import prepare_env, read_fn, aio_do_parse
|
| 43 |
from mineru.utils.hash_utils import str_sha256
|
| 44 |
|
| 45 |
os.environ['MINERU_MODEL_SOURCE'] = 'local'
|
|
@@ -149,8 +149,8 @@ latex_delimiters = [
|
|
| 149 |
]
|
| 150 |
|
| 151 |
|
| 152 |
-
with open("header.html", "r") as
|
| 153 |
-
header =
|
| 154 |
|
| 155 |
|
| 156 |
latin_lang = [
|
|
@@ -227,7 +227,8 @@ def main():
|
|
| 227 |
with gr.Row():
|
| 228 |
with gr.Column(variant='panel', scale=5):
|
| 229 |
with gr.Row():
|
| 230 |
-
|
|
|
|
| 231 |
with gr.Row():
|
| 232 |
max_pages = gr.Slider(1, 20, 10, step=1, label='Max convert pages')
|
| 233 |
with gr.Row():
|
|
@@ -251,7 +252,7 @@ def main():
|
|
| 251 |
gr.Examples(
|
| 252 |
examples=[os.path.join(example_root, _) for _ in os.listdir(example_root) if
|
| 253 |
_.endswith('pdf')],
|
| 254 |
-
inputs=
|
| 255 |
)
|
| 256 |
|
| 257 |
with gr.Column(variant='panel', scale=5):
|
|
@@ -285,10 +286,10 @@ def main():
|
|
| 285 |
api_name=False
|
| 286 |
)
|
| 287 |
|
| 288 |
-
|
| 289 |
-
change_bu.click(fn=to_markdown, inputs=[
|
| 290 |
outputs=[md, md_text, output_file, pdf_show], api_name=False)
|
| 291 |
-
clear_bu.add([
|
| 292 |
|
| 293 |
demo.launch(ssr_mode=True)
|
| 294 |
|
|
|
|
| 39 |
from gradio_pdf import PDF
|
| 40 |
import gradio as gr
|
| 41 |
|
| 42 |
+
from mineru.cli.common import prepare_env, read_fn, aio_do_parse, pdf_suffixes, image_suffixes
|
| 43 |
from mineru.utils.hash_utils import str_sha256
|
| 44 |
|
| 45 |
os.environ['MINERU_MODEL_SOURCE'] = 'local'
|
|
|
|
| 149 |
]
|
| 150 |
|
| 151 |
|
| 152 |
+
with open("header.html", "r") as header_file:
|
| 153 |
+
header = header_file.read()
|
| 154 |
|
| 155 |
|
| 156 |
latin_lang = [
|
|
|
|
| 227 |
with gr.Row():
|
| 228 |
with gr.Column(variant='panel', scale=5):
|
| 229 |
with gr.Row():
|
| 230 |
+
suffixes = pdf_suffixes + image_suffixes
|
| 231 |
+
input_file = gr.File(label='Please upload a PDF or image', file_types=suffixes)
|
| 232 |
with gr.Row():
|
| 233 |
max_pages = gr.Slider(1, 20, 10, step=1, label='Max convert pages')
|
| 234 |
with gr.Row():
|
|
|
|
| 252 |
gr.Examples(
|
| 253 |
examples=[os.path.join(example_root, _) for _ in os.listdir(example_root) if
|
| 254 |
_.endswith('pdf')],
|
| 255 |
+
inputs=input_file
|
| 256 |
)
|
| 257 |
|
| 258 |
with gr.Column(variant='panel', scale=5):
|
|
|
|
| 286 |
api_name=False
|
| 287 |
)
|
| 288 |
|
| 289 |
+
input_file.change(fn=to_pdf, inputs=input_file, outputs=pdf_show, api_name=False)
|
| 290 |
+
change_bu.click(fn=to_markdown, inputs=[input_file, max_pages, is_ocr, formula_enable, table_enable, language, backend, url],
|
| 291 |
outputs=[md, md_text, output_file, pdf_show], api_name=False)
|
| 292 |
+
clear_bu.add([input_file, md, pdf_show, md_text, output_file, is_ocr])
|
| 293 |
|
| 294 |
demo.launch(ssr_mode=True)
|
| 295 |
|