output_file.md 21.9 KB
Newer Older
Sidney233's avatar
Sidney233 committed
1
# Overview
2

3
After executing the `mineru` command, in addition to outputting files related to markdown, several other files unrelated to markdown will also be generated. These files will be introduced one by one.
sfk's avatar
sfk committed
4

Sidney233's avatar
Sidney233 committed
5
## some_pdf_layout.pdf
sfk's avatar
sfk committed
6

7
Each page's layout consists of one or more bounding boxes. The number in the top-right corner of each box indicates the reading order. Additionally, different content blocks are highlighted with distinct background colors within the layout.pdf.
Sidney233's avatar
Sidney233 committed
8
![layout example](../images/layout_example.png)
sfk's avatar
sfk committed
9

Sidney233's avatar
Sidney233 committed
10
## some_pdf_spans.pdf(Applicable only to the pipeline backend)
sfk's avatar
sfk committed
11
12
13

All spans on the page are drawn with different colored line frames according to the span type. This file can be used for quality control, allowing for quick identification of issues such as missing text or unrecognized inline formulas.

Sidney233's avatar
Sidney233 committed
14
![spans example](../images/spans_example.png)
sfk's avatar
sfk committed
15

Sidney233's avatar
Sidney233 committed
16
## some_pdf_model.json(Applicable only to the pipeline backend)
sfk's avatar
sfk committed
17

Sidney233's avatar
Sidney233 committed
18
### Structure Definition
19

sfk's avatar
sfk committed
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
```python
from pydantic import BaseModel, Field
from enum import IntEnum

class CategoryType(IntEnum):
     title = 0               # Title
     plain_text = 1          # Text
     abandon = 2             # Includes headers, footers, page numbers, and page annotations
     figure = 3              # Image
     figure_caption = 4      # Image description
     table = 5               # Table
     table_caption = 6       # Table description
     table_footnote = 7      # Table footnote
     isolate_formula = 8     # Block formula
     formula_caption = 9     # Formula label
35

sfk's avatar
sfk committed
36
37
38
     embedding = 13          # Inline formula
     isolated = 14           # Block formula
     text = 15               # OCR recognition result
39
40


sfk's avatar
sfk committed
41
42
43
44
45
46
47
48
49
50
51
class PageInfo(BaseModel):
    page_no: int = Field(description="Page number, the first page is 0", ge=0)
    height: int = Field(description="Page height", gt=0)
    width: int = Field(description="Page width", ge=0)

class ObjectInferenceResult(BaseModel):
    category_id: CategoryType = Field(description="Category", ge=0)
    poly: list[float] = Field(description="Quadrilateral coordinates, representing the coordinates of the top-left, top-right, bottom-right, and bottom-left points respectively")
    score: float = Field(description="Confidence of the inference result")
    latex: str | None = Field(description="LaTeX parsing result", default=None)
    html: str | None = Field(description="HTML parsing result", default=None)
52

sfk's avatar
sfk committed
53
54
55
class PageInferenceResults(BaseModel):
     layout_dets: list[ObjectInferenceResult] = Field(description="Page recognition results", ge=0)
     page_info: PageInfo = Field(description="Page metadata")
56
57


sfk's avatar
sfk committed
58
59
60
61
62
# The inference results of all pages, ordered by page number, are stored in a list as the inference results of MinerU
inference_result: list[PageInferenceResults] = []

```

63
The format of the poly coordinates is \[x0, y0, x1, y1, x2, y2, x3, y3\], representing the coordinates of the top-left, top-right, bottom-right, and bottom-left points respectively.
Sidney233's avatar
Sidney233 committed
64
![Poly Coordinate Diagram](../images/poly.png)
sfk's avatar
sfk committed
65

Sidney233's avatar
Sidney233 committed
66
### example
sfk's avatar
sfk committed
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118

