File size: 657 Bytes
145d936
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import argparse
import os

from marker.convert import convert_single_pdf
from marker.logger import configure_logging
from marker.models import load_all_models

import spaces
import gradio as gr
from marker.output import save_markdown


@spaces.GPU
def convert(file_path):
    model_lst = load_all_models()
    full_text, images, out_meta = convert_single_pdf(
        file_path,
        model_lst,
        max_pages=None,
        langs=None,
        batch_multiplier=16,
    )

    return full_text


gr.Interface(
    convert,
    inputs=gr.File(label="PDF file", sources=["upload"], type="filepath"),
    outputs=gr.Markdown(label="Markdown"),
).launch()