Skip to content

Commit 2528385

Browse files
authored
Merge pull request #4965 from opendatalab/dev
3.1.13
2 parents 853e4aa + f164868 commit 2528385

20 files changed

Lines changed: 3089 additions & 1293 deletions

demo/demo.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,15 @@ def build_form_data(
5050
server_url: str | None,
5151
start_page_id: int,
5252
end_page_id: int | None,
53+
image_analysis: bool = True,
5354
) -> dict[str, str | list[str]]:
5455
return _api_client.build_parse_request_form_data(
5556
lang_list=[language],
5657
backend=backend,
5758
parse_method=parse_method,
5859
formula_enable=formula_enable,
5960
table_enable=table_enable,
61+
image_analysis=image_analysis,
6062
server_url=server_url,
6163
start_page_id=start_page_id,
6264
end_page_id=end_page_id,
@@ -98,6 +100,7 @@ async def run_demo(
98100
language: str = "ch",
99101
formula_enable: bool = True,
100102
table_enable: bool = True,
103+
image_analysis: bool = True,
101104
server_url: str | None = None,
102105
start_page_id: int = 0,
103106
end_page_id: int | None = None,
@@ -117,6 +120,7 @@ async def run_demo(
117120
parse_method=parse_method,
118121
formula_enable=formula_enable,
119122
table_enable=table_enable,
123+
image_analysis=image_analysis,
120124
server_url=server_url,
121125
start_page_id=start_page_id,
122126
end_page_id=end_page_id,
@@ -225,6 +229,8 @@ def main() -> None:
225229
formula_enable = True
226230
# Enable table parsing in the output.
227231
table_enable = True
232+
# Enable image/chart analysis for VLM and hybrid backends.
233+
image_analysis = True
228234
# Required only for "*-http-client" backends, for example:
229235
# "http://127.0.0.1:30000"
230236
server_url = None
@@ -245,6 +251,7 @@ def main() -> None:
245251
language=language,
246252
formula_enable=formula_enable,
247253
table_enable=table_enable,
254+
image_analysis=image_analysis,
248255
server_url=server_url,
249256
start_page_id=start_page_id,
250257
end_page_id=end_page_id,

demo/office_docs/docx_01.docx

-10 Bytes
Binary file not shown.

demo/office_docs/pptx_01.pptx

1.45 KB
Binary file not shown.

docs/en/reference/output_files.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,12 @@ Text levels are distinguished through the `text_level` field:
429429
| `list` / `index` | List and index blocks with `list_items` |
430430
| `page_header` / `page_footer` / `page_number` / `page_aside_text` / `page_footnote` | Page auxiliary blocks |
431431

432+
Inline fields such as `title_content`, `paragraph_content`, and captions are
433+
usually span lists. A `hyperlink` span contains `content` and `url`; when one
434+
link contains text fragments with different styles, it may also contain
435+
`children`. In that case, `content` is the concatenated child text, and the
436+
exact styles are represented by the child `text` spans.
437+
432438
##### Sample Data
433439

434440
```json

docs/zh/reference/output_files.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,11 @@
429429
| `list` / `index` | 列表与索引,包含 `list_items` |
430430
| `page_header` / `page_footer` / `page_number` / `page_aside_text` / `page_footnote` | 页面辅助块 |
431431

432+
`title_content``paragraph_content`、说明文字等行内内容通常由 span 列表组成。
433+
`hyperlink` span 包含 `content``url`,当同一个链接内存在多段不同样式文本时,
434+
还会包含 `children`;此时 `content` 是 children 文本的拼接,精确样式以
435+
`children` 中的 `text` span 为准。
436+
432437
##### 示例数据
433438

434439
```json

mineru/backend/hybrid/hybrid_magic_model.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ def __init__(
156156
block_type = BlockType.INTERLINE_EQUATION
157157
span_type = ContentType.INTERLINE_EQUATION
158158

159+
if span_type == ContentType.TEXT and block_content is None:
160+
# 文本类块缺失 content 时按空文本处理,避免 VLM mkcontent 渲染阶段遇到 None。
161+
block_content = ""
162+
159163
# code 和 algorithm 类型的块,如果内容中包含行内公式,则需要将块类型切换为 algorithm
160164
switch_code_to_algorithm = False
161165

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Copyright (c) Opendatalab. All rights reserved.

0 commit comments

Comments
 (0)