```json
[
    {
        "layout_dets": [
            {
                "category_id": 2,
                "poly": [
                    99.1906967163086,
                    100.3119125366211,
                    730.3707885742188,
                    100.3119125366211,
                    730.3707885742188,
                    245.81326293945312,
                    99.1906967163086,
                    245.81326293945312
                ],
                "score": 0.9999997615814209
            }
        ],
        "page_info": {
            "page_no": 0,
            "height": 2339,
            "width": 1654
        }
    },
    {
        "layout_dets": [
            {
                "category_id": 5,
                "poly": [
                    99.13092803955078,
                    2210.680419921875,
                    497.3183898925781,
                    2210.680419921875,
                    497.3183898925781,
                    2264.78076171875,
                    99.13092803955078,
                    2264.78076171875
                ],
                "score": 0.9999997019767761
            }
        ],
        "page_info": {
            "page_no": 1,
            "height": 2339,
            "width": 1654
        }
    }
]
```

Sidney233's avatar
Sidney233 committed
119
## some_pdf_model_output.txt (Applicable only to the VLM backend)
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

This file contains the output of the VLM model, with each page's output separated by `----`.  
Each page's output consists of text blocks starting with `<|box_start|>` and ending with `<|md_end|>`.  
The meaning of each field is as follows:  
- `<|box_start|>x0 y0 x1 y1<|box_end|>`  
  x0 y0 x1 y1 represent the coordinates of a quadrilateral, indicating the top-left and bottom-right points. The values are based on a normalized page size of 1000x1000.
- `<|ref_start|>type<|ref_end|>`  
  `type` indicates the block type. Possible values are:
  ```json
  {
      "text": "Text",
      "title": "Title",
      "image": "Image",
      "image_caption": "Image Caption",
      "image_footnote": "Image Footnote",
      "table": "Table",
      "table_caption": "Table Caption",
      "table_footnote": "Table Footnote",
      "equation": "Interline Equation"
  }
  ```
- `<|md_start|>Markdown content<|md_end|>`  
  This field contains the Markdown content of the block. If `type` is `text`, the end of the text may contain the `<|txt_contd|>` tag, indicating that this block can be connected with the following `text` block(s).
  If `type` is `table`, the content is in `otsl` format and needs to be converted into HTML for rendering in Markdown.

Sidney233's avatar
Sidney233 committed
145
## some_pdf_middle.json
sfk's avatar
sfk committed
146

147
| Field Name     | Description                                                                                                    |
148
|:---------------| :------------------------------------------------------------------------------------------------------------- |
149
| pdf_info       | list, each element is a dict representing the parsing result of each PDF page, see the table below for details |
150
151
| \_backend      | pipeline \| vlm, used to indicate the mode used in this intermediate parsing state                                  |
| \_version_name | string, indicates the version of mineru used in this parsing                                                |
sfk's avatar
sfk committed
152
153
154
155
156
157
158

<br>

**pdf_info**

Field structure description

159
160
161
162
163
164
165
166
167
168
169
170
| Field Name          | Description                                                                                                        |
| :------------------ | :----------------------------------------------------------------------------------------------------------------- |
| preproc_blocks      | Intermediate result after PDF preprocessing, not yet segmented                                                     |
| layout_bboxes       | Layout segmentation results, containing layout direction (vertical, horizontal), and bbox, sorted by reading order |
| page_idx            | Page number, starting from 0                                                                                       |
| page_size           | Page width and height                                                                                              |
| \_layout_tree       | Layout tree structure                                                                                              |
| images              | list, each element is a dict representing an img_block                                                             |
| tables              | list, each element is a dict representing a table_block                                                            |
| interline_equations | list, each element is a dict representing an interline_equation_block                                              |
| discarded_blocks    | List, block information returned by the model that needs to be dropped                                             |
| para_blocks         | Result after segmenting preproc_blocks                                                                             |
sfk's avatar
sfk committed
171
172
173
174
175
176
177
178
179

In the above table, `para_blocks` is an array of dicts, each dict representing a block structure. A block can support up to one level of nesting.

<br>

**block**

The outer block is referred to as a first-level block, and the fields in the first-level block include:

180
181
182
183
184
| Field Name | Description                                                    |
| :--------- | :------------------------------------------------------------- |
| type       | Block type (table\|image)                                      |
| bbox       | Block bounding box coordinates                                 |
| blocks     | list, each element is a dict representing a second-level block |
sfk's avatar
sfk committed
185
186
187
188
189
190

