Commit Graph
91 Commits
Author SHA1 Message Date
myhloli c660fdc8f0 feat(llm): add LLM-aided formula and text correction
- Add LLM-aided formula and text correction functionality
- Update config reader to include LLM-aided settings
- Create new LLM-aided processing module
- Update main processing script to incorporate LLM-aided corrections
- Modify download scripts to check for new config version
2024-12-24 14:33:35 +08:00
myhloli c638fc5d1f fix(pdf): improve ligature handling and text extraction
- Move ligature replacement function to pdf_parse_union_core_v2.py
- Optimize ligature replacement using a more efficient approach
- Modify text extraction flags to preserve ligatures in PDF content
- Remove unnecessary function from ocr_mkcontent.py
2024-12-13 15:43:05 +08:00
myhloli 74ee428bbb fix(dict2md): add space for inline equations in CJK contexts
- In Chinese, Japanese, and Korean (CJK) languages, no space is needed for line breaks within paragraphs.
- However, if an inline equation is at the end of a line, a space should be added to separate it from the following text.
- This change improves the formatting of documents containing both CJK text and inline equations.
2024-12-07 17:53:54 +08:00
myhloli b80befe9cf refactor(mkcontent): optimize paragraph text merging and language detection
- Extract language detection to block level instead of line level
- Improve logic for handling Chinese, Japanese, and Korean languages
- Refactor code for better readability and performance
- Optimize handling of hyphenated words at line ends
2024-11-30 02:16:38 +08:00
myhloli c8cabb3cf6 feat(ocr_mkcontent): add language detection for line spacing
- Introduce language detection to determine line spacing based on language context
- Implement different spacing rules for Chinese/Japanese/Korean and Western texts
- Adjust span content handling based on detected language and span type
2024-11-30 01:14:12 +08:00
myhloli 782e6571bc fix(ocr_mkcontent): handle empty paragraphs on pages
- Add empty paragraph handling for pages with no content
- Append an empty markdown object when a page has no paragraphs
- Increment page number even if no content is present
2024-11-29 11:58:34 +08:00
myhloli 88c0854a65 refactor(ocr): improve text processing and span handling
- Remove unused language detection code
- Simplify text content processing logic
- Update span sorting and text extraction in pdf_parse_union_core_v2.py
2024-11-28 19:38:30 +08:00
myhloli 6a22b5ab7a refactor(magic_pdf): remove unused functions and simplify code 2024-11-26 17:52:03 +08:00
myhloli ecdaa49aee refactor(magic_pdf): remove unused functions and simplify code 2024-11-26 17:34:07 +08:00
Xiaomeng Zhao 23c8436ef9 Merge pull request #1047 from myhloli/dev
fix(ocr_mkcontent): improve hyphen handling at line ends
2024-11-21 17:50:05 +08:00
myhloli a07007e5e1 fix(ocr_mkcontent): improve hyphen handling at line ends
- fix the bug where hyphens in the middle of a line are being discarded
2024-11-21 17:49:14 +08:00
icecraft b492c19c4c refactor: move some constants or enums defs to config folder 2024-11-19 16:56:53 +08:00
myhloli 2de1d0ef05 fix(ocr_mkcontent): improve handling of single-character content
- Add digit check for single-character content to avoid adding unnecessary spaces
2024-11-13 16:29:16 +08:00
myhloli bd75596219 fix(merge_text): add ligature replacement functionality
- Implement __replace_ligatures function to split ligature characters- Integrate ligature replacement into the merge_para_with_text function
- Handle common ligatures such as fi, fl, ff, ffi, and ffl
2024-11-04 18:44:58 +08:00
myhloli 99cf160d1c fix(dict2md): improve text concatenation logic
- Optimize content stripping and checking logic
- Add special case handling for single-character content
- Adjust spacing rules for different content types
2024-11-03 11:34:13 +08:00
myhloli 87b9eeee59 fix(ocr): handle inline equations consistently with text content
- Include InlineEquation in the condition for handling text content
- Remove separate block for InlineEquation processing
- Ensures consistent handling of inline equations and text, improving content formatting
2024-11-01 23:35:36 +08:00
myhloli 7c03014c2a fix(ocr_mkcontent): improve content handling for different languages and equation types- Adjust content formatting for Chinese, Japanese, Korean, and Western languages
- Implement proper spacing rules around inline equations- Remove unnecessary empty lines in paragraph text
2024-11-01 23:28:53 +08:00
myhloli faf8c286fb fix(magic_pdf): handle missing image_path in spans
- Add check for 'image_path' in spans to avoid errors when it's missing
- Update image handling in both paragraph text and content dictionary
- Improve error handling and make the code more robust
2024-10-30 18:53:41 +08:00
myhloli 0e8d5893eb feat(draw_bbox): update bounding box drawing for tables and images
- Add support for drawing bounding boxes of table and image sub-blocks
- Implement sorting of table blocks based on type order
- Update bounding box drawing for text and title blocks
- Refactor code to handle different block types and their sub-blocks
2024-10-26 19:20:18 +08:00
myhloli c34c9d21ef refactor(ocr): improve image and table block handling
- Split image and table blocks into separate categories
- Add group_id to image and table blocks- Update block processing logic to handle new categories
- Modify layout splitting and span filling to accommodate new block types
- Adjust block indexing and sorting to consider new structures
2024-10-25 17:26:14 +08:00
myhloli 644085760b fix(ocr_mkcontent): expand para_to_standard_format_v2 to handle list and index blocks
- Modified the condition to include List and Index block types- This change enhances the function's capability to process different paragraph types
2024-10-21 17:16:42 +08:00
myhloli fc49f5c446 refactor(magic_pdf): remove unused parameters and simplify functions
- Remove unused parameters parse_type and lang from various functions
- Simplify function calls by removing unnecessary arguments
- Update related files to reflect these changes
2024-10-18 18:51:45 +08:00
myhloli 011a1b973b refactor(ocr):Increase the dilation factor in OCR to address the issue of word concatenation.
- Remove unused functions such as split_long_words, ocr_mk_mm_markdown_with_para, etc.
- Simplify ocr_mk_markdown_with_para_core_v2 by removing unnecessary language detection and word splitting logic- Remove wordninja dependency from requirements
- Update ocr_model_init to include additional parameters for OCR model configuration
2024-10-17 14:42:09 +08:00
myhloli 1f1dd3538d feat(list&index block): detect and merge list and index blocks
- Add detection for list and index blocks in OCR processing- Implement merging of list and index blocks across pages
- Update block types to include list and index categories
- Adjust text merging logic to handle new block types
- Modify layout drawing to distinguish list and index blocks
2024-10-15 00:50:48 +08:00
Xiaomeng Zhao 98313d4a25 Merge branch 'dev' into content-list-not-drop 2024-09-18 16:24:58 +08:00
myhloli 16699a9a70 fix(ocr_mkcontent): streamline drop reason handling 2024-09-18 16:10:42 +08:00
myhloli 196de029a3 fix(ocr_mkcontent): correct drop mode handling for pages with drop reasons 2024-09-18 15:58:14 +08:00
myhloli 37fbe998ac feat(ocr_mkcontent): support drop reason in none_with_reason modeEnable the NONE_WITH_REASON drop mode in para_to_standard_format_v2 by updating the
function signature to include the `drop_reason` parameter and handling it within the
function logic. This enhancement allows the function to convey the reason for dropping
content in the output.
2024-09-18 15:47:36 +08:00
myhloli 6062862c96 feat(pipeline): pass language parameter for parsing and markdown conversion
The pipeline now supports passing the language parameter to parsing functions and
during markdown conversion to optimize processing based on the specified language.
This enhancement allows for more accurate parsing and markdown generation, particularly
when dealing with non-English content.
2024-09-12 12:13:51 +08:00
icecraftandicecraft 03469909bb Feat/support footnote in figure (#532)
* feat: support figure footnote

* feat: using the relative position to combine footnote, table, image

* feat: add the readme of projects

* fix: code spell in unittest

---------

Co-authored-by: icecraft <xurui1@pjlab.org.cn>
2024-09-03 19:16:55 +08:00
d714ac8b76 Release: Release 0.7.1 verison, update dev (#527)
* feat<table model>: add tablemaster with paddleocr to detect and recognize table (#493)

* Update cla.yml

* Update bug_report.yml

* Update README_zh-CN.md (#404)

correct FAQ url

* Update README_zh-CN.md (#404) (#409) (#410)

correct FAQ url

Co-authored-by: sfk <18810651050@163.com>

* Update FAQ_zh_cn.md

add new issue

* Update FAQ_en_us.md

* Update README_Windows_CUDA_Acceleration_zh_CN.md

* Update README_zh-CN.md

* @Thepathakarpit has signed the CLA in opendatalab/MinerU#418

* Update cla.yml

* feat: add tablemaster_paddle (#463)

* Update README_zh-CN.md (#404) (#409)

correct FAQ url

Co-authored-by: sfk <18810651050@163.com>

* add dockerfile (#189)

Co-authored-by: drunkpig <60862764+drunkpig@users.noreply.github.com>

* Update cla.yml

* Update cla.yml

---------

Co-authored-by: drunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: sfk <18810651050@163.com>
Co-authored-by: Aoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: Xiaomeng Zhao <moe@myhloli.com>

* <fix>(para_split_v2): index out of range issue of span_text first char (#396)

Co-authored-by: liukaiwen <liukaiwen@pjlab.org.cn>

* @Matthijz98 has signed the CLA in opendatalab/MinerU#467

* Create download_models.py

* Create requirements-docker.txt

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

* @strongerfly has signed the CLA in opendatalab/MinerU#487

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

---------

Co-authored-by: Xiaomeng Zhao <moe@myhloli.com>
Co-authored-by: sfk <18810651050@163.com>
Co-authored-by: drunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Aoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: liukaiwen <liukaiwen@pjlab.org.cn>

* feat<table model>: add tablemaster with paddleocr to detect and recognize table (#508)

* Update cla.yml

* Update bug_report.yml

* Update README_zh-CN.md (#404)

correct FAQ url

* Update README_zh-CN.md (#404) (#409) (#410)

correct FAQ url

Co-authored-by: sfk <18810651050@163.com>

* Update FAQ_zh_cn.md

add new issue

* Update FAQ_en_us.md

* Update README_Windows_CUDA_Acceleration_zh_CN.md

* Update README_zh-CN.md

* @Thepathakarpit has signed the CLA in opendatalab/MinerU#418

* Update cla.yml

* feat: add tablemaster_paddle (#463)

* Update README_zh-CN.md (#404) (#409)

correct FAQ url

Co-authored-by: sfk <18810651050@163.com>

* add dockerfile (#189)

Co-authored-by: drunkpig <60862764+drunkpig@users.noreply.github.com>

* Update cla.yml

* Update cla.yml

---------

Co-authored-by: drunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: sfk <18810651050@163.com>
Co-authored-by: Aoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: Xiaomeng Zhao <moe@myhloli.com>

* <fix>(para_split_v2): index out of range issue of span_text first char (#396)

Co-authored-by: liukaiwen <liukaiwen@pjlab.org.cn>

* @Matthijz98 has signed the CLA in opendatalab/MinerU#467

* Create download_models.py

* Create requirements-docker.txt

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

* @strongerfly has signed the CLA in opendatalab/MinerU#487

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

* Update cla.yml

* Delete .github/workflows/gpu-ci.yml

* Update Huggingface and ModelScope links to organization account

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

---------

Co-authored-by: Xiaomeng Zhao <moe@myhloli.com>
Co-authored-by: sfk <18810651050@163.com>
Co-authored-by: drunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Aoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: liukaiwen <liukaiwen@pjlab.org.cn>
Co-authored-by: yyy <102640628+dt-yy@users.noreply.github.com>
Co-authored-by: wangbinDL <wangbin_research@163.com>

* feat<table model>: add tablemaster with paddleocr to detect and recognize table (#511)

* Update cla.yml

* Update bug_report.yml

* Update README_zh-CN.md (#404)

correct FAQ url

* Update README_zh-CN.md (#404) (#409) (#410)

correct FAQ url

Co-authored-by: sfk <18810651050@163.com>

* Update FAQ_zh_cn.md

add new issue

* Update FAQ_en_us.md

* Update README_Windows_CUDA_Acceleration_zh_CN.md

* Update README_zh-CN.md

* @Thepathakarpit has signed the CLA in opendatalab/MinerU#418

* Update cla.yml

* feat: add tablemaster_paddle (#463)

* Update README_zh-CN.md (#404) (#409)

correct FAQ url

Co-authored-by: sfk <18810651050@163.com>

* add dockerfile (#189)

Co-authored-by: drunkpig <60862764+drunkpig@users.noreply.github.com>

* Update cla.yml

* Update cla.yml

---------

Co-authored-by: drunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: sfk <18810651050@163.com>
Co-authored-by: Aoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: Xiaomeng Zhao <moe@myhloli.com>

* <fix>(para_split_v2): index out of range issue of span_text first char (#396)

Co-authored-by: liukaiwen <liukaiwen@pjlab.org.cn>

* @Matthijz98 has signed the CLA in opendatalab/MinerU#467

* Create download_models.py

* Create requirements-docker.txt

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

* @strongerfly has signed the CLA in opendatalab/MinerU#487

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

* Update cla.yml

* Delete .github/workflows/gpu-ci.yml

* Update Huggingface and ModelScope links to organization account

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

* feat<table model>: add tablemaster with paddleocr to detect and recognize table

---------

Co-authored-by: Xiaomeng Zhao <moe@myhloli.com>
Co-authored-by: sfk <18810651050@163.com>
Co-authored-by: drunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Aoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: liukaiwen <liukaiwen@pjlab.org.cn>
Co-authored-by: yyy <102640628+dt-yy@users.noreply.github.com>
Co-authored-by: wangbinDL <wangbin_research@163.com>

---------

Co-authored-by: Kaiwen Liu <lkw_buaa@163.com>
Co-authored-by: Xiaomeng Zhao <moe@myhloli.com>
Co-authored-by: sfk <18810651050@163.com>
Co-authored-by: drunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Aoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: liukaiwen <liukaiwen@pjlab.org.cn>
Co-authored-by: wangbinDL <wangbin_research@163.com>
2024-09-02 20:30:20 +08:00
drunkpig 18e65be489 fix: delete hyphen at end of line 2024-09-02 17:17:44 +08:00
drunkpig 83e0d55a34 fix: replace \u0002, \u0003 in common text (#521)
* fix replace \u0002, \u0003 in common text

* fix(para): When an English line ends with a hyphen, do not add a space at the end.
2024-09-02 16:23:17 +08:00
dd19f59eb6 fix(ocr_mkcontent): revise table caption output (#397)
* fix(ocr_mkcontent): revise table caption output

- Ensuring that
  table captions are properly included in the output.
- Remove the redundant `table_caption` variable。

* Update cla.yml

* Update bug_report.yml

* feat(cli): add debug option for detailed error handling

Enable users to invoke the CLI command with a new debug flag to get detailed debugging information.

* fix(pdf-extract-kit): adjust crop_paste parameters for better accuracyThe crop_paste_x and crop_paste_y values in the pdf_extract_kit.py have been modified
to improve the accuracy and consistency of OCR processing. The new values are set to 25
to ensure more precise image cropping and pasting which leads to better OCR recognition
results.

* Update README_zh-CN.md (#404)

correct FAQ url

* Update README_zh-CN.md (#404) (#409) (#410)

correct FAQ url

Co-authored-by: sfk <18810651050@163.com>

* Update FAQ_zh_cn.md

add new issue

* Update FAQ_en_us.md

* Update README_Windows_CUDA_Acceleration_zh_CN.md

* Update README_zh-CN.md

* @Thepathakarpit has signed the CLA in opendatalab/MinerU#418

* fix(pdf-extract-kit): increase crop_paste margin for OCR processingDouble the crop_paste margin from25 to 50 to ensure better OCR accuracy and
handling of border cases. This change will help in improving the overall quality of
OCR'ed text by providing more context around the detected text areas.

* fix(common): deep copy model list before drawing model bbox

Use a deep copy of the original model list in `drow_model_bbox` to avoid potential
modifications to the source data. This ensures the integrity of the original models
is maintained while generating the model bounding boxes visualization.

---------

Co-authored-by: sfk <18810651050@163.com>
Co-authored-by: drunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-08-20 14:40:36 +08:00
Xiaomeng Zhao 66e3ce9c4a fix(ocr_mkcontent): improve language detection and content formatting (#458)
Optimize the language detection logic to enhance content formatting.  This
change addresses issues with long word segmentation. Language detection now uses a
threshold to determine the language of a text based on the proportion of English characters.
Formatting rules for content have been updated to consider a list of languages (initially
including Chinese, Japanese, and Korean) where no space is added between content segments
for inline equations and text spans, improving the handling of Asian languages.

The impact of these changes includes improved accuracy in language detection, better
segmentation of long words, and more appropriate spacing in content formatting for multiple
languages.
2024-08-20 14:12:00 +08:00
liukaiwen ec7271faee fix table recognition bug#321 2024-08-05 16:54:35 +08:00
myhloli 0998d22a32 fix(ocr_mkcontent): add spaces around inline equation in content
Ensure proper formatting of inline equations by adding spaces outside the equation delimitersto prevent markdown from interpreting the equation content as part of a link. This addresses
the issue where inline OCR equations appear without the correct markdown formatting.
2024-08-04 23:44:49 +08:00
Kaiwen Liuandliukaiwen 37925f36d9 feat(model inference): add table recognition and conversion to LaTeX (#284)
* # add table recognition using struct-eqtable
## Changelog
31/07/20204
- Support table recognition. Table images will be converted into html.

### how to use the new feature:
set the attribute 'table-mode' to 'true' in magic-pdf.json

### caution:
it takes 200s to 500s to convert a single table image using cpu

* # add table recognition using struct-eqtable
## Changelog
31/07/20204
- Support table recognition. Table images will be converted into LaTex.

### how to use the new feature:
set the attribute 'table-mode' to 'true' in magic-pdf.json

### caution:
it takes 200s to 500s to convert a single table image using cpu

* # feat(model inference): add table recognition and convertion to LaTeX

# What's Changed

### New Features

- Add table content recognition, we use weights of [StructEqTable](https://github.com/UniModal4Reasoning/StructEqTable-Deploy) to convert table image to LaTex.

### Instruction

- pip install pypandoc struct-eqtable==0.1.0
- Download [StructEqTable weights](https://huggingface.co/wanderkid/PDF-Extract-Kit/tree/main/models/TabRec) and put it under models/ directory.
- Edit 'table-mode' value to turn on table recognition function which is turned off by default.
- If you did not download any models before, refer to [how to download models](docs/how_to_download_models_zh_cn.md)。

* add table recognition and convertion to LaTeX

* add table recognition and conversion to LaTeX

* add table recognition and conversion to LaTeX

* add table recognition and conversion to LaTeX

---------

Co-authored-by: liukaiwen <liukaiwen@pjlab.org.cn>
2024-08-02 11:13:46 +08:00
myhloli a5c35165ee feat(dict2md): add page index to para content for standard format v2 2024-07-30 17:30:26 +08:00
myhloli ff13c8e115 fix(mkmarkdown): add 2 space after image and table URLs 2024-07-13 20:16:43 +08:00
赵小蒙 5de013e6d5 fix:use line_lang instead of content_lang to concatenate para 2024-06-19 12:54:54 +08:00
赵小蒙 6199e608d4 add union_make logic 2024-04-30 11:54:33 +08:00
liukaiwen 503b9fad3e 解决标题后空格丢失 2024-04-29 17:52:26 +08:00
赵小蒙 f01cb89f01 fix lost image or table bug 2024-04-29 17:16:17 +08:00
赵小蒙 e980d2efa0 fix UNIPipe and spans space with language 2024-04-29 14:47:30 +08:00
赵小蒙 d3542f6a71 add para_to_standard_format logic 2024-04-25 18:47:41 +08:00
赵小蒙 7631907f49 fix interline_equations block 2024-04-25 11:40:25 +08:00
赵小蒙 81f73a3d9d 避免空para导致的error 2024-04-23 11:18:00 +08:00
赵小蒙 52777b224a fix ocr_mk_markdown_with_para_core_v2 2024-04-22 21:50:32 +08:00
赵小蒙 d7128a9d87 更新mm markdown拼装函数 2024-04-22 21:45:03 +08:00