Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
import gradio as gr
|
2 |
-
from marker import PDF
|
3 |
import os
|
4 |
|
5 |
def convert_pdf(input_file, output_format):
|
@@ -13,10 +13,8 @@ def convert_pdf(input_file, output_format):
|
|
13 |
Returns:
|
14 |
Path to the converted file.
|
15 |
"""
|
16 |
-
|
17 |
-
pdf = PDF(input_file.name)
|
18 |
|
19 |
-
# Check the output format and define the output file path
|
20 |
output_file_path = f"output.{output_format.split(' ')[0].lower()}"
|
21 |
|
22 |
if output_format == "Markdown (.md)":
|
@@ -33,7 +31,6 @@ def convert_pdf(input_file, output_format):
|
|
33 |
|
34 |
return output_file_path
|
35 |
|
36 |
-
# Define Gradio interface
|
37 |
output_format_dropdown = gr.inputs.Dropdown(
|
38 |
["Markdown (.md)", "HTML (.html)", "JSON (.json)"],
|
39 |
label="Select Output File Format",
|
@@ -50,5 +47,4 @@ gr_interface = gr.Interface(
|
|
50 |
description="Upload a PDF file and select the desired output format (Markdown, HTML, or JSON).",
|
51 |
)
|
52 |
|
53 |
-
# Launch the app
|
54 |
gr_interface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
+
from marker.pdf import PDF # Updated import path
|
3 |
import os
|
4 |
|
5 |
def convert_pdf(input_file, output_format):
|
|
|
13 |
Returns:
|
14 |
Path to the converted file.
|
15 |
"""
|
16 |
+
pdf = PDF(input_file.name) # Initialize the PDF object
|
|
|
17 |
|
|
|
18 |
output_file_path = f"output.{output_format.split(' ')[0].lower()}"
|
19 |
|
20 |
if output_format == "Markdown (.md)":
|
|
|
31 |
|
32 |
return output_file_path
|
33 |
|
|
|
34 |
output_format_dropdown = gr.inputs.Dropdown(
|
35 |
["Markdown (.md)", "HTML (.html)", "JSON (.json)"],
|
36 |
label="Select Output File Format",
|
|
|
47 |
description="Upload a PDF file and select the desired output format (Markdown, HTML, or JSON).",
|
48 |
)
|
49 |
|
|
|
50 |
gr_interface.launch()
|