<br>
There are only two types of first-level blocks: "table" and "image". All other blocks are second-level blocks.

The fields in a second-level block include:

191
192
193
194
195
| Field Name | Description                                                                                                 |
| :--------- | :---------------------------------------------------------------------------------------------------------- |
| type       | Block type                                                                                                  |
| bbox       | Block bounding box coordinates                                                                              |
| lines      | list, each element is a dict representing a line, used to describe the composition of a line of information |
sfk's avatar
sfk committed
196
197
198

Detailed explanation of second-level block types

199
200
| type               | Description            |
| :----------------- | :--------------------- |
sfk's avatar
sfk committed
201
202
| image_body         | Main body of the image |
| image_caption      | Image description text |
203
| image_footnote     | Image footnote         |
sfk's avatar
sfk committed
204
205
| table_body         | Main body of the table |
| table_caption      | Table description text |
206
207
208
| table_footnote     | Table footnote         |
| text               | Text block             |
| title              | Title block            |
209
210
| index              | Index block            |
| list               | List block             |
211
| interline_equation | Block formula          |
sfk's avatar
sfk committed
212
213
214
215
216
217
218

<br>

**line**

The field format of a line is as follows:

219
220
221
222
| Field Name | Description                                                                                             |
| :--------- | :------------------------------------------------------------------------------------------------------ |
| bbox       | Bounding box coordinates of the line                                                                    |
| spans      | list, each element is a dict representing a span, used to describe the composition of the smallest unit |
sfk's avatar
sfk committed
223
224
225
226
227

<br>

**span**

228
229
230
231
| Field Name          | Description                                                                                              |
| :------------------ | :------------------------------------------------------------------------------------------------------- |
| bbox                | Bounding box coordinates of the span                                                                     |
| type                | Type of the span                                                                                         |
sfk's avatar
sfk committed
232
233
234
235
| content \| img_path | Text spans use content, chart spans use img_path to store the actual text or screenshot path information |

The types of spans are as follows:

236
237
238
239
240
241
242
| type               | Description    |
| :----------------- | :------------- |
| image              | Image          |
| table              | Table          |
| text               | Text           |
| inline_equation    | Inline formula |
| interline_equation | Block formula  |
sfk's avatar
sfk committed
243
244
245
246
247
248
249
250
251
252
253

**Summary**

A span is the smallest storage unit for all elements.

The elements stored within para_blocks are block information.

The block structure is as follows:

First-level block (if any) -> Second-level block -> Line -> Span

Sidney233's avatar
Sidney233 committed
254
### example
sfk's avatar
sfk committed
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351

```json
{
    "pdf_info": [
        {
            "preproc_blocks": [
                {
                    "type": "text",
                    "bbox": [
                        52,
                        61.956024169921875,
                        294,
                        82.99800872802734
                    ],
                    "lines": [
                        {
                            "bbox": [
                                52,
                                61.956024169921875,
                                294,
                                72.0000228881836
                            ],
                            "spans": [
                                {
                                    "bbox": [
                                        54.0,
                                        61.956024169921875,
                                        296.2261657714844,
                                        72.0000228881836
                                    ],
                                    "content": "dependent on the service headway and the reliability of the departure ",
                                    "type": "text",
                                    "score": 1.0
                                }
                            ]
                        }
                    ]
                }
            ],
            "layout_bboxes": [
                {
                    "layout_bbox": [
                        52,
                        61,
                        294,
                        731
                    ],
                    "layout_label": "V",
                    "sub_layout": []
                }
            ],
            "page_idx": 0,
            "page_size": [
                612.0,
                792.0
            ],
            "_layout_tree": [],
            "images": [],
            "tables": [],
            "interline_equations": [],
            "discarded_blocks": [],
            "para_blocks": [
                {
                    "type": "text",
                    "bbox": [
                        52,
                        61.956024169921875,
                        294,
                        82.99800872802734
                    ],
                    "lines": [
                        {
                            "bbox": [
                                52,
                                61.956024169921875,
                                294,
                                72.0000228881836
                            ],
                            "spans": [
                                {
                                    "bbox": [
                                        54.0,
                                        61.956024169921875,
                                        296.2261657714844,
                                        72.0000228881836
                                    ],
                                    "content": "dependent on the service headway and the reliability of the departure ",
                                    "type": "text",
                                    "score": 1.0
                                }
                            ]
                        }
                    ]
                }
            ]
        }
    ],
352
    "_backend": "pipeline",
sfk's avatar
sfk committed
353
354
355
    "_version_name": "0.6.1"
}
```
356
357


