Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,19 +1,19 @@
|
|
1 |
-
import
|
2 |
import gradio as gr
|
3 |
|
4 |
def parse_pdf(pdf_file, output_format):
|
5 |
with open(pdf_file, 'rb') as file:
|
6 |
if output_format == "Markdown":
|
7 |
-
markdown_text =
|
8 |
return markdown_text
|
9 |
elif output_format == "HTML":
|
10 |
# Convert to HTML using marker-pdf's advanced parsing capabilities
|
11 |
# You might need to explore additional options and parameters for fine-tuning the output
|
12 |
-
html_text =
|
13 |
return html_text
|
14 |
elif output_format == "JSON":
|
15 |
# Convert to JSON using marker-pdf's structured output
|
16 |
-
json_output =
|
17 |
return json_output
|
18 |
|
19 |
# Create the Gradio interface
|
@@ -25,6 +25,7 @@ iface = gr.Interface(
|
|
25 |
description="Parse a PDF and choose the output format."
|
26 |
)
|
27 |
|
28 |
-
# Launch the Gradio app
|
29 |
if __name__ == "__main__":
|
30 |
-
iface.launch()
|
|
|
|
1 |
+
from marker import convert
|
2 |
import gradio as gr
|
3 |
|
4 |
def parse_pdf(pdf_file, output_format):
|
5 |
with open(pdf_file, 'rb') as file:
|
6 |
if output_format == "Markdown":
|
7 |
+
markdown_text = convert(file)
|
8 |
return markdown_text
|
9 |
elif output_format == "HTML":
|
10 |
# Convert to HTML using marker-pdf's advanced parsing capabilities
|
11 |
# You might need to explore additional options and parameters for fine-tuning the output
|
12 |
+
html_text = convert(file, output_format="html")
|
13 |
return html_text
|
14 |
elif output_format == "JSON":
|
15 |
# Convert to JSON using marker-pdf's structured output
|
16 |
+
json_output = convert(file, output_format="json")
|
17 |
return json_output
|
18 |
|
19 |
# Create the Gradio interface
|
|
|
25 |
description="Parse a PDF and choose the output format."
|
26 |
)
|
27 |
|
28 |
+
# Launch the Gradio app (optional: add share=True for a public link)
|
29 |
if __name__ == "__main__":
|
30 |
+
iface.launch() # For local development
|
31 |
+
# iface.launch(share=True) # For a public link
|