Spaces:
Running
on
L4
Running
on
L4
Update app.py
Browse files
app.py
CHANGED
@@ -19,15 +19,23 @@ os.system('wget https://github.com/opendatalab/MinerU/raw/dev/scripts/download_m
|
|
19 |
os.system('python download_models_hf.py')
|
20 |
|
21 |
with open('/home/user/magic-pdf.json', 'r') as file:
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
-
data['device-mode'] = "cuda"
|
25 |
if os.getenv('apikey'):
|
26 |
-
|
27 |
-
|
28 |
|
29 |
with open('/home/user/magic-pdf.json', 'w') as file:
|
30 |
-
json.dump(
|
31 |
|
32 |
# os.system('cp -r paddleocr /home/user/.paddleocr')
|
33 |
from gradio_pdf import PDF
|
@@ -143,8 +151,8 @@ def to_markdown(file_path, end_pages, is_ocr, layout_mode, formula_enable, table
|
|
143 |
return md_content, txt_content, archive_zip_path, new_pdf_path
|
144 |
|
145 |
|
146 |
-
latex_delimiters = [{"left": "$$", "right": "$$", "display": True},
|
147 |
-
|
148 |
|
149 |
|
150 |
def init_model():
|
@@ -247,7 +255,8 @@ if __name__ == "__main__":
|
|
247 |
with gr.Tabs():
|
248 |
with gr.Tab("Markdown rendering"):
|
249 |
md = gr.Markdown(label="Markdown rendering", height=1100, show_copy_button=True,
|
250 |
-
latex_delimiters=latex_delimiters,
|
|
|
251 |
with gr.Tab("Markdown text"):
|
252 |
md_text = gr.TextArea(lines=45, show_copy_button=True)
|
253 |
file.change(fn=to_pdf, inputs=file, outputs=pdf_show)
|
|
|
19 |
os.system('python download_models_hf.py')
|
20 |
|
21 |
with open('/home/user/magic-pdf.json', 'r') as file:
|
22 |
+
config = json.load(file)
|
23 |
+
|
24 |
+
config['device-mode'] = "cuda"
|
25 |
+
|
26 |
+
latex_delimiters = {
|
27 |
+
'display': {'left': '\\[', 'right': '\\]'},
|
28 |
+
'inline': {'left': '\\(', 'right': '\\)'}
|
29 |
+
}
|
30 |
+
|
31 |
+
config['latex-delimiter-config'] = latex_delimiters
|
32 |
|
|
|
33 |
if os.getenv('apikey'):
|
34 |
+
config['llm-aided-config']['title_aided']['api_key'] = os.getenv('apikey')
|
35 |
+
config['llm-aided-config']['title_aided']['enable'] = True
|
36 |
|
37 |
with open('/home/user/magic-pdf.json', 'w') as file:
|
38 |
+
json.dump(config, file, indent=4)
|
39 |
|
40 |
# os.system('cp -r paddleocr /home/user/.paddleocr')
|
41 |
from gradio_pdf import PDF
|
|
|
151 |
return md_content, txt_content, archive_zip_path, new_pdf_path
|
152 |
|
153 |
|
154 |
+
# latex_delimiters = [{"left": "$$", "right": "$$", "display": True},
|
155 |
+
# {"left": '$', "right": '$', "display": False}]
|
156 |
|
157 |
|
158 |
def init_model():
|
|
|
255 |
with gr.Tabs():
|
256 |
with gr.Tab("Markdown rendering"):
|
257 |
md = gr.Markdown(label="Markdown rendering", height=1100, show_copy_button=True,
|
258 |
+
# latex_delimiters=latex_delimiters,
|
259 |
+
line_breaks=True)
|
260 |
with gr.Tab("Markdown text"):
|
261 |
md_text = gr.TextArea(lines=45, show_copy_button=True)
|
262 |
file.change(fn=to_pdf, inputs=file, outputs=pdf_show)
|