Commit fc5f330c authored by myhloli's avatar myhloli
Browse files

fix: handle exceptions in parsing and return None on failure

parent e13b0a70
......@@ -28,6 +28,7 @@ async def parse_pdf(doc_path, output_dir, end_page_id, is_ocr, formula_enable, t
if backend.startswith("vlm"):
parse_method = "vlm"
url = None
local_image_dir, local_md_dir = prepare_env(output_dir, file_name, parse_method)
await aio_do_parse(
output_dir=output_dir,
......@@ -44,6 +45,7 @@ async def parse_pdf(doc_path, output_dir, end_page_id, is_ocr, formula_enable, t
return local_md_dir, file_name
except Exception as e:
logger.exception(e)
return None
def compress_directory_to_zip(directory_path, output_zip_path):
......@@ -175,6 +177,21 @@ def to_pdf(file_path):
def main():
example_enable = False
# try:
# print("Start init SgLang engine...")
# from mineru.backend.vlm.vlm_analyze import ModelSingleton
# modelsingleton = ModelSingleton()
# predictor = modelsingleton.get_model(
# "sglang-engine",
# None,
# None,
# mem_fraction_static=0.5,
# enable_torch_compile=True,
# )
# print("SgLang engine init successfully.")
# except Exception as e:
# logger.exception(e)
with gr.Blocks() as demo:
gr.HTML(header)
with gr.Row():
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment