Spaces:
Running
Running
Synced repo using 'sync_with_huggingface' Github Action
Browse files- gradio_app.py +34 -6
- requirements.txt +7 -2
gradio_app.py
CHANGED
@@ -86,7 +86,7 @@ if 'model_dict' not in globals():
|
|
86 |
with gr.Blocks(title="Marker") as demo:
|
87 |
gr.Markdown("""
|
88 |
# Marker Demo
|
89 |
-
|
90 |
This app will let you try marker, a PDF -> Markdown converter. It works with any languages, and extracts images, tables, equations, etc.
|
91 |
|
92 |
Find the project [here](https://github.com/VikParuchuri/marker).
|
@@ -129,17 +129,20 @@ with gr.Blocks(title="Marker") as demo:
|
|
129 |
in_file.clear(
|
130 |
fn=show_image,
|
131 |
inputs=[in_file],
|
132 |
-
outputs=[in_num, in_img, page_range_txt]
|
|
|
133 |
)
|
134 |
in_file.upload(
|
135 |
fn=show_image,
|
136 |
inputs=[in_file],
|
137 |
-
outputs=[in_num, in_img, page_range_txt]
|
|
|
138 |
)
|
139 |
in_num.change(
|
140 |
fn=show_image,
|
141 |
inputs=[in_file, in_num],
|
142 |
-
outputs=[in_num, in_img, page_range_txt]
|
|
|
143 |
)
|
144 |
|
145 |
def check_page_range(page_range, file):
|
@@ -156,11 +159,36 @@ with gr.Blocks(title="Marker") as demo:
|
|
156 |
page_range_txt.change(
|
157 |
fn=check_page_range,
|
158 |
inputs=[page_range_txt, in_file],
|
159 |
-
outputs=[page_range_txt, run_marker_btn]
|
|
|
160 |
)
|
161 |
|
162 |
# Run Marker
|
163 |
def run_marker_img(filename, page_range, force_ocr, output_format, debug, use_llm, strip_existing_ocr):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
cli_options = {
|
165 |
"output_format": output_format,
|
166 |
"page_range": page_range,
|
@@ -224,4 +252,4 @@ with gr.Blocks(title="Marker") as demo:
|
|
224 |
)
|
225 |
|
226 |
if __name__ == "__main__":
|
227 |
-
demo.launch()
|
|
|
86 |
with gr.Blocks(title="Marker") as demo:
|
87 |
gr.Markdown("""
|
88 |
# Marker Demo
|
89 |
+

|
90 |
This app will let you try marker, a PDF -> Markdown converter. It works with any languages, and extracts images, tables, equations, etc.
|
91 |
|
92 |
Find the project [here](https://github.com/VikParuchuri/marker).
|
|
|
129 |
in_file.clear(
|
130 |
fn=show_image,
|
131 |
inputs=[in_file],
|
132 |
+
outputs=[in_num, in_img, page_range_txt],
|
133 |
+
api_name=False
|
134 |
)
|
135 |
in_file.upload(
|
136 |
fn=show_image,
|
137 |
inputs=[in_file],
|
138 |
+
outputs=[in_num, in_img, page_range_txt],
|
139 |
+
api_name=False
|
140 |
)
|
141 |
in_num.change(
|
142 |
fn=show_image,
|
143 |
inputs=[in_file, in_num],
|
144 |
+
outputs=[in_num, in_img, page_range_txt],
|
145 |
+
api_name=False
|
146 |
)
|
147 |
|
148 |
def check_page_range(page_range, file):
|
|
|
159 |
page_range_txt.change(
|
160 |
fn=check_page_range,
|
161 |
inputs=[page_range_txt, in_file],
|
162 |
+
outputs=[page_range_txt, run_marker_btn],
|
163 |
+
api_name=False
|
164 |
)
|
165 |
|
166 |
# Run Marker
|
167 |
def run_marker_img(filename, page_range, force_ocr, output_format, debug, use_llm, strip_existing_ocr):
|
168 |
+
"""
|
169 |
+
Run marker on the given PDF file and return processed results in multiple formats.
|
170 |
+
|
171 |
+
Args:
|
172 |
+
filename (str): Path to the input PDF file.
|
173 |
+
page_range (str): Page range to process (e.g., "0-5").
|
174 |
+
force_ocr (bool, optional): If True (default), force OCR even on text-based PDFs.
|
175 |
+
output_format (str, optional): Output format. One of: "markdown", "html", "json".
|
176 |
+
Defaults to "markdown".
|
177 |
+
debug (bool, optional): If True, return additional debug images (rendered page and layout).
|
178 |
+
Defaults to False.
|
179 |
+
use_llm (bool, optional): If True, use LLM-assisted parsing for better semantic output.
|
180 |
+
Defaults to False.
|
181 |
+
strip_existing_ocr (bool, optional): If True, strip embedded OCR text and re-run OCR.
|
182 |
+
Defaults to False.
|
183 |
+
|
184 |
+
Returns:
|
185 |
+
tuple:
|
186 |
+
- markdown_result (str): Markdown output string.
|
187 |
+
- json_result (str): JSON output string.
|
188 |
+
- html_result (str): HTML output string.
|
189 |
+
- page_image (dict or None): Rendered image of PDF page (if debug is True, else None).
|
190 |
+
- layout_image (dict or None): Visualized layout image (if debug is True, else None).
|
191 |
+
"""
|
192 |
cli_options = {
|
193 |
"output_format": output_format,
|
194 |
"page_range": page_range,
|
|
|
252 |
)
|
253 |
|
254 |
if __name__ == "__main__":
|
255 |
+
demo.launch(server_name="0.0.0.0", server_port=7860, mcp_server=True, ssr_mode=False)
|
requirements.txt
CHANGED
@@ -1,4 +1,9 @@
|
|
1 |
torch==2.5.1
|
2 |
marker-pdf==1.2.3
|
3 |
-
gradio==5.
|
4 |
-
huggingface-hub==0.26.3
|
|
|
|
|
|
|
|
|
|
|
|
1 |
torch==2.5.1
|
2 |
marker-pdf==1.2.3
|
3 |
+
gradio[mcp]==5.28.0
|
4 |
+
huggingface-hub==0.26.3
|
5 |
+
|
6 |
+
# gradio[mcp] 5.28.0 depends on pydantic>=2.11
|
7 |
+
pydantic==2.11.4
|
8 |
+
# fix mcp bug https://github.com/modelcontextprotocol/python-sdk/issues/101
|
9 |
+
mcp==1.7.1
|