From 4bae02c2951f3d6fce9dfc2cd5ccdedae42be662 Mon Sep 17 00:00:00 2001 From: myhloli Date: Wed, 27 May 2026 23:19:24 +0800 Subject: [PATCH] feat: refactor finalize_middle_json to support server-side post-processing and enhance title leveling --- mineru/backend/hybrid/hybrid_analyze.py | 3 ++- mineru/cli/client.py | 6 +++++- mineru/cli/gradio_app.py | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/mineru/backend/hybrid/hybrid_analyze.py b/mineru/backend/hybrid/hybrid_analyze.py index 0c84c455..da70bbbd 100644 --- a/mineru/backend/hybrid/hybrid_analyze.py +++ b/mineru/backend/hybrid/hybrid_analyze.py @@ -989,7 +989,8 @@ async def aio_doc_analyze( ) if client_side_output_generation: - apply_server_side_postprocess( + await asyncio.to_thread( + apply_server_side_postprocess, middle_json["pdf_info"], hybrid_pipeline_model, _ocr_enable, diff --git a/mineru/cli/client.py b/mineru/cli/client.py index d90727d3..0af1f7d6 100644 --- a/mineru/cli/client.py +++ b/mineru/cli/client.py @@ -820,7 +820,11 @@ async def run_planned_task( parse_method, is_office=document.suffix in office_suffixes, ) - regenerate_client_side_outputs(parse_dir, document.stem) + await asyncio.to_thread( + regenerate_client_side_outputs, + parse_dir, + document.stem, + ) completed_tasks, completed_pages = await mark_task_completed( progress, planned_task.total_pages, diff --git a/mineru/cli/gradio_app.py b/mineru/cli/gradio_app.py index b3ff0c54..509a3095 100644 --- a/mineru/cli/gradio_app.py +++ b/mineru/cli/gradio_app.py @@ -1073,8 +1073,9 @@ async def _run_to_markdown_job( parse_method, allow_office_fallback=True, ) + emit_status(STATUS_PROCESSING_OUTPUT) if use_client_side_output_generation: - regenerate_client_side_outputs(local_md_dir, file_name) + await asyncio.to_thread(regenerate_client_side_outputs, local_md_dir, file_name) preview_pdf_path = maybe_generate_local_preview( extract_root=extract_root, @@ -1084,7 +1085,6 @@ async def _run_to_markdown_job( parse_method=parse_method, ) - emit_status(STATUS_PROCESSING_OUTPUT) zip_archive_success = compress_directory_to_zip(local_md_dir, archive_zip_path) if zip_archive_success == 0: logger.info('Compression successful')