Sidney233's avatar
Sidney233 committed
358
## some_pdf_content_list.json
359
360
361
362

This file is a JSON array where each element is a dict storing all readable content blocks in the document in reading order.  
`content_list` can be viewed as a simplified version of `middle.json`. The content block types are mostly consistent with those in `middle.json`, but layout information is not included.  

363
364
365
366
367
368
369
370
371
The content has the following types:

| type     | desc          |
|:---------|:--------------|
| image    | Image         |
| table    | Table         |
| text     | Text / Title  |
| equation | Block formula |

372
373
374
375
376
Please note that both `title` and text blocks in `content_list` are uniformly represented using the text type. The `text_level` field is used to distinguish the hierarchy of text blocks:
- A block without the `text_level` field or with `text_level=0` represents body text.
- A block with `text_level=1` represents a level-1 heading.
- A block with `text_level=2` represents a level-2 heading, and so on.

377
378
Each content contains the `page_idx` field, indicating the page number (starting from 0) where the content block resides.

Sidney233's avatar
Sidney233 committed
379
### example
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440

```json
[
        {
        "type": "text",
        "text": "The response of flow duration curves to afforestation ",
        "text_level": 1,
        "page_idx": 0
    },
    {
        "type": "text",
        "text": "Received 1 October 2003; revised 22 December 2004; accepted 3 January 2005 ",
        "page_idx": 0
    },
    {
        "type": "text",
        "text": "Abstract ",
        "text_level": 2,
        "page_idx": 0
    },
    {
        "type": "text",
        "text": "The hydrologic effect of replacing pasture or other short crops with trees is reasonably well understood on a mean annual basis. The impact on flow regime, as described by the annual flow duration curve (FDC) is less certain. A method to assess the impact of plantation establishment on FDCs was developed. The starting point for the analyses was the assumption that rainfall and vegetation age are the principal drivers of evapotranspiration. A key objective was to remove the variability in the rainfall signal, leaving changes in streamflow solely attributable to the evapotranspiration of the plantation. A method was developed to (1) fit a model to the observed annual time series of FDC percentiles; i.e. 10th percentile for each year of record with annual rainfall and plantation age as parameters, (2) replace the annual rainfall variation with the long term mean to obtain climate adjusted FDCs, and (3) quantify changes in FDC percentiles as plantations age. Data from 10 catchments from Australia, South Africa and New Zealand were used. The model was able to represent flow variation for the majority of percentiles at eight of the 10 catchments, particularly for the 10–50th percentiles. The adjusted FDCs revealed variable patterns in flow reductions with two types of responses (groups) being identified. Group 1 catchments show a substantial increase in the number of zero flow days, with low flows being more affected than high flows. Group 2 catchments show a more uniform reduction in flows across all percentiles. The differences may be partly explained by storage characteristics. The modelled flow reductions were in accord with published results of paired catchment experiments. An additional analysis was performed to characterise the impact of afforestation on the number of zero flow days $( N _ { \\mathrm { z e r o } } )$ for the catchments in group 1. This model performed particularly well, and when adjusted for climate, indicated a significant increase in $N _ { \\mathrm { z e r o } }$ . The zero flow day method could be used to determine change in the occurrence of any given flow in response to afforestation. The methods used in this study proved satisfactory in removing the rainfall variability, and have added useful insight into the hydrologic impacts of plantation establishment. This approach provides a methodology for understanding catchment response to afforestation, where paired catchment data is not available. ",
        "page_idx": 0
    },
    {
        "type": "text",
        "text": "1. Introduction ",
        "text_level": 2,
        "page_idx": 1
    },
    {
        "type": "image",
        "img_path": "images/a8ecda1c69b27e4f79fce1589175a9d721cbdc1cf78b4cc06a015f3746f6b9d8.jpg",
        "img_caption": [
            "Fig. 1. Annual flow duration curves of daily flows from Pine Creek, Australia, 1989–2000. "
        ],
        "img_footnote": [],
        "page_idx": 1
    },
    {
        "type": "equation",
        "img_path": "images/181ea56ef185060d04bf4e274685f3e072e922e7b839f093d482c29bf89b71e8.jpg",
        "text": "$$\nQ _ { \\% } = f ( P ) + g ( T )\n$$",
        "text_format": "latex",
        "page_idx": 2
    },
    {
        "type": "table",
        "img_path": "images/e3cb413394a475e555807ffdad913435940ec637873d673ee1b039e3bc3496d0.jpg",
        "table_caption": [
            "Table 2 Significance of the rainfall and time terms "
        ],
        "table_footnote": [
            "indicates that the rainfall term was significant at the $5 \\%$ level, $T$ indicates that the time term was significant at the $5 \\%$ level, \\* represents significance at the $10 \\%$ level, and na denotes too few data points for meaningful analysis. "
        ],
        "table_body": "<html><body><table><tr><td rowspan=\"2\">Site</td><td colspan=\"10\">Percentile</td></tr><tr><td>10</td><td>20</td><td>30</td><td>40</td><td>50</td><td>60</td><td>70</td><td>80</td><td>90</td><td>100</td></tr><tr><td>Traralgon Ck</td><td>P</td><td>P,*</td><td>P</td><td>P</td><td>P,</td><td>P,</td><td>P,</td><td>P,</td><td>P</td><td>P</td></tr><tr><td>Redhill</td><td>P,T</td><td>P,T</td><td>,*</td><td>**</td><td>P.T</td><td>P,*</td><td>P*</td><td>P*</td><td>*</td><td>,*</td></tr><tr><td>Pine Ck</td><td></td><td>P,T</td><td>P,T</td><td>P,T</td><td>P,T</td><td>T</td><td>T</td><td>T</td><td>na</td><td>na</td></tr><tr><td>Stewarts Ck 5</td><td>P,T</td><td>P,T</td><td>P,T</td><td>P,T</td><td>P.T</td><td>P.T</td><td>P,T</td><td>na</td><td>na</td><td>na</td></tr><tr><td>Glendhu 2</td><td>P</td><td>P,T</td><td>P,*</td><td>P,T</td><td>P.T</td><td>P,ns</td><td>P,T</td><td>P,T</td><td>P,T</td><td>P,T</td></tr><tr><td>Cathedral Peak 2</td><td>P,T</td><td>P,T</td><td>P,T</td><td>P,T</td><td>P,T</td><td>*,T</td><td>P,T</td><td>P,T</td><td>P,T</td><td>T</td></tr><tr><td>Cathedral Peak 3</td><td>P.T</td><td>P.T</td><td>P,T</td><td>P,T</td><td>P,T</td><td>T</td><td>P,T</td><td>P,T</td><td>P,T</td><td>T</td></tr><tr><td>Lambrechtsbos A</td><td>P,T</td><td>P</td><td>P</td><td>P,T</td><td>*,T</td><td>*,T</td><td>*,T</td><td>*,T</td><td>*,T</td><td>T</td></tr><tr><td>Lambrechtsbos B</td><td>P,T</td><td>P,T</td><td>P,T</td><td>P,T</td><td>P,T</td><td>P,T</td><td>P,T</td><td>P,T</td><td>T</td><td>T</td></tr><tr><td>Biesievlei</td><td>P,T</td><td>P.T</td><td>P,T</td><td>P,T</td><td>*,T</td><td>*,T</td><td>T</td><td>T</td><td>P,T</td><td>P,T</td></tr></table></body></html>",
        "page_idx": 5
    }
]
```