Unverified Commit 9f352df0 authored by drunkpig's avatar drunkpig Committed by GitHub
Browse files

Realese 0.8.0 (#586)



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

correct FAQ url
Co-authored-by: default avatarsfk <18810651050@163.com>

* add dockerfile (#189)
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>

* Update cla.yml

* Update cla.yml

* 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.

* fix(self_modify): merge detection boxes for optimized text region detection (#448)

Merge adjacent and overlapping detection boxes to optimize text region detection in
the document. Post processing of text boxes is enhanced by consolidating them into
larger text lines, taking into account their vertical and horizontal alignment. This
improvement reduces fragmentation and improves the readability of detected text blocks.

* fix(pdf-extract): adjust box threshold for OCR detection (#447)

Tuned the detection box threshold parameter in the OCR model initialization to improve the
accuracy of text extraction from images. The threshold was modified from 0.6 to
0.3 to filter out smaller detection boxes, which is expected to enhance the quality of the extracted
text by reducing noise and false positives in the OCR process.

* feat: rename the file generated by command line tools (#401)

* feat: rename the file generated by command line tools

* feat: add pdf filename as prefix to {span,layout,model}.pdf

---------
Co-authored-by: default avataricecraft <tmortred@gmail.com>
Co-authored-by: default avataricecraft <xurui1@pjlab.org.cn>

* 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: default avatarsfk <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: default avatarsfk <18810651050@163.com>
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: default avatargithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>

* build(docker): update docker build step (#471)

* build(docker): update base image to Ubuntu 22.04 and install PaddlePaddleUpgrade the Docker base image from ubuntu:latest to ubuntu:22.04 for improved
performance and stability.

Additionally, integrate PaddlePaddle GPU version 3.0.0b1
into the Docker build for enhanced AI capabilities. The MinIO configuration file has
also been updated to the latest version.

* build(dockerfile): Updated the Dockerfile

* build(Dockerfile): update Dockerfile

* docs(docker): add instructions for quick deployment with Docker

Include Docker-based deployment instructions in the README for both English and
Chinese locales. This update provides users a quick-start guide to using Docker for
deployment, with notes on GPU VRAM requirements and default acceleration features.

* build(docker): Layer the installation of dependencies, downloading the model, and the setup of the program itself.

* build(docker): Layer the installation of dependencies, downloading the model, and the setup of the program itself.

* upload an introduction about chemical formula and update readme.md (#489)

* upload an introduction about chemical formula

* rename 2 files

* update readme.md at TODO in chemstery

* rename 2 files and update readme.md at TODO in chemstery

* update README_zh-CN.md at TODO in chemstery

* upload an introduction about chemical formula and update readme.md (#489)

* upload an introduction about chemical formula

* rename 2 files

* update readme.md at TODO in chemstery

* rename 2 files and update readme.md at TODO in chemstery

* update README_zh-CN.md at TODO in chemstery

* fix: remove the default value of output option in tools/cli.py and tools/cli_dev.py (#494)
Co-authored-by: default avataricecraft <xurui1@pjlab.org.cn>

* feat: add test case (#499)
Co-authored-by: default avatarquyuan <quyuan@pjlab.org>

* Update cla.yml

* Update gpu-ci.yml

* Update cli.yml

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

* fix(pdf-parse-union-core): #492 decrease span threshold for block filling (#500)

Reduce the span threshold used in fill_spans_in_blocks from 0.6 to 0.3 to
improve the accuracy of block filling based on layout analysis.

* fix(detect_all_bboxes): remove small overlapping blocks by merging (#501)

Previously, small blocks that overlapped with larger ones were merely removed. This fix
changes the approach to merge smaller blocks into the larger block instead, ensuring that
no information is lost and the larger block encompasses all the text content fully.

* feat(cli&analyze&pipeline): add start_page and end_page args for pagination (#507)

* feat(cli&analyze&pipeline): add start_page and end_page args for paginationAdd start_page_id and end_page_id arguments to various components of the PDF parsing
pipeline to support pagination functionality. This feature allows users to specify the
range of pages to be processed, enhancing the efficiency and flexibility of the system.

* feat(cli&analyze&pipeline): add start_page and end_page args for paginationAdd start_page_id and end_page_id arguments to various components of the PDF parsing
pipeline to support pagination functionality. This feature allows users to specify the
range of pages to be processed, enhancing the efficiency and flexibility of the system.

* feat(cli&analyze&pipeline): add start_page and end_page args for paginationAdd start_page_id and end_page_id arguments to various components of the PDF parsing
pipeline to support pagination functionality. This feature allows users to specify the
range of pages to be processed, enhancing the efficiency and flexibility of the system.

* Feat/support rag (#510)

* Create requirements-docker.txt

* feat: update deps to support rag

* feat: add support to rag, add rag_data_reader api for rag integration

* feat: let user retrieve the filename of the processed file

* feat: add projects demo for rag integrations

---------
Co-authored-by: default avatarXiaomeng Zhao <moe@myhloli.com>
Co-authored-by: default avataricecraft <xurui1@pjlab.org.cn>

* Update Dockerfile

* feat(gradio): add app by gradio (#512)

* 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.

* fix(end_page_id):Fix the issue where end_page_id is corrected to len-1 when its input is 0. (#518)

* fix(para): When an English line ends with a hyphen, do not add a space at the end. (#523)

* 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.

* fix: delete hyphen at end of line

* 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: default avatarsfk <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: default avatarsfk <18810651050@163.com>

* add dockerfile (#189)
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>

* Update cla.yml

* Update cla.yml

---------
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: default avatarsfk <18810651050@163.com>
Co-authored-by: default avatarAoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: default avatarXiaomeng Zhao <moe@myhloli.com>

* <fix>(para_split_v2): index out of range issue of span_text first char (#396)
Co-authored-by: default avatarliukaiwen <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: default avatarXiaomeng Zhao <moe@myhloli.com>
Co-authored-by: default avatarsfk <18810651050@163.com>
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: default avatargithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: default avatarAoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: default avatarliukaiwen <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: default avatarsfk <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: default avatarsfk <18810651050@163.com>

* add dockerfile (#189)
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>

* Update cla.yml

* Update cla.yml

---------
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: default avatarsfk <18810651050@163.com>
Co-authored-by: default avatarAoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: default avatarXiaomeng Zhao <moe@myhloli.com>

* <fix>(para_split_v2): index out of range issue of span_text first char (#396)
Co-authored-by: default avatarliukaiwen <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: default avatarXiaomeng Zhao <moe@myhloli.com>
Co-authored-by: default avatarsfk <18810651050@163.com>
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: default avatargithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: default avatarAoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: default avatarliukaiwen <liukaiwen@pjlab.org.cn>
Co-authored-by: default avataryyy <102640628+dt-yy@users.noreply.github.com>
Co-authored-by: default avatarwangbinDL <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: default avatarsfk <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: default avatarsfk <18810651050@163.com>

* add dockerfile (#189)
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>

* Update cla.yml

* Update cla.yml

---------
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: default avatarsfk <18810651050@163.com>
Co-authored-by: default avatarAoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: default avatarXiaomeng Zhao <moe@myhloli.com>

* <fix>(para_split_v2): index out of range issue of span_text first char (#396)
Co-authored-by: default avatarliukaiwen <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: default avatarXiaomeng Zhao <moe@myhloli.com>
Co-authored-by: default avatarsfk <18810651050@163.com>
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: default avatargithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: default avatarAoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: default avatarliukaiwen <liukaiwen@pjlab.org.cn>
Co-authored-by: default avataryyy <102640628+dt-yy@users.noreply.github.com>
Co-authored-by: default avatarwangbinDL <wangbin_research@163.com>

---------
Co-authored-by: default avatarKaiwen Liu <lkw_buaa@163.com>
Co-authored-by: default avatarXiaomeng Zhao <moe@myhloli.com>
Co-authored-by: default avatarsfk <18810651050@163.com>
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: default avatargithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: default avatarAoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: default avatarliukaiwen <liukaiwen@pjlab.org.cn>
Co-authored-by: default avatarwangbinDL <wangbin_research@163.com>

* Hotfix readme 0.7.1 (#529)

* release: release 0.7.1 version (#526)

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

correct FAQ url
Co-authored-by: default avatarsfk <18810651050@163.com>

* add dockerfile (#189)
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>

* Update cla.yml

* Update cla.yml

* 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: default avatarsfk <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: default avatarsfk <18810651050@163.com>

* add dockerfile (#189)
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>

* Update cla.yml

* Update cla.yml

---------
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: default avatarsfk <18810651050@163.com>
Co-authored-by: default avatarAoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: default avatarXiaomeng Zhao <moe@myhloli.com>

* <fix>(para_split_v2): index out of range issue of span_text first char (#396)
Co-authored-by: default avatarliukaiwen <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: default avatarXiaomeng Zhao <moe@myhloli.com>
Co-authored-by: default avatarsfk <18810651050@163.com>
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: default avatargithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: default avatarAoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: default avatarliukaiwen <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: default avatarsfk <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: default avatarsfk <18810651050@163.com>

* add dockerfile (#189)
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>

* Update cla.yml

* Update cla.yml

---------
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: default avatarsfk <18810651050@163.com>
Co-authored-by: default avatarAoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: default avatarXiaomeng Zhao <moe@myhloli.com>

* <fix>(para_split_v2): index out of range issue of span_text first char (#396)
Co-authored-by: default avatarliukaiwen <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: default avatarXiaomeng Zhao <moe@myhloli.com>
Co-authored-by: default avatarsfk <18810651050@163.com>
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: default avatargithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: default avatarAoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: default avatarliukaiwen <liukaiwen@pjlab.org.cn>
Co-authored-by: default avataryyy <102640628+dt-yy@users.noreply.github.com>
Co-authored-by: default avatarwangbinDL <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: default avatarsfk <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: default avatarsfk <18810651050@163.com>

* add dockerfile (#189)
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>

* Update cla.yml

* Update cla.yml

---------
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: default avatarsfk <18810651050@163.com>
Co-authored-by: default avatarAoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: default avatarXiaomeng Zhao <moe@myhloli.com>

* <fix>(para_split_v2): index out of range issue of span_text first char (#396)
Co-authored-by: default avatarliukaiwen <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: default avatarXiaomeng Zhao <moe@myhloli.com>
Co-authored-by: default avatarsfk <18810651050@163.com>
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: default avatargithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: default avatarAoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: default avatarliukaiwen <liukaiwen@pjlab.org.cn>
Co-authored-by: default avataryyy <102640628+dt-yy@users.noreply.github.com>
Co-authored-by: default avatarwangbinDL <wangbin_research@163.com>

---------
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: default avatarsfk <18810651050@163.com>
Co-authored-by: default avatarAoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: default avatarXiaomeng Zhao <moe@myhloli.com>
Co-authored-by: default avatarKaiwen Liu <lkw_buaa@163.com>
Co-authored-by: default avatargithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: default avatarliukaiwen <liukaiwen@pjlab.org.cn>
Co-authored-by: default avatarwangbinDL <wangbin_research@163.com>

* Update README.md

* Update README_zh-CN.md

* Update README_zh-CN.md

---------
Co-authored-by: default avataryyy <102640628+dt-yy@users.noreply.github.com>
Co-authored-by: default avatardrunkpig <60862764+drunkpig@users.noreply.github.com>
Co-authored-by: default avatarAoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: default avatarXiaomeng Zhao <moe@myhloli.com>
Co-authored-by: default avatarKaiwen Liu <lkw_buaa@163.com>
Co-authored-by: default avatargithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: default avatarliukaiwen <liukaiwen@pjlab.org.cn>
Co-authored-by: default avatarwangbinDL <wangbin_research@163.com>

* Update README_zh-CN.md

delete Known issue about table recognition

* Update Dockerfile

* fix: resolve inaccuracy of drawing layout box caused by paragraphs combination #384 (#542)

* fix: resolve inaccuracy of drawing layout box caused by paragraphs combination

* fix: resolve inaccuracy of drawing layout box caused by paragraphs combination #384

* fix: resolve inaccuracy of drawing layout box caused by paragraphs combination #384

* fix: resolve inaccuracy of drawing layout box caused by paragraphs combination #384

* fix: typo error in markdown (#536)
Co-authored-by: default avataricecraft <xurui1@pjlab.org.cn>

* fix(gradio): remove unused imports and simplify pdf display (#534)

Removed the previously used gradio and gradio-pdf imports which were not leveraged in the code. Also,
replaced the custom `show_pdf` function with direct use of the `PDF` component from gradio for a simpler
and more integrated PDF upload and display solution, improving code maintainability and readability.

* 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: default avataricecraft <xurui1@pjlab.org.cn>

* refactor(pdf_extract_kit): implement singleton pattern for atomic models (#533)

Refactor the pdf_extract_kit module to utilize a singleton pattern when initializing
atomic models. This change ensures that atomic models are instantiated at most once,
optimizing memory usage and reducing redundant initialization steps. The AtomModelSingleton
class now manages the instantiation and retrieval of atomic models, improving the
overall structure and efficiency of the codebase.

* Update README.md

* Update README_zh-CN.md

* Update README_zh-CN.md

add HF、modelscope、colab url

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README_zh-CN.md

* Rename README.md to README_zh-CN.md

* Create readme.md

* Rename readme.md to README.md

* Rename README.md to README_zh-CN.md

* Update README_zh-CN.md

* Create README.md

* Update README.md

* Update README.md

* Update README.md

* Update README_zh-CN.md

* Update README.md

* Update README_zh-CN.md

* Update README_zh-CN.md

* Update README.md

* Update README_zh-CN.md

* fix: resolve inaccuracy of drawing layout box caused by paragraphs combination #384 (#573)

* fix: resolve inaccuracy of drawing layout box caused by paragraphs combination

* fix: resolve inaccuracy of drawing layout box caused by paragraphs combination #384

* fix: resolve inaccuracy of drawing layout box caused by paragraphs combination #384

* fix: resolve inaccuracy of drawing layout box caused by paragraphs combination #384

* fix: resolve inaccuracy of drawing layout box caused by paragraphs combination #384

* Update README_zh-CN.md

* Update README.md

* Update README.md

* Update README.md

* Update README_zh-CN.md

* add rag data api

* Update README_zh-CN.md

update rag api image

* Update README.md

docs: remove RAG related release notes

* Update README_zh-CN.md

docs: remove RAG related release notes

* Update README_zh-CN.md

update 更新记录

---------
Co-authored-by: default avatarsfk <18810651050@163.com>
Co-authored-by: default avatarAoyang Fang <222010547@link.cuhk.edu.cn>
Co-authored-by: default avatarXiaomeng Zhao <moe@myhloli.com>
Co-authored-by: default avataricecraft <tmortred@163.com>
Co-authored-by: default avataricecraft <tmortred@gmail.com>
Co-authored-by: default avataricecraft <xurui1@pjlab.org.cn>
Co-authored-by: default avatargithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: default avatarSiyu Hao <131659128+GDDGCZ518@users.noreply.github.com>
Co-authored-by: default avataryyy <102640628+dt-yy@users.noreply.github.com>
Co-authored-by: default avatarquyuan <quyuan@pjlab.org>
Co-authored-by: default avatarKaiwen Liu <lkw_buaa@163.com>
Co-authored-by: default avatarliukaiwen <liukaiwen@pjlab.org.cn>
Co-authored-by: default avatarwangbinDL <wangbin_research@163.com>
parent b6633cd6
# 数学新星问题征解
第十五期 (2016.06)
主持: 牟晓生
第一题. 设 $z_{1}, z_{2}, z_{3}$ 是单位复数. 证明存在单位复数 $z$ 使得:
$$
\frac{1}{\left|z-z_{1}\right|^{2}}+\frac{1}{\left|z-z_{2}\right|^{2}}+\frac{1}{\left|z-z_{3}\right|^{2}} \leq \frac{9}{4}
$$
(湖北武钢三中学生 王逸轩, 上海大学冷岗松 供题)
第二题. 如图, $D$ 是正三角形 $A B C$ 的边 $B C$ 上一点, $B D>C D$. 记 $O_{1}, I_{1}$ 为 $\triangle A B D$ 的外心与内心, $O_{2}, I_{2}$ 为 $\triangle A C D$ 的外心与内心. 圆 $I_{1}$ 与圆 $I_{2}$ 除 $B C$外的另一条外公切线交 $A B, A C$ 于 $P, Q$. 设直线 $P I_{1}$与 $Q I_{2}$ 交于 $R$, 而直线 $O_{1} I_{1}$ 与 $O_{2} I_{2}$ 交于 $T$. 证明: $A T^{2}=A R^{2}+A D \cdot B C$.
(广西钦州 卢圣 供题)
第三题. 给定正整数 $m, n$, 考虑在 $m \times n$ 白棋盘上先将一些格染成黑色. 在之后的每一时刻, 若存在一个白格至少与两个黑格相邻, 则可将它也染成黑色. 求最初至少要染多少个黑色格才能在某一时刻染黑整个棋盘?
(哈佛大学 牟晓生 供题)
第四题. $A B C$ 是一个三角形, 而 $P, Q, R$ 分别是 $B C, C A, A B$ 上的点。证明 $\triangle P Q R$ 的周长不小于 $\triangle A Q R, \triangle B R P, \triangle C P Q$ 周长的最小值.
(哈佛大学 牟晓生 供题)
[
{
"layout_dets": [
{
"category_id": 1,
"poly": [
245.17965698242188,
1408.162841796875,
1409.9876708984375,
1408.162841796875,
1409.9876708984375,
1576.8612060546875,
245.17965698242188,
1576.8612060546875
],
"score": 0.9999911189079285
},
{
"category_id": 1,
"poly": [
625.3294067382812,
753.8365478515625,
1410.015380859375,
753.8365478515625,
1410.015380859375,
797.5187377929688,
625.3294067382812,
797.5187377929688
],
"score": 0.9999904632568359
},
{
"category_id": 1,
"poly": [
243.91610717773438,
900.430419921875,
1029.7550048828125,
900.430419921875,
1029.7550048828125,
1246.8853759765625,
243.91610717773438,
1246.8853759765625
],
"score": 0.9999890327453613
},
{
"category_id": 1,
"poly": [
244.826171875,
575.121826171875,
1113.444091796875,
575.121826171875,
1113.444091796875,
624.2438354492188,
244.826171875,
624.2438354492188
],
"score": 0.9999887347221375
},
{
"category_id": 1,
"poly": [
698.5866088867188,
1262.7681884765625,
1032.8016357421875,
1262.7681884765625,
1032.8016357421875,
1304.719970703125,
698.5866088867188,
1304.719970703125
],
"score": 0.9999858736991882
},
{
"category_id": 1,
"poly": [
1047.3941650390625,
1589.7156982421875,
1407.320556640625,
1589.7156982421875,
1407.320556640625,
1635.564453125,
1047.3941650390625,
1635.564453125
],
"score": 0.9999785423278809
},
{
"category_id": 0,
"poly": [
586.237060546875,
268.1336669921875,
1070.578857421875,
268.1336669921875,
1070.578857421875,
333.3851623535156,
586.237060546875,
333.3851623535156
],
"score": 0.9999648332595825
},
{
"category_id": 3,
"poly": [
1064.586669921875,
891.74169921875,
1405.2781982421875,
891.74169921875,
1405.2781982421875,
1323.926513671875,
1064.586669921875,
1323.926513671875
],
"score": 0.9999620318412781
},
{
"category_id": 1,
"poly": [
245.0867156982422,
1737.461181640625,
1407.4088134765625,
1737.461181640625,
1407.4088134765625,
1844.520751953125,
245.0867156982422,
1844.520751953125
],
"score": 0.9999591112136841
},
{
"category_id": 1,
"poly": [
728.7286376953125,
464.164306640625,
925.77294921875,
464.164306640625,
925.77294921875,
507.0546875,
728.7286376953125,
507.0546875
],
"score": 0.9999172687530518
},
{
"category_id": 1,
"poly": [
671.8990478515625,
403.32611083984375,
982.4508666992188,
403.32611083984375,
982.4508666992188,
447.346435546875,
671.8990478515625,
447.346435546875
],
"score": 0.9999128580093384
},
{
"category_id": 1,
"poly": [
1050.064697265625,
1859.377197265625,
1406.635009765625,
1859.377197265625,
1406.635009765625,
1901.196533203125,
1050.064697265625,
1901.196533203125
],
"score": 0.9998365640640259
},
{
"category_id": 8,
"poly": [
559.9688720703125,
640.2896728515625,
1096.220458984375,
640.2896728515625,
1096.220458984375,
732.165283203125,
559.9688720703125,
732.165283203125
],
"score": 0.9991127252578735
},
{
"category_id": 13,
"poly": [
409,
581,
530,
581,
530,
621,
409,
621
],
"score": 0.93,
"latex": "z_{1},z_{2},z_{3}"
},
{
"category_id": 13,
"poly": [
539,
963,
627,
963,
627,
1005,
539,
1005
],
"score": 0.93,
"latex": "O_{1},I_{1}"
},
{
"category_id": 13,
"poly": [
754,
1741,
864,
1741,
864,
1783,
754,
1783
],
"score": 0.93,
"latex": "P,Q,R"
},
{
"category_id": 13,
"poly": [
725,
1144,
798,
1144,
798,
1185,
725,
1185
],
"score": 0.92,
"latex": "O_{2}I_{2}"
},
{
"category_id": 13,
"poly": [
738,
1413,
836,
1413,
836,
1451,
738,
1451
],
"score": 0.92,
"latex": "m\\times n"
},
{
"category_id": 13,
"poly": [
602,
1144,
674,
1144,
674,
1184,
602,
1184
],
"score": 0.92,
"latex": "O_{1}I_{1}"
},
{
"category_id": 13,
"poly": [
246,
1023,
332,
1023,
332,
1065,
246,
1065
],
"score": 0.92,
"latex": "O_{2},I_{2}"
},
{
"category_id": 13,
"poly": [
304,
963,
470,
963,
470,
1002,
304,
1002
],
"score": 0.92,
"latex": "B D\\,>\\,C D"
},
{
"category_id": 13,
"poly": [
289,
1144,
350,
1144,
350,
1186,
289,
1186
],
"score": 0.91,
"latex": "Q I_{2}"
},
{
"category_id": 14,
"poly": [
557,
640,
1093,
640,
1093,
729,
557,
729
],
"score": 0.91,
"latex": "\\frac{1}{|z-z_{1}|^{2}}+\\frac{1}{|z-z_{2}|^{2}}+\\frac{1}{|z-z_{3}|^{2}}\\leq\\frac{9}{4}."
},
{
"category_id": 13,
"poly": [
767,
1083,
835,
1083,
835,
1125,
767,
1125
],
"score": 0.91,
"latex": "P,Q"
},
{
"category_id": 13,
"poly": [
597,
1082,
720,
1082,
720,
1124,
597,
1124
],
"score": 0.9,
"latex": "A B,A C"
},
{
"category_id": 13,
"poly": [
988,
1740,
1176,
1740,
1176,
1783,
988,
1783
],
"score": 0.9,
"latex": "B C,C A,A B"
},
{
"category_id": 13,
"poly": [
968,
1084,
1026,
1084,
1026,
1123,
968,
1123
],
"score": 0.9,
"latex": "P I_{1}"
},
{
"category_id": 13,
"poly": [
546,
1414,
615,
1414,
615,
1453,
546,
1453
],
"score": 0.9,
"latex": "m,n"
},
{
"category_id": 13,
"poly": [
570,
1800,
921,
1800,
921,
1843,
570,
1843
],
"score": 0.89,
"latex": "\\triangle A Q R,\\triangle B R P,\\triangle C P Q"
},
{
"category_id": 13,
"poly": [
771,
1024,
806,
1024,
806,
1064,
771,
1064
],
"score": 0.88,
"latex": "I_{1}"
},
{
"category_id": 13,
"poly": [
887,
1024,
921,
1024,
921,
1063,
887,
1063
],
"score": 0.88,
"latex": "I_{2}"
},
{
"category_id": 13,
"poly": [
996,
585,
1021,
585,
1021,
616,
996,
616
],
"score": 0.82,
"latex": "z"
},
{
"category_id": 13,
"poly": [
475,
904,
510,
904,
510,
941,
475,
941
],
"score": 0.81,
"latex": "D"
},
{
"category_id": 13,
"poly": [
437,
1145,
467,
1145,
467,
1181,
437,
1181
],
"score": 0.8,
"latex": "R"
},
{
"category_id": 13,
"poly": [
884,
1145,
914,
1145,
914,
1181,
884,
1181
],
"score": 0.8,
"latex": "T"
},
{
"category_id": 14,
"poly": [
246,
1203,
593,
1203,
593,
1244,
246,
1244
],
"score": 0.78,
"latex": "A T^{2}=A R^{2}+A D\\cdot B C."
},
{
"category_id": 13,
"poly": [
883,
903,
943,
903,
943,
942,
883,
942
],
"score": 0.74,
"latex": "B C"
},
{
"category_id": 13,
"poly": [
969,
1024,
1028,
1024,
1028,
1061,
969,
1061
],
"score": 0.73,
"latex": "B C"
},
{
"category_id": 13,
"poly": [
380,
1023,
494,
1023,
494,
1062,
380,
1062
],
"score": 0.67,
"latex": "\\triangle A C D"
},
{
"category_id": 13,
"poly": [
246,
1800,
360,
1800,
360,
1842,
246,
1842
],
"score": 0.6,
"latex": "\\triangle P Q R"
},
{
"category_id": 13,
"poly": [
677,
963,
793,
963,
793,
1002,
677,
1002
],
"score": 0.52,
"latex": "\\triangle A B D"
},
{
"category_id": 13,
"poly": [
710,
902,
795,
902,
795,
942,
710,
942
],
"score": 0.41,
"latex": "A B C"
},
{
"category_id": 13,
"poly": [
379,
1740,
463,
1740,
463,
1780,
379,
1780
],
"score": 0.31,
"latex": "A B C"
},
{
"category_id": 13,
"poly": [
1381,
1166,
1393,
1166,
1393,
1178,
1381,
1178
],
"score": 0.26,
"latex": "c"
},
{
"category_id": 15,
"poly": [
254.0,
1476.0,
1400.0,
1476.0,
1400.0,
1511.0,
254.0,
1511.0
],
"score": 0.99,
"text": "的每一时刻,若存在一个白格至少与两个黑格相邻,则可将它也染成黑色.求最初"
},
{
"category_id": 15,
"poly": [
256.0,
1537.0,
1031.0,
1537.0,
1031.0,
1572.0,
256.0,
1572.0
],
"score": 0.98,
"text": "至少要染多少个黑色格才能在某一时刻染黑整个棋盘?"
},
{
"category_id": 15,
"poly": [
837.0,
1418.0,
1403.0,
1418.0,
1403.0,
1452.0,
837.0,
1452.0
],
"score": 0.99,
"text": "白棋盘上先将一些格染成黑色.在之后"
},
{
"category_id": 15,
"poly": [
254.0,
1418.0,
545.0,
1418.0,
545.0,
1452.0,
254.0,
1452.0
],
"score": 1.0,
"text": "第三题.给定正整数"
},
{
"category_id": 15,
"poly": [
616.0,
1418.0,
737.0,
1418.0,
737.0,
1452.0,
616.0,
1452.0
],
"score": 0.94,
"text": ",考虑在"
},
{
"category_id": 15,
"poly": [
645.0,
763.0,
1400.0,
763.0,
1400.0,
797.0,
645.0,
797.0
],
"score": 0.98,
"text": "(湖北武钢三中学生 王逸轩,上海大学冷岗松 供题)"
},
{
"category_id": 15,
"poly": [
675.0,
1150.0,
724.0,
1150.0,
724.0,
1184.0,
675.0,
1184.0
],
"score": 1.0,
"text": "与"
},
{
"category_id": 15,
"poly": [
251.0,
970.0,
303.0,
970.0,
303.0,
1004.0,
251.0,
1004.0
],
"score": 0.99,
"text": "点,"
},
{
"category_id": 15,
"poly": [
471.0,
970.0,
538.0,
970.0,
538.0,
1004.0,
471.0,
1004.0
],
"score": 0.71,
"text": ".记"
},
{
"category_id": 15,
"poly": [
254.0,
1150.0,
288.0,
1150.0,
288.0,
1184.0,
254.0,
1184.0
],
"score": 1.0,
"text": "与"
},
{
"category_id": 15,
"poly": [
251.0,
1089.0,
596.0,
1089.0,
596.0,
1123.0,
251.0,
1123.0
],
"score": 1.0,
"text": "外的另一条外公切线交"
},
{
"category_id": 15,
"poly": [
721.0,
1089.0,
766.0,
1089.0,
766.0,
1123.0,
721.0,
1123.0
],
"score": 1.0,
"text": "于"
},
{
"category_id": 15,
"poly": [
836.0,
1089.0,
967.0,
1089.0,
967.0,
1123.0,
836.0,
1123.0
],
"score": 0.97,
"text": ".设直线"
},
{
"category_id": 15,
"poly": [
807.0,
1026.0,
886.0,
1023.0,
886.0,
1065.0,
807.0,
1067.0
],
"score": 1.0,
"text": "与圆"
},
{
"category_id": 15,
"poly": [
251.0,
906.0,
474.0,
906.0,
474.0,
940.0,
251.0,
940.0
],
"score": 0.95,
"text": "第二题.如图,"
},
{
"category_id": 15,
"poly": [
351.0,
1150.0,
436.0,
1150.0,
436.0,
1184.0,
351.0,
1184.0
],
"score": 1.0,
"text": "交于"
},
{
"category_id": 15,
"poly": [
468.0,
1150.0,
601.0,
1150.0,
601.0,
1184.0,
468.0,
1184.0
],
"score": 1.0,
"text": ",而直线"
},
{
"category_id": 15,
"poly": [
799.0,
1150.0,
883.0,
1150.0,
883.0,
1184.0,
799.0,
1184.0
],
"score": 1.0,
"text": "交于"
},
{
"category_id": 15,
"poly": [
915.0,
1150.0,
1024.0,
1150.0,
1024.0,
1184.0,
915.0,
1184.0
],
"score": 0.86,
"text": ".证明:"
},
{
"category_id": 15,
"poly": [
944.0,
906.0,
1019.0,
906.0,
1019.0,
940.0,
944.0,
940.0
],
"score": 0.99,
"text": "上一"
},
{
"category_id": 15,
"poly": [
922.0,
1026.0,
968.0,
1023.0,
968.0,
1065.0,
922.0,
1067.0
],
"score": 1.0,
"text": "除"
},
{
"category_id": 15,
"poly": [
333.0,
1026.0,
379.0,
1023.0,
379.0,
1065.0,
333.0,
1067.0
],
"score": 1.0,
"text": "为"
},
{
"category_id": 15,
"poly": [
495.0,
1026.0,
770.0,
1023.0,
770.0,
1065.0,
495.0,
1067.0
],
"score": 0.99,
"text": "的外心与内心.圆"
},
{
"category_id": 15,
"poly": [
628.0,
970.0,
676.0,
970.0,
676.0,
1004.0,
628.0,
1004.0
],
"score": 1.0,
"text": "为"
},
{
"category_id": 15,
"poly": [
794.0,
970.0,
1024.0,
970.0,
1024.0,
1004.0,
794.0,
1004.0
],
"score": 0.97,
"text": "的外心与内心,"
},
{
"category_id": 15,
"poly": [
511.0,
906.0,
709.0,
906.0,
709.0,
940.0,
511.0,
940.0
],
"score": 1.0,
"text": "是正三角形"
},
{
"category_id": 15,
"poly": [
796.0,
906.0,
882.0,
906.0,
882.0,
940.0,
796.0,
940.0
],
"score": 1.0,
"text": "的边"
},
{
"category_id": 15,
"poly": [
251.0,
582.0,
408.0,
582.0,
408.0,
624.0,
251.0,
624.0
],
"score": 1.0,
"text": "第一题.设"
},
{
"category_id": 15,
"poly": [
531.0,
582.0,
995.0,
582.0,
995.0,
624.0,
531.0,
624.0
],
"score": 1.0,
"text": "是单位复数.证明存在单位复数"
},
{
"category_id": 15,
"poly": [
1022.0,
582.0,
1105.0,
582.0,
1105.0,
624.0,
1022.0,
624.0
],
"score": 0.98,
"text": "使得:"
},
{
"category_id": 15,
"poly": [
704.0,
1267.0,
1026.0,
1267.0,
1026.0,
1308.0,
704.0,
1308.0
],
"score": 0.95,
"text": "(广西钦州 卢圣 供题)"
},
{
"category_id": 15,
"poly": [
1053.0,
1596.0,
1405.0,
1596.0,
1405.0,
1637.0,
1053.0,
1637.0
],
"score": 0.96,
"text": "(哈佛大学 牟晓生 供题)"
},
{
"category_id": 15,
"poly": [
596.0,
278.0,
1058.0,
278.0,
1058.0,
329.0,
596.0,
329.0
],
"score": 1.0,
"text": "数学新星问题征解"
},
{
"category_id": 15,
"poly": [
865.0,
1745.0,
987.0,
1745.0,
987.0,
1786.0,
865.0,
1786.0
],
"score": 1.0,
"text": "分别是"
},
{
"category_id": 15,
"poly": [
1177.0,
1745.0,
1405.0,
1745.0,
1405.0,
1786.0,
1177.0,
1786.0
],
"score": 1.0,
"text": "上的点。证明"
},
{
"category_id": 15,
"poly": [
922.0,
1808.0,
1130.0,
1808.0,
1130.0,
1842.0,
922.0,
1842.0
],
"score": 1.0,
"text": "周长的最小值"
},
{
"category_id": 15,
"poly": [
361.0,
1808.0,
569.0,
1808.0,
569.0,
1842.0,
361.0,
1842.0
],
"score": 1.0,
"text": "的周长不小于"
},
{
"category_id": 15,
"poly": [
251.0,
1745.0,
378.0,
1745.0,
378.0,
1786.0,
251.0,
1786.0
],
"score": 0.97,
"text": "第四题."
},
{
"category_id": 15,
"poly": [
464.0,
1745.0,
753.0,
1745.0,
753.0,
1786.0,
464.0,
1786.0
],
"score": 1.0,
"text": "是一个三角形,而"
},
{
"category_id": 15,
"poly": [
729.0,
465.0,
923.0,
465.0,
923.0,
509.0,
729.0,
509.0
],
"score": 1.0,
"text": "主持:牟晓生"
},
{
"category_id": 15,
"poly": [
672.0,
404.0,
982.0,
404.0,
982.0,
453.0,
672.0,
453.0
],
"score": 1.0,
"text": "第十五期 (2016.06)"
},
{
"category_id": 15,
"poly": [
1049.0,
1856.0,
1408.0,
1862.0,
1407.0,
1910.0,
1048.0,
1905.0
],
"score": 0.97,
"text": "(哈佛大学 牟晓生 供题)"
}
],
"page_info": {
"page_no": 0,
"height": 2339,
"width": 1654
}
}
]
\ No newline at end of file
[
{
"layout_dets": [
{
"category_id": 1,
"poly": [
578.199951171875,
672.8836669921875,
1579.9771728515625,
672.8836669921875,
1579.9771728515625,
1034.6820068359375,
578.199951171875,
1034.6820068359375
],
"score": 0.9999963641166687
},
{
"category_id": 1,
"poly": [
583.6012573242188,
1067.112548828125,
1579.8231201171875,
1067.112548828125,
1579.8231201171875,
1537.1314697265625,
583.6012573242188,
1537.1314697265625
],
"score": 0.9999961853027344
},
{
"category_id": 1,
"poly": [
585.4329223632812,
1568.2215576171875,
1578.5496826171875,
1568.2215576171875,
1578.5496826171875,
1931.5169677734375,
585.4329223632812,
1931.5169677734375
],
"score": 0.9999949336051941
},
{
"category_id": 1,
"poly": [
578.48388671875,
532.0015869140625,
1577.96337890625,
532.0015869140625,
1577.96337890625,
641.0133056640625,
578.48388671875,
641.0133056640625
],
"score": 0.999992847442627
},
{
"category_id": 1,
"poly": [
66.4359359741211,
1776.6947021484375,
530.4816284179688,
1776.6947021484375,
530.4816284179688,
1883.12841796875,
66.4359359741211,
1883.12841796875
],
"score": 0.9999925494194031
},
{
"category_id": 3,
"poly": [
70.23741149902344,
818.9378662109375,
517.8241577148438,
818.9378662109375,
517.8241577148438,
1076.58251953125,
70.23741149902344,
1076.58251953125
],
"score": 0.9999912977218628
},
{
"category_id": 1,
"poly": [
64.99989318847656,
651.9586791992188,
436.51446533203125,
651.9586791992188,
436.51446533203125,
723.5755615234375,
64.99989318847656,
723.5755615234375
],
"score": 0.9999803900718689
},
{
"category_id": 0,
"poly": [
556.2784423828125,
270.2118835449219,
1577.8243408203125,
270.2118835449219,
1577.8243408203125,
408.96875,
556.2784423828125,
408.96875
],
"score": 0.9999694228172302
},
{
"category_id": 1,
"poly": [
67.8554458618164,
1342.222900390625,
530.5653686523438,
1342.222900390625,
530.5653686523438,
1447.843017578125,
67.8554458618164,
1447.843017578125
],
"score": 0.999964714050293
},
{
"category_id": 1,
"poly": [
65.74972534179688,
1631.3668212890625,
530.32763671875,
1631.3668212890625,
530.32763671875,
1772.4139404296875,
65.74972534179688,
1772.4139404296875
],
"score": 0.9999628067016602
},
{
"category_id": 1,
"poly": [
588.5555419921875,
2068.548828125,
1525.326416015625,
2068.548828125,
1525.326416015625,
2103.8896484375,
588.5555419921875,
2103.8896484375
],
"score": 0.9999607801437378
},
{
"category_id": 1,
"poly": [
586.5614013671875,
1963.109619140625,
1556.57763671875,
1963.109619140625,
1556.57763671875,
2034.810302734375,
586.5614013671875,
2034.810302734375
],
"score": 0.9999467730522156
},
{
"category_id": 5,
"poly": [
59.963104248046875,
1110.6282958984375,
529.9212646484375,
1110.6282958984375,
529.9212646484375,
1225.2918701171875,
59.963104248046875,
1225.2918701171875
],
"score": 0.9999458193778992
},
{
"category_id": 2,
"poly": [
70.253173828125,
103.42188262939453,
420.4876708984375,
103.42188262939453,
420.4876708984375,
223.3950653076172,
70.253173828125,
223.3950653076172
],
"score": 0.9999403953552246
},
{
"category_id": 2,
"poly": [
1081.0198974609375,
2244.876220703125,
1554.6702880859375,
2244.876220703125,
1554.6702880859375,
2275.28662109375,
1081.0198974609375,
2275.28662109375
],
"score": 0.9999216794967651
},
{
"category_id": 1,
"poly": [
68.85406494140625,
345.90887451171875,
307.9100646972656,
345.90887451171875,
307.9100646972656,
409.0101013183594,
68.85406494140625,
409.0101013183594
],
"score": 0.9999182224273682
},
{
"category_id": 0,
"poly": [
65.58615112304688,
1295.93701171875,
180.41529846191406,
1295.93701171875,
180.41529846191406,
1328.8675537109375,
65.58615112304688,
1328.8675537109375
],
"score": 0.9998924136161804
},
{
"category_id": 2,
"poly": [
1245.0789794921875,
108.83450317382812,
1576.3145751953125,
108.83450317382812,
1576.3145751953125,
219.29098510742188,
1245.0789794921875,
219.29098510742188
],
"score": 0.9995979070663452
},
{
"category_id": 1,
"poly": [
65.7517318725586,
483.5211181640625,
428.60296630859375,
483.5211181640625,
428.60296630859375,
586.8902587890625,
65.7517318725586,
586.8902587890625
],
"score": 0.9993292689323425
},
{
"category_id": 0,
"poly": [
65.02902221679688,
445.0223083496094,
208.32994079589844,
445.0223083496094,
208.32994079589844,
476.65191650390625,
65.02902221679688,
476.65191650390625
],
"score": 0.9992275238037109
},
{
"category_id": 0,
"poly": [
556.9666748046875,
453.0841369628906,
673.0485229492188,
453.0841369628906,
673.0485229492188,
490.6045227050781,
556.9666748046875,
490.6045227050781
],
"score": 0.9949869513511658
},
{
"category_id": 1,
"poly": [
66.26496124267578,
1524.239013671875,
530.25537109375,
1524.239013671875,
530.25537109375,
1627.5289306640625,
66.26496124267578,
1627.5289306640625
],
"score": 0.9919456839561462
},
{
"category_id": 7,
"poly": [
62.55642318725586,
1227.4195556640625,
380.1070556640625,
1227.4195556640625,
380.1070556640625,
1252.86181640625,
62.55642318725586,
1252.86181640625
],
"score": 0.9918301105499268
},
{
"category_id": 1,
"poly": [
66.80264282226562,
1451.476806640625,
527.379150390625,
1451.476806640625,
527.379150390625,
1519.5836181640625,
66.80264282226562,
1519.5836181640625
],
"score": 0.9883919954299927
},
{
"category_id": 0,
"poly": [
65.35992431640625,
605.3745727539062,
181.2437286376953,
605.3745727539062,
181.2437286376953,
637.0079956054688,
65.35992431640625,
637.0079956054688
],
"score": 0.9870822429656982
},
{
"category_id": 0,
"poly": [
178.8284149169922,
264.662109375,
396.5289611816406,
264.662109375,
396.5289611816406,
315.4195251464844,
178.8284149169922,
315.4195251464844
],
"score": 0.9779264330863953
},
{
"category_id": 4,
"poly": [
66.15017700195312,
767.2459106445312,
181.25796508789062,
767.2459106445312,
181.25796508789062,
799.7833251953125,
66.15017700195312,
799.7833251953125
],
"score": 0.8933500051498413
},
{
"category_id": 13,
"poly": [
590,
747,
688,
747,
688,
778,
590,
778
],
"score": 0.91,
"latex": "+24.4\\%"
},
{
"category_id": 13,
"poly": [
1433,
855,
1492,
855,
1492,
886,
1433,
886
],
"score": 0.86,
"latex": "30\\%"
},
{
"category_id": 13,
"poly": [
238,
689,
264,
689,
264,
717,
238,
717
],
"score": 0.34,
"latex": "@"
},
{
"category_id": 13,
"poly": [
702,
1002,
722,
1002,
722,
1026,
702,
1026
],
"score": 0.33,
"latex": "^+"
},
{
"category_id": 13,
"poly": [
177,
1154,
223,
1154,
223,
1185,
177,
1185
],
"score": 0.28,
"latex": "(\\%)"
}
],
"page_info": {
"page_no": 0,
"height": 2339,
"width": 1654
}
},
{
"layout_dets": [
{
"category_id": 2,
"poly": [
88.00835418701172,
31.891786575317383,
300.7422180175781,
31.891786575317383,
300.7422180175781,
113.60026550292969,
88.00835418701172,
113.60026550292969
],
"score": 0.9999986886978149
},
{
"category_id": 2,
"poly": [
771.0192260742188,
2213.478759765625,
827.4277954101562,
2213.478759765625,
827.4277954101562,
2239.4013671875,
771.0192260742188,
2239.4013671875
],
"score": 0.9999961853027344
},
{
"category_id": 7,
"poly": [
544.297119140625,
488.5483703613281,
988.39990234375,
488.5483703613281,
988.39990234375,
541.063232421875,
544.297119140625,
541.063232421875
],
"score": 0.9999918341636658
},
{
"category_id": 2,
"poly": [
1082.88330078125,
82.37212371826172,
1519.426513671875,
82.37212371826172,
1519.426513671875,
114.92091369628906,
1082.88330078125,
114.92091369628906
],
"score": 0.9999634623527527
},
{
"category_id": 2,
"poly": [
1009.1594848632812,
2210.946533203125,
1535.924560546875,
2210.946533203125,
1535.924560546875,
2241.8310546875,
1009.1594848632812,
2241.8310546875
],
"score": 0.9999324679374695
},
{
"category_id": 5,
"poly": [
537.3482666015625,
156.8837432861328,
1584.9873046875,
156.8837432861328,
1584.9873046875,
485.2989501953125,
537.3482666015625,
485.2989501953125
],
"score": 0.9985944628715515
},
{
"category_id": 7,
"poly": [
62.69691848754883,
443.4039611816406,
249.91006469726562,
443.4039611816406,
249.91006469726562,
467.46136474609375,
62.69691848754883,
467.46136474609375
],
"score": 0.9873790740966797
},
{
"category_id": 5,
"poly": [
61.37367248535156,
138.51014709472656,
528.3062744140625,
138.51014709472656,
528.3062744140625,
443.5386962890625,
61.37367248535156,
443.5386962890625
],
"score": 0.9232067465782166
},
{
"category_id": 6,
"poly": [
548.1131591796875,
148.73146057128906,
797.3046875,
148.73146057128906,
797.3046875,
180.74632263183594,
548.1131591796875,
180.74632263183594
],
"score": 0.6074692606925964
},
{
"category_id": 13,
"poly": [
864,
455,
922,
455,
922,
482,
864,
482
],
"score": 0.74,
"latex": "6.0\\%"
},
{
"category_id": 13,
"poly": [
850,
418,
922,
418,
922,
445,
850,
445
],
"score": 0.64,
"latex": "35.3\\%"
},
{
"category_id": 13,
"poly": [
1501,
270,
1571,
270,
1571,
298,
1501,
298
],
"score": 0.54,
"latex": "13.8\\%"
},
{
"category_id": 13,
"poly": [
1013,
454,
1083,
454,
1083,
482,
1013,
482
],
"score": 0.52,
"latex": "15.0\\%"
},
{
"category_id": 13,
"poly": [
1012,
417,
1083,
417,
1083,
444,
1012,
444
],
"score": 0.52,
"latex": "33.7\\%"
},
{
"category_id": 13,
"poly": [
689,
456,
725,
456,
725,
482,
689,
482
],
"score": 0.48,
"latex": "(\\%)"
},
{
"category_id": 13,
"poly": [
850,
344,
922,
344,
922,
372,
850,
372
],
"score": 0.4,
"latex": "83.8\\%"
},
{
"category_id": 13,
"poly": [
863,
270,
922,
270,
922,
298,
863,
298
],
"score": 0.4,
"latex": "4.5\\%"
},
{
"category_id": 13,
"poly": [
1334,
270,
1406,
270,
1406,
298,
1334,
298
],
"score": 0.35,
"latex": "37.2\\%"
},
{
"category_id": 13,
"poly": [
618,
419,
656,
419,
656,
446,
618,
446
],
"score": 0.35,
"latex": "(\\%)"
}
],
"page_info": {
"page_no": 1,
"height": 2339,
"width": 1654
}
},
{
"layout_dets": [
{
"category_id": 2,
"poly": [
87.90370178222656,
31.597869873046875,
300.9918518066406,
31.597869873046875,
300.9918518066406,
113.40574645996094,
87.90370178222656,
113.40574645996094
],
"score": 0.9999939799308777
},
{
"category_id": 2,
"poly": [
1008.9932250976562,
2209.250732421875,
1534.93310546875,
2209.250732421875,
1534.93310546875,
2242.773193359375,
1008.9932250976562,
2242.773193359375
],
"score": 0.9999377727508545
},
{
"category_id": 2,
"poly": [
770.6605224609375,
2212.857666015625,
827.4124145507812,
2212.857666015625,
827.4124145507812,
2239.771484375,
770.6605224609375,
2239.771484375
],
"score": 0.9998394250869751
},
{
"category_id": 2,
"poly": [
1082.0982666015625,
82.25032043457031,
1518.9271240234375,
82.25032043457031,
1518.9271240234375,
114.52558898925781,
1082.0982666015625,
114.52558898925781
],
"score": 0.9996459484100342
},
{
"category_id": 7,
"poly": [
95.3975601196289,
1846.637939453125,
564.4164428710938,
1846.637939453125,
564.4164428710938,
1899.2098388671875,
95.3975601196289,
1899.2098388671875
],
"score": 0.9908689260482788
},
{
"category_id": 6,
"poly": [
95.46688842773438,
173.42837524414062,
470.2196960449219,
173.42837524414062,
470.2196960449219,
217.74642944335938,
95.46688842773438,
217.74642944335938
],
"score": 0.9438199400901794
},
{
"category_id": 5,
"poly": [
854.114501953125,
1043.93505859375,
1592.0174560546875,
1043.93505859375,
1592.0174560546875,
1846.166015625,
854.114501953125,
1846.166015625
],
"score": 0.884392499923706
},
{
"category_id": 5,
"poly": [
92.02899169921875,
1331.891845703125,
814.2921752929688,
1331.891845703125,
814.2921752929688,
1842.61962890625,
92.02899169921875,
1842.61962890625
],
"score": 0.8743516206741333
},
{
"category_id": 5,
"poly": [
851.83984375,
224.9954833984375,
1592.4066162109375,
224.9954833984375,
1592.4066162109375,
1018.7108154296875,
851.83984375,
1018.7108154296875
],
"score": 0.8650234937667847
},
{
"category_id": 5,
"poly": [
91.79834747314453,
224.1070556640625,
816.58203125,
224.1070556640625,
816.58203125,
1248.4244384765625,
91.79834747314453,
1248.4244384765625
],
"score": 0.8604705333709717
},
{
"category_id": 5,
"poly": [
85.1959228515625,
220.71908569335938,
1602.307373046875,
220.71908569335938,
1602.307373046875,
1844.490234375,
85.1959228515625,
1844.490234375
],
"score": 0.6637970209121704
},
{
"category_id": 13,
"poly": [
737,
704,
804,
704,
804,
730,
737,
730
],
"score": 0.56,
"latex": "\\pmb{26.5\\%}"
},
{
"category_id": 13,
"poly": [
738,
673,
804,
673,
804,
699,
738,
699
],
"score": 0.48,
"latex": "\\pmb{16.2\\%}"
},
{
"category_id": 13,
"poly": [
736,
767,
805,
767,
805,
795,
736,
795
],
"score": 0.48,
"latex": "\\mathbf{\\lambda_{23.7\\%}}"
},
{
"category_id": 13,
"poly": [
231,
611,
268,
611,
268,
638,
231,
638
],
"score": 0.47,
"latex": "(\\%)"
},
{
"category_id": 13,
"poly": [
749,
736,
804,
736,
804,
763,
749,
763
],
"score": 0.41,
"latex": "\\pmb{9.2\\%}"
},
{
"category_id": 13,
"poly": [
737,
641,
804,
641,
804,
668,
737,
668
],
"score": 0.41,
"latex": "{\\bf38.0\\%}"
},
{
"category_id": 13,
"poly": [
748,
577,
805,
577,
805,
606,
748,
606
],
"score": 0.35,
"latex": "0.1\\%"
},
{
"category_id": 13,
"poly": [
187,
800,
222,
800,
222,
827,
187,
827
],
"score": 0.32,
"latex": "(\\%)"
},
{
"category_id": 13,
"poly": [
738,
830,
805,
830,
805,
857,
738,
857
],
"score": 0.28,
"latex": "\\mathbf{13.8\\%}"
},
{
"category_id": 13,
"poly": [
737,
862,
805,
862,
805,
889,
737,
889
],
"score": 0.27,
"latex": "\\mathbf{31.9\\%}"
},
{
"category_id": 13,
"poly": [
736,
955,
804,
955,
804,
983,
736,
983
],
"score": 0.26,
"latex": "\\pmb{65.3\\%}"
}
],
"page_info": {
"page_no": 2,
"height": 2339,
"width": 1654
}
},
{
"layout_dets": [
{
"category_id": 2,
"poly": [
86.30094909667969,
32.05949783325195,
303.6516418457031,
32.05949783325195,
303.6516418457031,
114.77470397949219,
86.30094909667969,
114.77470397949219
],
"score": 0.9999954104423523
},
{
"category_id": 1,
"poly": [
108.4946060180664,
590.2034912109375,
1536.75146484375,
590.2034912109375,
1536.75146484375,
688.491455078125,
108.4946060180664,
688.491455078125
],
"score": 0.9999933242797852
},
{
"category_id": 0,
"poly": [
95.94879913330078,
1205.413818359375,
252.92385864257812,
1205.413818359375,
252.92385864257812,
1246.00146484375,
95.94879913330078,
1246.00146484375
],
"score": 0.9999929666519165
},
{
"category_id": 1,
"poly": [
106.48407745361328,
338.2734680175781,
1568.8638916015625,
338.2734680175781,
1568.8638916015625,
437.8475341796875,
106.48407745361328,
437.8475341796875
],
"score": 0.9999896883964539
},
{
"category_id": 2,
"poly": [
767.6920776367188,
2212.26904296875,
830.787353515625,
2212.26904296875,
830.787353515625,
2239.28466796875,
767.6920776367188,
2239.28466796875
],
"score": 0.9999850988388062
},
{
"category_id": 0,
"poly": [
96.18524932861328,
508.3636474609375,
291.44244384765625,
508.3636474609375,
291.44244384765625,
549.4661254882812,
96.18524932861328,
549.4661254882812
],
"score": 0.9999837875366211
},
{
"category_id": 2,
"poly": [
1082.2711181640625,
81.18756103515625,
1520.2156982421875,
81.18756103515625,
1520.2156982421875,
116.55754089355469,
1082.2711181640625,
116.55754089355469
],
"score": 0.99994957447052
},
{
"category_id": 0,
"poly": [
96.45137786865234,
157.9286346435547,
319.2138671875,
157.9286346435547,
319.2138671875,
213.84323120117188,
96.45137786865234,
213.84323120117188
],
"score": 0.9999274611473083
},
{
"category_id": 0,
"poly": [
96.99203491210938,
257.65087890625,
483.64617919921875,
257.65087890625,
483.64617919921875,
301.5384216308594,
96.99203491210938,
301.5384216308594
],
"score": 0.999910295009613
},
{
"category_id": 2,
"poly": [
1008.87890625,
2208.611328125,
1536.04736328125,
2208.611328125,
1536.04736328125,
2243.415283203125,
1008.87890625,
2243.415283203125
],
"score": 0.999893069267273
},
{
"category_id": 1,
"poly": [
108.4665298461914,
1288.0936279296875,
1546.7523193359375,
1288.0936279296875,
1546.7523193359375,
1383.8436279296875,
108.4665298461914,
1383.8436279296875
],
"score": 0.9997895956039429
},
{
"category_id": 1,
"poly": [
107.81368255615234,
1678.247802734375,
1227.883056640625,
1678.247802734375,
1227.883056640625,
1711.3719482421875,
107.81368255615234,
1711.3719482421875
],
"score": 0.999572217464447
},
{
"category_id": 5,
"poly": [
109.7546157836914,
810.016357421875,
1579.9564208984375,
810.016357421875,
1579.9564208984375,
1171.63818359375,
109.7546157836914,
1171.63818359375
],
"score": 0.999454140663147
},
{
"category_id": 1,
"poly": [
106.4626235961914,
1548.298828125,
1540.339111328125,
1548.298828125,
1540.339111328125,
1676.6796875,
106.4626235961914,
1676.6796875
],
"score": 0.9886388778686523
},
{
"category_id": 1,
"poly": [
107.5276107788086,
1386.3994140625,
1540.8876953125,
1386.3994140625,
1540.8876953125,
1447.81298828125,
107.5276107788086,
1447.81298828125
],
"score": 0.9709202647209167
},
{
"category_id": 1,
"poly": [
107.66427612304688,
1451.8365478515625,
1537.991943359375,
1451.8365478515625,
1537.991943359375,
1546.6905517578125,
107.66427612304688,
1546.6905517578125
],
"score": 0.9589993953704834
},
{
"category_id": 6,
"poly": [
95.90386199951172,
728.28564453125,
328.19708251953125,
728.28564453125,
328.19708251953125,
768.121826171875,
95.90386199951172,
768.121826171875
],
"score": 0.6999472379684448
},
{
"category_id": 1,
"poly": [
106.67626953125,
1371.860595703125,
1544.8497314453125,
1371.860595703125,
1544.8497314453125,
1678.673095703125,
106.67626953125,
1678.673095703125
],
"score": 0.5646986961364746
},
{
"category_id": 0,
"poly": [
95.94149780273438,
728.2644653320312,
328.195068359375,
728.2644653320312,
328.195068359375,
768.1664428710938,
95.94149780273438,
768.1664428710938
],
"score": 0.30706164240837097
},
{
"category_id": 13,
"poly": [
1247,
887,
1353,
887,
1353,
914,
1247,
914
],
"score": 0.91,
"latex": "5\\%{\\sim}20\\%"
},
{
"category_id": 13,
"poly": [
1181,
923,
1290,
923,
1290,
950,
1181,
950
],
"score": 0.9,
"latex": "-5\\%{+}5\\%"
},
{
"category_id": 13,
"poly": [
1416,
1047,
1469,
1047,
1469,
1077,
1416,
1077
],
"score": 0.87,
"latex": "10\\%"
},
{
"category_id": 13,
"poly": [
1254,
963,
1296,
963,
1296,
991,
1254,
991
],
"score": 0.86,
"latex": "5\\%"
},
{
"category_id": 13,
"poly": [
1373,
1003,
1428,
1003,
1428,
1032,
1373,
1032
],
"score": 0.86,
"latex": "10\\%"
},
{
"category_id": 13,
"poly": [
1332,
1047,
1388,
1047,
1388,
1076,
1332,
1076
],
"score": 0.86,
"latex": "\\cdot10\\%"
},
{
"category_id": 13,
"poly": [
1373,
1112,
1428,
1112,
1428,
1141,
1373,
1141
],
"score": 0.85,
"latex": "10\\%"
},
{
"category_id": 13,
"poly": [
1248,
854,
1302,
854,
1302,
880,
1248,
880
],
"score": 0.85,
"latex": "z0\\%"
}
],
"page_info": {
"page_no": 3,
"height": 2339,
"width": 1654
}
}
]
\ No newline at end of file
...@@ -37,9 +37,9 @@ class TestBench(): ...@@ -37,9 +37,9 @@ class TestBench():
now_simscore = now_score["average_sim_score"] now_simscore = now_score["average_sim_score"]
now_editdistance = now_score["average_edit_distance"] now_editdistance = now_score["average_edit_distance"]
now_bleu = now_score["average_bleu_score"] now_bleu = now_score["average_bleu_score"]
#assert last_simscore <= now_simscore assert last_simscore <= now_simscore
#assert last_editdistance <= now_editdistance assert last_editdistance <= now_editdistance
#assert last_bleu <= now_bleu assert last_bleu <= now_bleu
def get_score(): def get_score():
......
import pytest
import os
from conf import conf
import os
import json
from magic_pdf.pipe.UNIPipe import UNIPipe
from magic_pdf.rw.DiskReaderWriter import DiskReaderWriter
from lib import common
pdf_res_path = conf.conf["pdf_res_path"]
code_path = conf.conf["code_path"]
pdf_dev_path = conf.conf["pdf_dev_path"]
class TestCli:
"""
test cli
"""
def test_pdf_sdk(self):
"""
pdf sdk 方式解析
"""
demo_names = list()
pdf_path = os.path.join(pdf_dev_path, "pdf")
for pdf_file in os.listdir(pdf_path):
if pdf_file.endswith('.pdf'):
demo_names.append(pdf_file.split('.')[0])
for demo_name in demo_names:
model_path = os.path.join(pdf_dev_path, f"{demo_name}_model.json")
pdf_path = os.path.join(pdf_dev_path, "pdf", f"{demo_name}.pdf")
pdf_bytes = open(pdf_path, "rb").read()
model_json = json.loads(open(model_path, "r", encoding="utf-8").read())
image_writer = DiskReaderWriter(pdf_dev_path)
image_dir = str(os.path.basename(pdf_dev_path))
jso_useful_key = {"_pdf_type": "", "model_list": model_json}
pipe = UNIPipe(pdf_bytes, jso_useful_key, image_writer)
pipe.pipe_classify()
pipe.pipe_parse()
md_content = pipe.pipe_mk_markdown(image_dir, drop_mode="none")
dir_path = os.path.join(pdf_dev_path, "mineru")
if not os.path.exists(dir_path):
os.makedirs(dir_path, exist_ok=True)
res_path = os.path.join(dir_path, f"{demo_name}.md")
with open(res_path, "w+", encoding="utf-8") as f:
f.write(md_content)
common.count_folders_and_check_contents(res_path)
# def test_pdf_specify_jsonl(self):
# """
# 输入jsonl, 默认方式解析
# """
# cmd = "cd %s && export PYTHONPATH=. && python magic_pdf/cli/magicpdf.py json-command --json 's3://llm-process-pperf/ebook_index_textbook_40k/中高考&竞赛知识点/part-663f1ef5e7c1-009416.jsonl?bytes=0,1133972'" % (code_path)
# logging.info(cmd)
# common.check_shell(cmd)
# #common.count_folders_and_check_contents(pdf_res_path)
# def test_pdf_specify_jsonl_txt(self):
# """
# 输入jsonl, txt方式解析
# """
# cmd = "cd %s && export PYTHONPATH=. && python magic_pdf/cli/magicpdf.py json-command --json 's3://llm-process-pperf/ebook_index_textbook_40k/中高考&竞赛知识点/part-663f1ef5e7c1-009416.jsonl?bytes=0,1133972' --method txt" % (code_path)
# logging.info(cmd)
# common.check_shell(cmd)
# #common.count_folders_and_check_contents(pdf_res_path)
#
# def test_pdf_specify_jsonl_ocr(self):
# """
# 输入jsonl, ocr方式解析
# """
# cmd = "cd %s && export PYTHONPATH=. && python magic_pdf/cli/magicpdf.py json-command --json 's3://llm-process-pperf/ebook_index_textbook_40k/中高考&竞赛知识点/part-663f1ef5e7c1-009416.jsonl?bytes=0,1133972' --method ocr" % (code_path)
# logging.info(cmd)
# common.check_shell(cmd)
# #common.count_folders_and_check_contents(pdf_res_path)
if __name__ == "__main__":
pytest.main()
"""test cli and sdk."""
import logging
import os
import pytest
from conf import conf
from lib import common
import magic_pdf.model as model_config
from magic_pdf.pipe.UNIPipe import UNIPipe
from magic_pdf.rw.DiskReaderWriter import DiskReaderWriter
model_config.__use_inside_model__ = True
pdf_res_path = conf.conf['pdf_res_path']
code_path = conf.conf['code_path']
pdf_dev_path = conf.conf['pdf_dev_path']
class TestCli:
"""test cli."""
@pytest.mark.P0
def test_pdf_auto_sdk(self):
"""pdf sdk auto test."""
demo_names = list()
pdf_path = os.path.join(pdf_dev_path, 'pdf')
for pdf_file in os.listdir(pdf_path):
if pdf_file.endswith('.pdf'):
demo_names.append(pdf_file.split('.')[0])
for demo_name in demo_names:
pdf_path = os.path.join(pdf_dev_path, 'pdf', f'{demo_name}.pdf')
print(pdf_path)
pdf_bytes = open(pdf_path, 'rb').read()
local_image_dir = os.path.join(pdf_dev_path, 'pdf', 'images')
image_dir = str(os.path.basename(local_image_dir))
image_writer = DiskReaderWriter(local_image_dir)
model_json = list()
jso_useful_key = {'_pdf_type': '', 'model_list': model_json}
pipe = UNIPipe(pdf_bytes, jso_useful_key, image_writer)
pipe.pipe_classify()
if len(model_json) == 0:
if model_config.__use_inside_model__:
pipe.pipe_analyze()
else:
exit(1)
pipe.pipe_parse()
md_content = pipe.pipe_mk_markdown(image_dir, drop_mode='none')
dir_path = os.path.join(pdf_dev_path, 'mineru')
if not os.path.exists(dir_path):
os.makedirs(dir_path, exist_ok=True)
res_path = os.path.join(dir_path, f'{demo_name}.md')
common.delete_file(res_path)
with open(res_path, 'w+', encoding='utf-8') as f:
f.write(md_content)
common.sdk_count_folders_and_check_contents(res_path)
@pytest.mark.P0
def test_pdf_ocr_sdk(self):
"""pdf sdk ocr test."""
demo_names = list()
pdf_path = os.path.join(pdf_dev_path, 'pdf')
for pdf_file in os.listdir(pdf_path):
if pdf_file.endswith('.pdf'):
demo_names.append(pdf_file.split('.')[0])
for demo_name in demo_names:
pdf_path = os.path.join(pdf_dev_path, 'pdf', f'{demo_name}.pdf')
print(pdf_path)
pdf_bytes = open(pdf_path, 'rb').read()
local_image_dir = os.path.join(pdf_dev_path, 'pdf', 'images')
image_dir = str(os.path.basename(local_image_dir))
image_writer = DiskReaderWriter(local_image_dir)
model_json = list()
jso_useful_key = {'_pdf_type': 'ocr', 'model_list': model_json}
pipe = UNIPipe(pdf_bytes, jso_useful_key, image_writer)
pipe.pipe_classify()
if len(model_json) == 0:
if model_config.__use_inside_model__:
pipe.pipe_analyze()
else:
exit(1)
pipe.pipe_parse()
md_content = pipe.pipe_mk_markdown(image_dir, drop_mode='none')
dir_path = os.path.join(pdf_dev_path, 'mineru')
if not os.path.exists(dir_path):
os.makedirs(dir_path, exist_ok=True)
res_path = os.path.join(dir_path, f'{demo_name}.md')
common.delete_file(res_path)
with open(res_path, 'w+', encoding='utf-8') as f:
f.write(md_content)
common.sdk_count_folders_and_check_contents(res_path)
@pytest.mark.P0
def test_pdf_txt_sdk(self):
"""pdf sdk txt test."""
demo_names = list()
pdf_path = os.path.join(pdf_dev_path, 'pdf')
for pdf_file in os.listdir(pdf_path):
if pdf_file.endswith('.pdf'):
demo_names.append(pdf_file.split('.')[0])
for demo_name in demo_names:
pdf_path = os.path.join(pdf_dev_path, 'pdf', f'{demo_name}.pdf')
print(pdf_path)
pdf_bytes = open(pdf_path, 'rb').read()
local_image_dir = os.path.join(pdf_dev_path, 'pdf', 'images')
image_dir = str(os.path.basename(local_image_dir))
image_writer = DiskReaderWriter(local_image_dir)
model_json = list()
jso_useful_key = {'_pdf_type': 'txt', 'model_list': model_json}
pipe = UNIPipe(pdf_bytes, jso_useful_key, image_writer)
pipe.pipe_classify()
if len(model_json) == 0:
if model_config.__use_inside_model__:
pipe.pipe_analyze()
else:
exit(1)
pipe.pipe_parse()
md_content = pipe.pipe_mk_markdown(image_dir, drop_mode='none')
dir_path = os.path.join(pdf_dev_path, 'mineru')
if not os.path.exists(dir_path):
os.makedirs(dir_path, exist_ok=True)
res_path = os.path.join(dir_path, f'{demo_name}.md')
common.delete_file(res_path)
with open(res_path, 'w+', encoding='utf-8') as f:
f.write(md_content)
common.sdk_count_folders_and_check_contents(res_path)
@pytest.mark.P0
def test_pdf_cli_auto(self):
"""magic_pdf cli test auto."""
demo_names = []
pdf_path = os.path.join(pdf_dev_path, 'pdf')
for pdf_file in os.listdir(pdf_path):
if pdf_file.endswith('.pdf'):
demo_names.append(pdf_file.split('.')[0])
for demo_name in demo_names:
res_path = os.path.join(pdf_dev_path, 'mineru')
common.delete_file(res_path)
cmd = 'magic-pdf -p %s -o %s -m %s' % (os.path.join(
pdf_path, f'{demo_name}.pdf'), res_path, 'auto')
logging.info(cmd)
os.system(cmd)
common.cli_count_folders_and_check_contents(
os.path.join(res_path, demo_name, 'auto'))
@pytest.mark.P0
def test_pdf_clit_txt(self):
"""magic_pdf cli test txt."""
demo_names = []
pdf_path = os.path.join(pdf_dev_path, 'pdf')
for pdf_file in os.listdir(pdf_path):
if pdf_file.endswith('.pdf'):
demo_names.append(pdf_file.split('.')[0])
for demo_name in demo_names:
res_path = os.path.join(pdf_dev_path, 'mineru')
common.delete_file(res_path)
cmd = 'magic-pdf -p %s -o %s -m %s' % (os.path.join(
pdf_path, f'{demo_name}.pdf'), res_path, 'txt')
logging.info(cmd)
os.system(cmd)
common.cli_count_folders_and_check_contents(
os.path.join(res_path, demo_name, 'txt'))
@pytest.mark.P0
def test_pdf_clit_ocr(self):
"""magic_pdf cli test ocr."""
demo_names = []
pdf_path = os.path.join(pdf_dev_path, 'pdf')
for pdf_file in os.listdir(pdf_path):
if pdf_file.endswith('.pdf'):
demo_names.append(pdf_file.split('.')[0])
for demo_name in demo_names:
res_path = os.path.join(pdf_dev_path, 'mineru')
common.delete_file(res_path)
cmd = 'magic-pdf -p %s -o %s -m %s' % (os.path.join(
pdf_path, f'{demo_name}.pdf'), res_path, 'ocr')
logging.info(cmd)
os.system(cmd)
common.cli_count_folders_and_check_contents(
os.path.join(res_path, demo_name, 'ocr'))
if __name__ == '__main__':
pytest.main()
{
"pdf_info": [
{
"preproc_blocks": [
{
"type": "text",
"bbox": [
47,
57,
299,
93
],
"lines": [
{
"bbox": [
47,
57,
299,
68
],
"spans": [
{
"bbox": [
49,
57,
298,
68
],
"score": 0.98,
"content": "of the synthetic stereo scene from a single camera perspective",
"type": "text"
}
]
},
{
"bbox": [
47,
71,
299,
80
],
"spans": [
{
"bbox": [
49,
71,
299,
80
],
"score": 0.96,
"content": "along with the ground truth disparity,occlusion map,and",
"type": "text"
}
]
},
{
"bbox": [
47,
82,
123,
93
],
"spans": [
{
"bbox": [
49,
82,
123,
93
],
"score": 0.99,
"content": "discontinuitymap.",
"type": "text"
}
]
}
]
},
{
"type": "image",
"bbox": [
47,
100,
301,
535
],
"blocks": [
{
"bbox": [
51,
100,
292,
484
],
"type": "image_body",
"lines": [
{
"bbox": [
51,
100,
292,
484
],
"spans": [
{
"bbox": [
51,
100,
292,
484
],
"score": 0.9999815225601196,
"type": "image",
"image_path": "b07d74524eac6f46b5505b48b1e10db23f2b45cb2d21d5fec72e967e61255811.jpg"
}
]
}
]
},
{
"bbox": [
47,
488,
301,
535
],
"type": "image_caption",
"lines": [
{
"bbox": [
49,
490,
299,
499
],
"spans": [
{
"bbox": [
49,
490,
299,
499
],
"score": 1.0,
"content": "Figure2:Twosampleframesfromthesyntheticvideose-",
"type": "text"
}
]
},
{
"bbox": [
48,
501,
300,
512
],
"spans": [
{
"bbox": [
48,
501,
300,
512
],
"score": 1.0,
"content": "quence (1st row), along with their corresponding ground truth",
"type": "text"
}
]
},
{
"bbox": [
48,
513,
299,
523
],
"spans": [
{
"bbox": [
48,
513,
299,
523
],
"score": 0.98,
"content": "disparity (2nd row), occlusion map (3rd row), and discontinuity",
"type": "text"
}
]
},
{
"bbox": [
48,
525,
110,
535
],
"spans": [
{
"bbox": [
48,
525,
110,
535
],
"score": 0.99,
"content": "map (4th row).",
"type": "text"
}
]
}
]
}
]
},
{
"type": "text",
"bbox": [
47,
549,
299,
678
],
"lines": [
{
"bbox": [
58,
549,
299,
558
],
"spans": [
{
"bbox": [
58,
549,
298,
558
],
"score": 0.98,
"content": "Theresultsof temporalstereomatching aregiveninFigure",
"type": "text"
}
]
},
{
"bbox": [
47,
561,
299,
570
],
"spans": [
{
"bbox": [
47,
561,
298,
570
],
"score": 0.98,
"content": "3foruniformadditivenoiseconfinedtotherangesof±O",
"type": "text"
}
]
},
{
"bbox": [
47,
573,
299,
582
],
"spans": [
{
"bbox": [
49,
573,
299,
582
],
"score": 0.96,
"content": "±20, and ±40. Each performance plot is given as a function",
"type": "text"
}
]
},
{
"bbox": [
47,
585,
299,
594
],
"spans": [
{
"bbox": [
48,
585,
299,
594
],
"score": 0.95,
"content": "of the feedback coefficient X. As with the majority of temporal",
"type": "text"
}
]
},
{
"bbox": [
47,
597,
299,
606
],
"spans": [
{
"bbox": [
49,
597,
299,
606
],
"score": 0.99,
"content": "stereomatching methods,improvements are negligible when",
"type": "text"
}
]
},
{
"bbox": [
47,
609,
299,
618
],
"spans": [
{
"bbox": [
48,
609,
299,
618
],
"score": 0.97,
"content": "no noise is added to the images [1o], [19]. This is largely due",
"type": "text"
}
]
},
{
"bbox": [
47,
621,
299,
629
],
"spans": [
{
"bbox": [
48,
621,
299,
629
],
"score": 1.0,
"content": "tothefactthatthevideousedtoevaluatethesemethodsis",
"type": "text"
}
]
},
{
"bbox": [
47,
633,
299,
641
],
"spans": [
{
"bbox": [
48,
633,
299,
641
],
"score": 1.0,
"content": "computergeneratedwithverylittlenoisetostartwith,thus",
"type": "text"
}
]
},
{
"bbox": [
47,
644,
299,
654
],
"spans": [
{
"bbox": [
48,
644,
299,
654
],
"score": 0.98,
"content": "the noise suppression achieved with temporal stereo matching",
"type": "text"
}
]
},
{
"bbox": [
47,
657,
299,
666
],
"spans": [
{
"bbox": [
48,
657,
299,
666
],
"score": 0.98,
"content": "showslittletonoimprovementovermethodsthatoperate on",
"type": "text"
}
]
},
{
"bbox": [
47,
669,
113,
678
],
"spans": [
{
"bbox": [
48,
669,
113,
678
],
"score": 1.0,
"content": "pairsofimages.",
"type": "text"
}
]
}
]
},
{
"type": "text",
"bbox": [
47,
680,
299,
725
],
"lines": [
{
"bbox": [
58,
680,
299,
690
],
"spans": [
{
"bbox": [
59,
680,
298,
690
],
"score": 0.97,
"content": "Significantimprovementsin accuracy canbeseenin Figure",
"type": "text"
}
]
},
{
"bbox": [
47,
692,
299,
701
],
"spans": [
{
"bbox": [
48,
692,
298,
701
],
"score": 0.97,
"content": "3 when the noise has ranges of ±20, and ±40.In this scenario",
"type": "text"
}
]
},
{
"bbox": [
47,
703,
299,
714
],
"spans": [
{
"bbox": [
48,
703,
299,
714
],
"score": 0.98,
"content": "the effect of noise in the current frame is reduced by increasing",
"type": "text"
}
]
},
{
"bbox": [
47,
716,
299,
725
],
"spans": [
{
"bbox": [
48,
716,
299,
725
],
"score": 0.96,
"content": "thefeedbackcoefficientX.Thisincreasing ofXhas theeffect",
"type": "text"
}
]
}
]
},
{
"type": "image",
"bbox": [
310,
55,
564,
371
],
"blocks": [
{
"bbox": [
314,
55,
538,
305
],
"type": "image_body",
"lines": [
{
"bbox": [
314,
55,
538,
305
],
"spans": [
{
"bbox": [
314,
55,
538,
305
],
"score": 0.9999905824661255,
"type": "image",
"image_path": "c7539af438972442d0f86aa46409e6684338ddfd1fbfd6bdacf02220853ccb55.jpg"
}
]
}
]
},
{
"bbox": [
310,
311,
564,
371
],
"type": "image_caption",
"lines": [
{
"bbox": [
312,
313,
562,
322
],
"spans": [
{
"bbox": [
312,
313,
562,
322
],
"score": 0.97,
"content": "Figure 3: Performance of temporal matching at different levels",
"type": "text"
}
]
},
{
"bbox": [
312,
325,
561,
334
],
"spans": [
{
"bbox": [
312,
325,
561,
334
],
"score": 0.98,
"content": "of uniformly distributed image noise{±0,±20,±40}.Mean",
"type": "text"
}
]
},
{
"bbox": [
311,
336,
563,
347
],
"spans": [
{
"bbox": [
311,
336,
563,
347
],
"score": 0.99,
"content": "squared error (MSE) of disparities is plotted versus the values",
"type": "text"
}
]
},
{
"bbox": [
311,
348,
561,
358
],
"spans": [
{
"bbox": [
311,
348,
561,
358
],
"score": 0.96,
"content": "of the feedback coefficient X. Dashed lines correspond to the",
"type": "text"
}
]
},
{
"bbox": [
311,
360,
535,
371
],
"spans": [
{
"bbox": [
311,
360,
535,
371
],
"score": 0.96,
"content": "values of MSE obtained without temporal aggregation.",
"type": "text"
}
]
}
]
}
]
},
{
"type": "image",
"bbox": [
310,
418,
563,
666
],
"blocks": [
{
"bbox": [
314,
418,
549,
623
],
"type": "image_body",
"lines": [
{
"bbox": [
314,
418,
549,
623
],
"spans": [
{
"bbox": [
314,
418,
549,
623
],
"score": 0.9999067783355713,
"type": "image",
"image_path": "9ac4db9197801de4a20dbc9ea17bc0c53afb7290dc8b5b45d9e92e830566cb14.jpg"
}
]
}
]
},
{
"bbox": [
310,
630,
563,
666
],
"type": "image_caption",
"lines": [
{
"bbox": [
312,
631,
562,
641
],
"spans": [
{
"bbox": [
312,
631,
562,
641
],
"score": 0.94,
"content": "Figure 4:Optimal values of the feedback coefficient \\ cor-",
"type": "text"
}
]
},
{
"bbox": [
312,
644,
561,
652
],
"spans": [
{
"bbox": [
312,
644,
561,
652
],
"score": 0.97,
"content": "responding to the smallest mean squared error (MSE)of the",
"type": "text"
}
]
},
{
"bbox": [
312,
655,
513,
665
],
"spans": [
{
"bbox": [
312,
655,
513,
665
],
"score": 0.97,
"content": "disparity estimates for a range of noise strengths.",
"type": "text"
}
]
}
]
}
]
},
{
"type": "text",
"bbox": [
311,
692,
563,
725
],
"lines": [
{
"bbox": [
311,
692,
563,
702
],
"spans": [
{
"bbox": [
311,
692,
562,
702
],
"score": 0.95,
"content": "of averaging out noise in the per-pixel costs by selecting",
"type": "text"
}
]
},
{
"bbox": [
311,
704,
563,
713
],
"spans": [
{
"bbox": [
311,
704,
562,
713
],
"score": 0.98,
"content": "matches based more heavily upon the auxiliary cost, which",
"type": "text"
}
]
},
{
"bbox": [
311,
716,
563,
725
],
"spans": [
{
"bbox": [
311,
716,
563,
725
],
"score": 0.97,
"content": "is essentially a much more stable running average of the cost",
"type": "text"
}
]
}
]
}
],
"layout_bboxes": [
{
"layout_bbox": [
47,
55,
301,
726
],
"layout_label": "V",
"sub_layout": []
},
{
"layout_bbox": [
310,
55,
564,
726
],
"layout_label": "V",
"sub_layout": []
}
],
"page_idx": 0,
"page_size": [
612.0,
792.0
],
"_layout_tree": [
{
"layout_bbox": [
0,
55,
612.0,
726
],
"layout_label": "V",
"sub_layout": [
{
"layout_bbox": [
47,
55,
564,
726
],
"layout_label": "H",
"sub_layout": [
{
"layout_bbox": [
47,
55,
301,
726
],
"layout_label": "V",
"sub_layout": []
},
{
"layout_bbox": [
310,
55,
564,
726
],
"layout_label": "V",
"sub_layout": []
}
]
}
]
}
],
"images": [
{
"type": "image",
"bbox": [
47,
100,
301,
535
],
"blocks": [
{
"bbox": [
51,
100,
292,
484
],
"type": "image_body",
"lines": [
{
"bbox": [
51,
100,
292,
484
],
"spans": [
{
"bbox": [
51,
100,
292,
484
],
"score": 0.9999815225601196,
"type": "image",
"image_path": "b07d74524eac6f46b5505b48b1e10db23f2b45cb2d21d5fec72e967e61255811.jpg"
}
]
}
]
},
{
"bbox": [
47,
488,
301,
535
],
"type": "image_caption",
"lines": [
{
"bbox": [
49,
490,
299,
499
],
"spans": [
{
"bbox": [
49,
490,
299,
499
],
"score": 1.0,
"content": "Figure2:Twosampleframesfromthesyntheticvideose-",
"type": "text"
}
]
},
{
"bbox": [
48,
501,
300,
512
],
"spans": [
{
"bbox": [
48,
501,
300,
512
],
"score": 1.0,
"content": "quence (1st row), along with their corresponding ground truth",
"type": "text"
}
]
},
{
"bbox": [
48,
513,
299,
523
],
"spans": [
{
"bbox": [
48,
513,
299,
523
],
"score": 0.98,
"content": "disparity (2nd row), occlusion map (3rd row), and discontinuity",
"type": "text"
}
]
},
{
"bbox": [
48,
525,
110,
535
],
"spans": [
{
"bbox": [
48,
525,
110,
535
],
"score": 0.99,
"content": "map (4th row).",
"type": "text"
}
]
}
]
}
]
},
{
"type": "image",
"bbox": [
310,
55,
564,
371
],
"blocks": [
{
"bbox": [
314,
55,
538,
305
],
"type": "image_body",
"lines": [
{
"bbox": [
314,
55,
538,
305
],
"spans": [
{
"bbox": [
314,
55,
538,
305
],
"score": 0.9999905824661255,
"type": "image",
"image_path": "c7539af438972442d0f86aa46409e6684338ddfd1fbfd6bdacf02220853ccb55.jpg"
}
]
}
]
},
{
"bbox": [
310,
311,
564,
371
],
"type": "image_caption",
"lines": [
{
"bbox": [
312,
313,
562,
322
],
"spans": [
{
"bbox": [
312,
313,
562,
322
],
"score": 0.97,
"content": "Figure 3: Performance of temporal matching at different levels",
"type": "text"
}
]
},
{
"bbox": [
312,
325,
561,
334
],
"spans": [
{
"bbox": [
312,
325,
561,
334
],
"score": 0.98,
"content": "of uniformly distributed image noise{±0,±20,±40}.Mean",
"type": "text"
}
]
},
{
"bbox": [
311,
336,
563,
347
],
"spans": [
{
"bbox": [
311,
336,
563,
347
],
"score": 0.99,
"content": "squared error (MSE) of disparities is plotted versus the values",
"type": "text"
}
]
},
{
"bbox": [
311,
348,
561,
358
],
"spans": [
{
"bbox": [
311,
348,
561,
358
],
"score": 0.96,
"content": "of the feedback coefficient X. Dashed lines correspond to the",
"type": "text"
}
]
},
{
"bbox": [
311,
360,
535,
371
],
"spans": [
{
"bbox": [
311,
360,
535,
371
],
"score": 0.96,
"content": "values of MSE obtained without temporal aggregation.",
"type": "text"
}
]
}
]
}
]
},
{
"type": "image",
"bbox": [
310,
418,
563,
666
],
"blocks": [
{
"bbox": [
314,
418,
549,
623
],
"type": "image_body",
"lines": [
{
"bbox": [
314,
418,
549,
623
],
"spans": [
{
"bbox": [
314,
418,
549,
623
],
"score": 0.9999067783355713,
"type": "image",
"image_path": "9ac4db9197801de4a20dbc9ea17bc0c53afb7290dc8b5b45d9e92e830566cb14.jpg"
}
]
}
]
},
{
"bbox": [
310,
630,
563,
666
],
"type": "image_caption",
"lines": [
{
"bbox": [
312,
631,
562,
641
],
"spans": [
{
"bbox": [
312,
631,
562,
641
],
"score": 0.94,
"content": "Figure 4:Optimal values of the feedback coefficient \\ cor-",
"type": "text"
}
]
},
{
"bbox": [
312,
644,
561,
652
],
"spans": [
{
"bbox": [
312,
644,
561,
652
],
"score": 0.97,
"content": "responding to the smallest mean squared error (MSE)of the",
"type": "text"
}
]
},
{
"bbox": [
312,
655,
513,
665
],
"spans": [
{
"bbox": [
312,
655,
513,
665
],
"score": 0.97,
"content": "disparity estimates for a range of noise strengths.",
"type": "text"
}
]
}
]
}
]
}
],
"tables": [],
"interline_equations": [],
"discarded_blocks": [],
"need_drop": false,
"drop_reason": [],
"para_blocks": [
{
"type": "text",
"bbox": [
47,
57,
299,
93
],
"lines": [
{
"bbox": [
47,
57,
299,
68
],
"spans": [
{
"bbox": [
49,
57,
298,
68
],
"score": 0.98,
"content": "of the synthetic stereo scene from a single camera perspective",
"type": "text"
}
]
},
{
"bbox": [
47,
71,
299,
80
],
"spans": [
{
"bbox": [
49,
71,
299,
80
],
"score": 0.96,
"content": "along with the ground truth disparity,occlusion map,and",
"type": "text"
}
]
},
{
"bbox": [
47,
82,
123,
93
],
"spans": [
{
"bbox": [
49,
82,
123,
93
],
"score": 0.99,
"content": "discontinuitymap.",
"type": "text"
}
]
}
]
},
{
"type": "image",
"bbox": [
47,
100,
301,
535
],
"blocks": [
{
"bbox": [
51,
100,
292,
484
],
"type": "image_body",
"lines": [
{
"bbox": [
51,
100,
292,
484
],
"spans": [
{
"bbox": [
51,
100,
292,
484
],
"score": 0.9999815225601196,
"type": "image",
"image_path": "b07d74524eac6f46b5505b48b1e10db23f2b45cb2d21d5fec72e967e61255811.jpg"
}
]
}
]
},
{
"bbox": [
47,
488,
301,
535
],
"type": "image_caption",
"lines": [
{
"bbox": [
49,
490,
299,
499
],
"spans": [
{
"bbox": [
49,
490,
299,
499
],
"score": 1.0,
"content": "Figure2:Twosampleframesfromthesyntheticvideose-",
"type": "text"
}
]
},
{
"bbox": [
48,
501,
300,
512
],
"spans": [
{
"bbox": [
48,
501,
300,
512
],
"score": 1.0,
"content": "quence (1st row), along with their corresponding ground truth",
"type": "text"
}
]
},
{
"bbox": [
48,
513,
299,
523
],
"spans": [
{
"bbox": [
48,
513,
299,
523
],
"score": 0.98,
"content": "disparity (2nd row), occlusion map (3rd row), and discontinuity",
"type": "text"
}
]
},
{
"bbox": [
48,
525,
110,
535
],
"spans": [
{
"bbox": [
48,
525,
110,
535
],
"score": 0.99,
"content": "map (4th row).",
"type": "text"
}
]
}
]
}
]
},
{
"type": "text",
"bbox": [
47,
549,
299,
678
],
"lines": [
{
"bbox": [
58,
549,
299,
558
],
"spans": [
{
"bbox": [
58,
549,
298,
558
],
"score": 0.98,
"content": "Theresultsof temporalstereomatching aregiveninFigure",
"type": "text"
}
]
},
{
"bbox": [
47,
561,
299,
570
],
"spans": [
{
"bbox": [
47,
561,
298,
570
],
"score": 0.98,
"content": "3foruniformadditivenoiseconfinedtotherangesof±O",
"type": "text"
}
]
},
{
"bbox": [
47,
573,
299,
582
],
"spans": [
{
"bbox": [
49,
573,
299,
582
],
"score": 0.96,
"content": "±20, and ±40. Each performance plot is given as a function",
"type": "text"
}
]
},
{
"bbox": [
47,
585,
299,
594
],
"spans": [
{
"bbox": [
48,
585,
299,
594
],
"score": 0.95,
"content": "of the feedback coefficient X. As with the majority of temporal",
"type": "text"
}
]
},
{
"bbox": [
47,
597,
299,
606
],
"spans": [
{
"bbox": [
49,
597,
299,
606
],
"score": 0.99,
"content": "stereomatching methods,improvements are negligible when",
"type": "text"
}
]
},
{
"bbox": [
47,
609,
299,
618
],
"spans": [
{
"bbox": [
48,
609,
299,
618
],
"score": 0.97,
"content": "no noise is added to the images [1o], [19]. This is largely due",
"type": "text"
}
]
},
{
"bbox": [
47,
621,
299,
629
],
"spans": [
{
"bbox": [
48,
621,
299,
629
],
"score": 1.0,
"content": "tothefactthatthevideousedtoevaluatethesemethodsis",
"type": "text"
}
]
},
{
"bbox": [
47,
633,
299,
641
],
"spans": [
{
"bbox": [
48,
633,
299,
641
],
"score": 1.0,
"content": "computergeneratedwithverylittlenoisetostartwith,thus",
"type": "text"
}
]
},
{
"bbox": [
47,
644,
299,
654
],
"spans": [
{
"bbox": [
48,
644,
299,
654
],
"score": 0.98,
"content": "the noise suppression achieved with temporal stereo matching",
"type": "text"
}
]
},
{
"bbox": [
47,
657,
299,
666
],
"spans": [
{
"bbox": [
48,
657,
299,
666
],
"score": 0.98,
"content": "showslittletonoimprovementovermethodsthatoperate on",
"type": "text"
}
]
},
{
"bbox": [
47,
669,
113,
678
],
"spans": [
{
"bbox": [
48,
669,
113,
678
],
"score": 1.0,
"content": "pairsofimages.",
"type": "text"
}
]
}
]
},
{
"type": "text",
"bbox": [
47,
680,
299,
725
],
"lines": [
{
"bbox": [
58,
680,
299,
690
],
"spans": [
{
"bbox": [
59,
680,
298,
690
],
"score": 0.97,
"content": "Significantimprovementsin accuracy canbeseenin Figure",
"type": "text"
}
]
},
{
"bbox": [
47,
692,
299,
701
],
"spans": [
{
"bbox": [
48,
692,
298,
701
],
"score": 0.97,
"content": "3 when the noise has ranges of ±20, and ±40.In this scenario",
"type": "text"
}
]
},
{
"bbox": [
47,
703,
299,
714
],
"spans": [
{
"bbox": [
48,
703,
299,
714
],
"score": 0.98,
"content": "the effect of noise in the current frame is reduced by increasing",
"type": "text"
}
]
},
{
"bbox": [
47,
716,
299,
725
],
"spans": [
{
"bbox": [
48,
716,
299,
725
],
"score": 0.96,
"content": "thefeedbackcoefficientX.Thisincreasing ofXhas theeffect",
"type": "text"
}
]
}
]
},
{
"type": "image",
"bbox": [
310,
55,
564,
371
],
"blocks": [
{
"bbox": [
314,
55,
538,
305
],
"type": "image_body",
"lines": [
{
"bbox": [
314,
55,
538,
305
],
"spans": [
{
"bbox": [
314,
55,
538,
305
],
"score": 0.9999905824661255,
"type": "image",
"image_path": "c7539af438972442d0f86aa46409e6684338ddfd1fbfd6bdacf02220853ccb55.jpg"
}
]
}
]
},
{
"bbox": [
310,
311,
564,
371
],
"type": "image_caption",
"lines": [
{
"bbox": [
312,
313,
562,
322
],
"spans": [
{
"bbox": [
312,
313,
562,
322
],
"score": 0.97,
"content": "Figure 3: Performance of temporal matching at different levels",
"type": "text"
}
]
},
{
"bbox": [
312,
325,
561,
334
],
"spans": [
{
"bbox": [
312,
325,
561,
334
],
"score": 0.98,
"content": "of uniformly distributed image noise{±0,±20,±40}.Mean",
"type": "text"
}
]
},
{
"bbox": [
311,
336,
563,
347
],
"spans": [
{
"bbox": [
311,
336,
563,
347
],
"score": 0.99,
"content": "squared error (MSE) of disparities is plotted versus the values",
"type": "text"
}
]
},
{
"bbox": [
311,
348,
561,
358
],
"spans": [
{
"bbox": [
311,
348,
561,
358
],
"score": 0.96,
"content": "of the feedback coefficient X. Dashed lines correspond to the",
"type": "text"
}
]
},
{
"bbox": [
311,
360,
535,
371
],
"spans": [
{
"bbox": [
311,
360,
535,
371
],
"score": 0.96,
"content": "values of MSE obtained without temporal aggregation.",
"type": "text"
}
]
}
]
}
]
},
{
"type": "image",
"bbox": [
310,
418,
563,
666
],
"blocks": [
{
"bbox": [
314,
418,
549,
623
],
"type": "image_body",
"lines": [
{
"bbox": [
314,
418,
549,
623
],
"spans": [
{
"bbox": [
314,
418,
549,
623
],
"score": 0.9999067783355713,
"type": "image",
"image_path": "9ac4db9197801de4a20dbc9ea17bc0c53afb7290dc8b5b45d9e92e830566cb14.jpg"
}
]
}
]
},
{
"bbox": [
310,
630,
563,
666
],
"type": "image_caption",
"lines": [
{
"bbox": [
312,
631,
562,
641
],
"spans": [
{
"bbox": [
312,
631,
562,
641
],
"score": 0.94,
"content": "Figure 4:Optimal values of the feedback coefficient \\ cor-",
"type": "text"
}
]
},
{
"bbox": [
312,
644,
561,
652
],
"spans": [
{
"bbox": [
312,
644,
561,
652
],
"score": 0.97,
"content": "responding to the smallest mean squared error (MSE)of the",
"type": "text"
}
]
},
{
"bbox": [
312,
655,
513,
665
],
"spans": [
{
"bbox": [
312,
655,
513,
665
],
"score": 0.97,
"content": "disparity estimates for a range of noise strengths.",
"type": "text"
}
]
}
]
}
]
},
{
"type": "text",
"bbox": [
311,
692,
563,
725
],
"lines": [
{
"bbox": [
311,
692,
563,
702
],
"spans": [
{
"bbox": [
311,
692,
562,
702
],
"score": 0.95,
"content": "of averaging out noise in the per-pixel costs by selecting",
"type": "text"
}
]
},
{
"bbox": [
311,
704,
563,
713
],
"spans": [
{
"bbox": [
311,
704,
562,
713
],
"score": 0.98,
"content": "matches based more heavily upon the auxiliary cost, which",
"type": "text"
}
]
},
{
"bbox": [
311,
716,
563,
725
],
"spans": [
{
"bbox": [
311,
716,
563,
725
],
"score": 0.97,
"content": "is essentially a much more stable running average of the cost",
"type": "text"
}
]
}
]
}
]
}
],
"_parse_type": "ocr",
"_version_name": "0.7.0b1"
}
import json
import os
import shutil
import tempfile
from magic_pdf.integrations.rag.api import DataReader, RagDocumentReader
from magic_pdf.integrations.rag.type import CategoryType
from magic_pdf.integrations.rag.utils import \
convert_middle_json_to_layout_elements
def test_rag_document_reader():
# setup
unitest_dir = '/tmp/magic_pdf/unittest/integrations/rag'
os.makedirs(unitest_dir, exist_ok=True)
temp_output_dir = tempfile.mkdtemp(dir=unitest_dir)
os.makedirs(temp_output_dir, exist_ok=True)
# test
with open('tests/test_integrations/test_rag/assets/middle.json') as f:
json_data = json.load(f)
res = convert_middle_json_to_layout_elements(json_data, temp_output_dir)
doc = RagDocumentReader(res)
assert len(list(iter(doc))) == 1
page = list(iter(doc))[0]
assert len(list(iter(page))) == 10
assert len(page.get_rel_map()) == 3
item = list(iter(page))[0]
assert item.category_type == CategoryType.text
# teardown
shutil.rmtree(temp_output_dir)
def test_data_reader():
# setup
unitest_dir = '/tmp/magic_pdf/unittest/integrations/rag'
os.makedirs(unitest_dir, exist_ok=True)
temp_output_dir = tempfile.mkdtemp(dir=unitest_dir)
os.makedirs(temp_output_dir, exist_ok=True)
# test
data_reader = DataReader('tests/test_integrations/test_rag/assets', 'ocr',
temp_output_dir)
assert data_reader.get_documents_count() == 2
for idx in range(data_reader.get_documents_count()):
document = data_reader.get_document_result(idx)
assert document is not None
# teardown
shutil.rmtree(temp_output_dir)
import json
import os
import shutil
import tempfile
from magic_pdf.integrations.rag.type import CategoryType
from magic_pdf.integrations.rag.utils import (
convert_middle_json_to_layout_elements, inference)
def test_convert_middle_json_to_layout_elements():
# setup
unitest_dir = '/tmp/magic_pdf/unittest/integrations/rag'
os.makedirs(unitest_dir, exist_ok=True)
temp_output_dir = tempfile.mkdtemp(dir=unitest_dir)
os.makedirs(temp_output_dir, exist_ok=True)
# test
with open('tests/test_integrations/test_rag/assets/middle.json') as f:
json_data = json.load(f)
res = convert_middle_json_to_layout_elements(json_data, temp_output_dir)
assert len(res) == 1
assert len(res[0].layout_dets) == 10
assert res[0].layout_dets[0].anno_id == 0
assert res[0].layout_dets[0].category_type == CategoryType.text
assert len(res[0].extra.element_relation) == 3
# teardown
shutil.rmtree(temp_output_dir)
def test_inference():
asset_dir = 'tests/test_integrations/test_rag/assets'
# setup
unitest_dir = '/tmp/magic_pdf/unittest/integrations/rag'
os.makedirs(unitest_dir, exist_ok=True)
temp_output_dir = tempfile.mkdtemp(dir=unitest_dir)
os.makedirs(temp_output_dir, exist_ok=True)
# test
res = inference(
asset_dir + '/one_page_with_table_image.pdf',
temp_output_dir,
'ocr',
)
assert res is not None
assert len(res) == 1
assert len(res[0].layout_dets) == 10
assert res[0].layout_dets[0].anno_id == 0
assert res[0].layout_dets[0].category_type == CategoryType.text
assert len(res[0].extra.element_relation) == 3
# teardown
shutil.rmtree(temp_output_dir)
from magic_pdf.dict2md.ocr_mkcontent import __is_hyphen_at_line_end
def test_hyphen_at_line_end():
"""
测试行尾是不是一个连字符
"""
test_cases_ok = [
"I am zhang-",
"you are zhang- ",
"math-",
"This is a TEST-",
"This is a TESTing-",
"美国人 hello-",
]
test_cases_bad = [
"This is a TEST$-",
"This is a TEST21-",
"中国人-",
"美国人 hello人-",
"this is 123-",
]
for test_case in test_cases_ok:
assert __is_hyphen_at_line_end(test_case)
for test_case in test_cases_bad:
assert not __is_hyphen_at_line_end(test_case)
\ No newline at end of file
...@@ -19,7 +19,12 @@ def test_common_do_parse(method): ...@@ -19,7 +19,12 @@ def test_common_do_parse(method):
# run # run
with open("tests/test_tools/assets/common/cli_test_01.pdf", "rb") as f: with open("tests/test_tools/assets/common/cli_test_01.pdf", "rb") as f:
bits = f.read() bits = f.read()
do_parse(temp_output_dir, filename, bits, [], method, f_dump_content_list=True) do_parse(temp_output_dir,
filename,
bits, [],
method,
False,
f_dump_content_list=True)
# check # check
base_output_dir = os.path.join(temp_output_dir, f"fake/{method}") base_output_dir = os.path.join(temp_output_dir, f"fake/{method}")
......
import pytest
import os import os
from magic_pdf.libs.boxbase import _is_in_or_part_overlap, _is_in_or_part_overlap_with_area_ratio, _is_in, \
_is_part_overlap, _left_intersect, _right_intersect, _is_vertical_full_overlap, _is_bottom_full_overlap, \ import pytest
_is_left_overlap, __is_overlaps_y_exceeds_threshold, calculate_iou, calculate_overlap_area_2_minbox_area_ratio, \
calculate_overlap_area_in_bbox1_area_ratio, get_minbox_if_overlap_by_ratio, get_bbox_in_boundry, \ from magic_pdf.libs.boxbase import (__is_overlaps_y_exceeds_threshold,
find_top_nearest_text_bbox, find_bottom_nearest_text_bbox, find_left_nearest_text_bbox, \ _is_bottom_full_overlap, _is_in,
find_right_nearest_text_bbox, bbox_relative_pos, bbox_distance _is_in_or_part_overlap,
from magic_pdf.libs.commons import mymax, join_path, get_top_percent_list _is_in_or_part_overlap_with_area_ratio,
_is_left_overlap, _is_part_overlap,
_is_vertical_full_overlap, _left_intersect,
_right_intersect, bbox_distance,
bbox_relative_pos, calculate_iou,
calculate_overlap_area_2_minbox_area_ratio,
calculate_overlap_area_in_bbox1_area_ratio,
find_bottom_nearest_text_bbox,
find_left_nearest_text_bbox,
find_right_nearest_text_bbox,
find_top_nearest_text_bbox,
get_bbox_in_boundary,
get_minbox_if_overlap_by_ratio)
from magic_pdf.libs.commons import get_top_percent_list, join_path, mymax
from magic_pdf.libs.config_reader import get_s3_config from magic_pdf.libs.config_reader import get_s3_config
from magic_pdf.libs.path_utils import parse_s3path from magic_pdf.libs.path_utils import parse_s3path
# 输入一个列表,如果列表空返回0,否则返回最大元素 # 输入一个列表,如果列表空返回0,否则返回最大元素
@pytest.mark.parametrize("list_input, target_num", @pytest.mark.parametrize('list_input, target_num',
[ [
([0, 0, 0, 0], 0), ([0, 0, 0, 0], 0),
([0], 0), ([0], 0),
...@@ -29,7 +41,7 @@ def test_list_max(list_input: list, target_num) -> None: ...@@ -29,7 +41,7 @@ def test_list_max(list_input: list, target_num) -> None:
# 连接多个参数生成路径信息,使用"/"作为连接符,生成的结果需要是一个合法路径 # 连接多个参数生成路径信息,使用"/"作为连接符,生成的结果需要是一个合法路径
@pytest.mark.parametrize("path_input, target_path", [ @pytest.mark.parametrize('path_input, target_path', [
(['https:', '', 'www.baidu.com'], 'https://www.baidu.com'), (['https:', '', 'www.baidu.com'], 'https://www.baidu.com'),
(['https:', 'www.baidu.com'], 'https:/www.baidu.com'), (['https:', 'www.baidu.com'], 'https:/www.baidu.com'),
(['D:', 'file', 'pythonProject', 'demo' + '.py'], 'D:/file/pythonProject/demo.py'), (['D:', 'file', 'pythonProject', 'demo' + '.py'], 'D:/file/pythonProject/demo.py'),
...@@ -42,7 +54,7 @@ def test_join_path(path_input: list, target_path: str) -> None: ...@@ -42,7 +54,7 @@ def test_join_path(path_input: list, target_path: str) -> None:
# 获取列表中前百分之多少的元素 # 获取列表中前百分之多少的元素
@pytest.mark.parametrize("num_list, percent, target_num_list", [ @pytest.mark.parametrize('num_list, percent, target_num_list', [
([], 0.75, []), ([], 0.75, []),
([-5, -10, 9, 3, 7, -7, 0, 23, -1, -11], 0.8, [23, 9, 7, 3, 0, -1, -5, -7]), ([-5, -10, 9, 3, 7, -7, 0, 23, -1, -11], 0.8, [23, 9, 7, 3, 0, -1, -5, -7]),
([-5, -10, 9, 3, 7, -7, 0, 23, -1, -11], 0, []), ([-5, -10, 9, 3, 7, -7, 0, 23, -1, -11], 0, []),
...@@ -57,9 +69,9 @@ def test_get_top_percent_list(num_list: list, percent: float, target_num_list: l ...@@ -57,9 +69,9 @@ def test_get_top_percent_list(num_list: list, percent: float, target_num_list: l
# 输入一个s3路径,返回bucket名字和其余部分(key) # 输入一个s3路径,返回bucket名字和其余部分(key)
@pytest.mark.parametrize("s3_path, target_data", [ @pytest.mark.parametrize('s3_path, target_data', [
("s3://bucket/path/to/my/file.txt", "bucket"), ('s3://bucket/path/to/my/file.txt', 'bucket'),
("s3a://bucket1/path/to/my/file2.txt", "bucket1"), ('s3a://bucket1/path/to/my/file2.txt', 'bucket1'),
# ("/path/to/my/file1.txt", "path"), # ("/path/to/my/file1.txt", "path"),
# ("bucket/path/to/my/file2.txt", "bucket"), # ("bucket/path/to/my/file2.txt", "bucket"),
]) ])
...@@ -76,7 +88,7 @@ def test_parse_s3path(s3_path: str, target_data: str): ...@@ -76,7 +88,7 @@ def test_parse_s3path(s3_path: str, target_data: str):
# 2个box是否处于包含或者部分重合关系。 # 2个box是否处于包含或者部分重合关系。
# 如果某边界重合算重合。 # 如果某边界重合算重合。
# 部分边界重合,其他在内部也算包含 # 部分边界重合,其他在内部也算包含
@pytest.mark.parametrize("box1, box2, target_bool", [ @pytest.mark.parametrize('box1, box2, target_bool', [
((120, 133, 223, 248), (128, 168, 269, 295), True), ((120, 133, 223, 248), (128, 168, 269, 295), True),
((137, 53, 245, 157), (134, 11, 200, 147), True), # 部分重合 ((137, 53, 245, 157), (134, 11, 200, 147), True), # 部分重合
((137, 56, 211, 116), (140, 66, 202, 199), True), # 部分重合 ((137, 56, 211, 116), (140, 66, 202, 199), True), # 部分重合
...@@ -101,7 +113,7 @@ def test_is_in_or_part_overlap(box1: tuple, box2: tuple, target_bool: bool) -> N ...@@ -101,7 +113,7 @@ def test_is_in_or_part_overlap(box1: tuple, box2: tuple, target_bool: bool) -> N
# 如果box1在box2内部,返回True # 如果box1在box2内部,返回True
# 如果是部分重合的,则重合面积占box1的比例大于阈值时候返回True # 如果是部分重合的,则重合面积占box1的比例大于阈值时候返回True
@pytest.mark.parametrize("box1, box2, target_bool", [ @pytest.mark.parametrize('box1, box2, target_bool', [
((35, 28, 108, 90), (47, 60, 83, 96), False), # 包含 box1 up box2, box2 多半,box1少半 ((35, 28, 108, 90), (47, 60, 83, 96), False), # 包含 box1 up box2, box2 多半,box1少半
((65, 151, 92, 177), (49, 99, 105, 198), True), # 包含 box1 in box2 ((65, 151, 92, 177), (49, 99, 105, 198), True), # 包含 box1 in box2
((80, 62, 112, 84), (74, 40, 144, 111), True), # 包含 box1 in box2 ((80, 62, 112, 84), (74, 40, 144, 111), True), # 包含 box1 in box2
...@@ -119,7 +131,7 @@ def test_is_in_or_part_overlap_with_area_ratio(box1: tuple, box2: tuple, target_ ...@@ -119,7 +131,7 @@ def test_is_in_or_part_overlap_with_area_ratio(box1: tuple, box2: tuple, target_
# box1在box2内部或者box2在box1内部返回True。如果部分边界重合也算作包含。 # box1在box2内部或者box2在box1内部返回True。如果部分边界重合也算作包含。
@pytest.mark.parametrize("box1, box2, target_bool", [ @pytest.mark.parametrize('box1, box2, target_bool', [
# ((), (), "Error"), # Error # ((), (), "Error"), # Error
((65, 151, 92, 177), (49, 99, 105, 198), True), # 包含 box1 in box2 ((65, 151, 92, 177), (49, 99, 105, 198), True), # 包含 box1 in box2
((80, 62, 112, 84), (74, 40, 144, 111), True), # 包含 box1 in box2 ((80, 62, 112, 84), (74, 40, 144, 111), True), # 包含 box1 in box2
...@@ -141,7 +153,7 @@ def test_is_in(box1: tuple, box2: tuple, target_bool: bool) -> None: ...@@ -141,7 +153,7 @@ def test_is_in(box1: tuple, box2: tuple, target_bool: bool) -> None:
# 仅仅是部分包含关系,返回True,如果是完全包含关系则返回False # 仅仅是部分包含关系,返回True,如果是完全包含关系则返回False
@pytest.mark.parametrize("box1, box2, target_bool", [ @pytest.mark.parametrize('box1, box2, target_bool', [
((65, 151, 92, 177), (49, 99, 105, 198), False), # 包含 box1 in box2 ((65, 151, 92, 177), (49, 99, 105, 198), False), # 包含 box1 in box2
((80, 62, 112, 84), (74, 40, 144, 111), False), # 包含 box1 in box2 ((80, 62, 112, 84), (74, 40, 144, 111), False), # 包含 box1 in box2
# ((76, 140, 154, 277), (121, 326, 192, 384), False), # 分离 Error # ((76, 140, 154, 277), (121, 326, 192, 384), False), # 分离 Error
...@@ -161,7 +173,7 @@ def test_is_part_overlap(box1: tuple, box2: tuple, target_bool: bool) -> None: ...@@ -161,7 +173,7 @@ def test_is_part_overlap(box1: tuple, box2: tuple, target_bool: bool) -> None:
# left_box右侧是否和right_box左侧有部分重叠 # left_box右侧是否和right_box左侧有部分重叠
@pytest.mark.parametrize("box1, box2, target_bool", [ @pytest.mark.parametrize('box1, box2, target_bool', [
(None, None, False), (None, None, False),
((88, 81, 222, 173), (60, 221, 123, 358), False), # 分离 ((88, 81, 222, 173), (60, 221, 123, 358), False), # 分离
((121, 149, 184, 289), (172, 130, 230, 268), True), # box1 left bottom box2 相交 ((121, 149, 184, 289), (172, 130, 230, 268), True), # box1 left bottom box2 相交
...@@ -179,7 +191,7 @@ def test_left_intersect(box1: tuple, box2: tuple, target_bool: bool) -> None: ...@@ -179,7 +191,7 @@ def test_left_intersect(box1: tuple, box2: tuple, target_bool: bool) -> None:
# left_box左侧是否和right_box右侧部分重叠 # left_box左侧是否和right_box右侧部分重叠
@pytest.mark.parametrize("box1, box2, target_bool", [ @pytest.mark.parametrize('box1, box2, target_bool', [
(None, None, False), (None, None, False),
((88, 81, 222, 173), (60, 221, 123, 358), False), # 分离 ((88, 81, 222, 173), (60, 221, 123, 358), False), # 分离
((121, 149, 184, 289), (172, 130, 230, 268), False), # box1 left bottom box2 相交 ((121, 149, 184, 289), (172, 130, 230, 268), False), # box1 left bottom box2 相交
...@@ -198,7 +210,7 @@ def test_right_intersect(box1: tuple, box2: tuple, target_bool: bool) -> None: ...@@ -198,7 +210,7 @@ def test_right_intersect(box1: tuple, box2: tuple, target_bool: bool) -> None:
# x方向上:要么box1包含box2, 要么box2包含box1。不能部分包含 # x方向上:要么box1包含box2, 要么box2包含box1。不能部分包含
# y方向上:box1和box2有重叠 # y方向上:box1和box2有重叠
@pytest.mark.parametrize("box1, box2, target_bool", [ @pytest.mark.parametrize('box1, box2, target_bool', [
# (None, None, False), # Error # (None, None, False), # Error
((35, 28, 108, 90), (47, 60, 83, 96), True), # box1 top box2, x:box2 in box1, y:有重叠 ((35, 28, 108, 90), (47, 60, 83, 96), True), # box1 top box2, x:box2 in box1, y:有重叠
((35, 28, 98, 90), (27, 60, 103, 96), True), # box1 top box2, x:box1 in box2, y:有重叠 ((35, 28, 98, 90), (27, 60, 103, 96), True), # box1 top box2, x:box1 in box2, y:有重叠
...@@ -214,7 +226,7 @@ def test_is_vertical_full_overlap(box1: tuple, box2: tuple, target_bool: bool) - ...@@ -214,7 +226,7 @@ def test_is_vertical_full_overlap(box1: tuple, box2: tuple, target_bool: bool) -
# 检查box1下方和box2的上方有轻微的重叠,轻微程度收到y_tolerance的限制 # 检查box1下方和box2的上方有轻微的重叠,轻微程度收到y_tolerance的限制
@pytest.mark.parametrize("box1, box2, target_bool", [ @pytest.mark.parametrize('box1, box2, target_bool', [
(None, None, False), (None, None, False),
((35, 28, 108, 90), (47, 89, 83, 116), True), # box1 top box2, y:有重叠 ((35, 28, 108, 90), (47, 89, 83, 116), True), # box1 top box2, y:有重叠
((35, 28, 108, 90), (47, 60, 83, 96), False), # box1 top box2, y:有重叠且过多 ((35, 28, 108, 90), (47, 60, 83, 96), False), # box1 top box2, y:有重叠且过多
...@@ -228,7 +240,7 @@ def test_is_bottom_full_overlap(box1: tuple, box2: tuple, target_bool: bool) -> ...@@ -228,7 +240,7 @@ def test_is_bottom_full_overlap(box1: tuple, box2: tuple, target_bool: bool) ->
# 检查box1的左侧是否和box2有重叠 # 检查box1的左侧是否和box2有重叠
@pytest.mark.parametrize("box1, box2, target_bool", [ @pytest.mark.parametrize('box1, box2, target_bool', [
(None, None, False), (None, None, False),
((88, 81, 222, 173), (60, 221, 123, 358), False), # 分离 ((88, 81, 222, 173), (60, 221, 123, 358), False), # 分离
# ((121, 149, 184, 289), (172, 130, 230, 268), False), # box1 left bottom box2 相交 Error # ((121, 149, 184, 289), (172, 130, 230, 268), False), # box1 left bottom box2 相交 Error
...@@ -245,7 +257,7 @@ def test_is_left_overlap(box1: tuple, box2: tuple, target_bool: bool) -> None: ...@@ -245,7 +257,7 @@ def test_is_left_overlap(box1: tuple, box2: tuple, target_bool: bool) -> None:
# 查两个bbox在y轴上是否有重叠,并且该重叠区域的高度占两个bbox高度更低的那个超过阈值 # 查两个bbox在y轴上是否有重叠,并且该重叠区域的高度占两个bbox高度更低的那个超过阈值
@pytest.mark.parametrize("box1, box2, target_bool", [ @pytest.mark.parametrize('box1, box2, target_bool', [
# (None, None, "Error"), # Error # (None, None, "Error"), # Error
((51, 69, 192, 147), (75, 48, 132, 187), True), # y: box1 in box2 ((51, 69, 192, 147), (75, 48, 132, 187), True), # y: box1 in box2
((51, 39, 192, 197), (75, 48, 132, 187), True), # y: box2 in box1 ((51, 39, 192, 197), (75, 48, 132, 187), True), # y: box2 in box1
...@@ -260,7 +272,7 @@ def test_is_overlaps_y_exceeds_threshold(box1: tuple, box2: tuple, target_bool: ...@@ -260,7 +272,7 @@ def test_is_overlaps_y_exceeds_threshold(box1: tuple, box2: tuple, target_bool:
# Determine the coordinates of the intersection rectangle # Determine the coordinates of the intersection rectangle
@pytest.mark.parametrize("box1, box2, target_num", [ @pytest.mark.parametrize('box1, box2, target_num', [
# (None, None, "Error"), # Error # (None, None, "Error"), # Error
((88, 81, 222, 173), (60, 221, 123, 358), 0.0), # 分离 ((88, 81, 222, 173), (60, 221, 123, 358), 0.0), # 分离
((76, 140, 154, 277), (121, 326, 192, 384), 0.0), # 分离 ((76, 140, 154, 277), (121, 326, 192, 384), 0.0), # 分离
...@@ -276,7 +288,7 @@ def test_calculate_iou(box1: tuple, box2: tuple, target_num: float) -> None: ...@@ -276,7 +288,7 @@ def test_calculate_iou(box1: tuple, box2: tuple, target_num: float) -> None:
# 计算box1和box2的重叠面积占最小面积的box的比例 # 计算box1和box2的重叠面积占最小面积的box的比例
@pytest.mark.parametrize("box1, box2, target_num", [ @pytest.mark.parametrize('box1, box2, target_num', [
# (None, None, "Error"), # Error # (None, None, "Error"), # Error
((142, 109, 238, 164), (134, 211, 224, 270), 0.0), # 分离 ((142, 109, 238, 164), (134, 211, 224, 270), 0.0), # 分离
((88, 81, 222, 173), (60, 221, 123, 358), 0.0), # 分离 ((88, 81, 222, 173), (60, 221, 123, 358), 0.0), # 分离
...@@ -295,7 +307,7 @@ def test_calculate_overlap_area_2_minbox_area_ratio(box1: tuple, box2: tuple, ta ...@@ -295,7 +307,7 @@ def test_calculate_overlap_area_2_minbox_area_ratio(box1: tuple, box2: tuple, ta
# 计算box1和box2的重叠面积占bbox1的比例 # 计算box1和box2的重叠面积占bbox1的比例
@pytest.mark.parametrize("box1, box2, target_num", [ @pytest.mark.parametrize('box1, box2, target_num', [
# (None, None, "Error"), # Error # (None, None, "Error"), # Error
((142, 109, 238, 164), (134, 211, 224, 270), 0.0), # 分离 ((142, 109, 238, 164), (134, 211, 224, 270), 0.0), # 分离
((88, 81, 222, 173), (60, 221, 123, 358), 0.0), # 分离 ((88, 81, 222, 173), (60, 221, 123, 358), 0.0), # 分离
...@@ -315,7 +327,7 @@ def test_calculate_overlap_area_in_bbox1_area_ratio(box1: tuple, box2: tuple, ta ...@@ -315,7 +327,7 @@ def test_calculate_overlap_area_in_bbox1_area_ratio(box1: tuple, box2: tuple, ta
# 计算两个bbox重叠的面积占最小面积的box的比例,如果比例大于ratio,则返回小的那个bbox,否则返回None # 计算两个bbox重叠的面积占最小面积的box的比例,如果比例大于ratio,则返回小的那个bbox,否则返回None
@pytest.mark.parametrize("box1, box2, ratio, target_box", [ @pytest.mark.parametrize('box1, box2, ratio, target_box', [
# (None, None, 0.8, "Error"), # Error # (None, None, 0.8, "Error"), # Error
((142, 109, 238, 164), (134, 211, 224, 270), 0.0, None), # 分离 ((142, 109, 238, 164), (134, 211, 224, 270), 0.0, None), # 分离
((109, 126, 204, 245), (110, 127, 232, 206), 0.5, (110, 127, 232, 206)), ((109, 126, 204, 245), (110, 127, 232, 206), 0.5, (110, 127, 232, 206)),
...@@ -331,7 +343,7 @@ def test_get_minbox_if_overlap_by_ratio(box1: tuple, box2: tuple, ratio: float, ...@@ -331,7 +343,7 @@ def test_get_minbox_if_overlap_by_ratio(box1: tuple, box2: tuple, ratio: float,
# 根据boundry获取在这个范围内的所有的box的列表,完全包含关系 # 根据boundry获取在这个范围内的所有的box的列表,完全包含关系
@pytest.mark.parametrize("boxes, boundry, target_boxs", [ @pytest.mark.parametrize('boxes, boundary, target_boxs', [
# ([], (), "Error"), # Error # ([], (), "Error"), # Error
([], (110, 340, 209, 387), []), ([], (110, 340, 209, 387), []),
([(142, 109, 238, 164)], (134, 211, 224, 270), []), # 分离 ([(142, 109, 238, 164)], (134, 211, 224, 270), []), # 分离
...@@ -347,15 +359,15 @@ def test_get_minbox_if_overlap_by_ratio(box1: tuple, box2: tuple, ratio: float, ...@@ -347,15 +359,15 @@ def test_get_minbox_if_overlap_by_ratio(box1: tuple, box2: tuple, ratio: float,
(137, 29, 287, 87)], (30, 20, 200, 320), (137, 29, 287, 87)], (30, 20, 200, 320),
[(81, 280, 123, 315), (46, 99, 133, 148), (33, 156, 97, 211)]), [(81, 280, 123, 315), (46, 99, 133, 148), (33, 156, 97, 211)]),
]) ])
def test_get_bbox_in_boundry(boxes: list, boundry: tuple, target_boxs: list) -> None: def test_get_bbox_in_boundary(boxes: list, boundary: tuple, target_boxs: list) -> None:
assert target_boxs == get_bbox_in_boundry(boxes, boundry) assert target_boxs == get_bbox_in_boundary(boxes, boundary)
# 寻找上方距离最近的box,margin 4个单位, x方向有重合,y方向最近的 # 寻找上方距离最近的box,margin 4个单位, x方向有重合,y方向最近的
@pytest.mark.parametrize("pymu_blocks, obj_box, target_boxs", [ @pytest.mark.parametrize('pymu_blocks, obj_box, target_boxs', [
([{"bbox": (81, 280, 123, 315)}, {"bbox": (282, 203, 342, 247)}, {"bbox": (183, 100, 300, 155)}, ([{'bbox': (81, 280, 123, 315)}, {'bbox': (282, 203, 342, 247)}, {'bbox': (183, 100, 300, 155)},
{"bbox": (46, 99, 133, 148)}, {"bbox": (33, 156, 97, 211)}, {'bbox': (46, 99, 133, 148)}, {'bbox': (33, 156, 97, 211)},
{"bbox": (137, 29, 287, 87)}], (81, 280, 123, 315), {"bbox": (33, 156, 97, 211)}), {'bbox': (137, 29, 287, 87)}], (81, 280, 123, 315), {'bbox': (33, 156, 97, 211)}),
# ([{"bbox": (168, 120, 263, 159)}, # ([{"bbox": (168, 120, 263, 159)},
# {"bbox": (231, 61, 279, 159)}, # {"bbox": (231, 61, 279, 159)},
# {"bbox": (35, 85, 136, 110)}, # {"bbox": (35, 85, 136, 110)},
...@@ -363,46 +375,46 @@ def test_get_bbox_in_boundry(boxes: list, boundry: tuple, target_boxs: list) -> ...@@ -363,46 +375,46 @@ def test_get_bbox_in_boundry(boxes: list, boundry: tuple, target_boxs: list) ->
# {"bbox": (144, 264, 188, 323)}, # {"bbox": (144, 264, 188, 323)},
# {"bbox": (62, 37, 126, 64)}], (228, 193, 347, 225), # {"bbox": (62, 37, 126, 64)}], (228, 193, 347, 225),
# [{"bbox": (168, 120, 263, 159)}, {"bbox": (231, 61, 279, 159)}]), # y:方向最近的有两个,x: 两个均有重合 Error # [{"bbox": (168, 120, 263, 159)}, {"bbox": (231, 61, 279, 159)}]), # y:方向最近的有两个,x: 两个均有重合 Error
([{"bbox": (35, 85, 136, 159)}, ([{'bbox': (35, 85, 136, 159)},
{"bbox": (168, 120, 263, 159)}, {'bbox': (168, 120, 263, 159)},
{"bbox": (231, 61, 279, 118)}, {'bbox': (231, 61, 279, 118)},
{"bbox": (228, 193, 347, 225)}, {'bbox': (228, 193, 347, 225)},
{"bbox": (144, 264, 188, 323)}, {'bbox': (144, 264, 188, 323)},
{"bbox": (62, 37, 126, 64)}], (228, 193, 347, 225), {'bbox': (62, 37, 126, 64)}], (228, 193, 347, 225),
{"bbox": (168, 120, 263, 159)},), # y:方向最近的有两个,x:只有一个有重合 {'bbox': (168, 120, 263, 159)},), # y:方向最近的有两个,x:只有一个有重合
([{"bbox": (239, 115, 379, 167)}, ([{'bbox': (239, 115, 379, 167)},
{"bbox": (33, 237, 104, 262)}, {'bbox': (33, 237, 104, 262)},
{"bbox": (124, 288, 168, 325)}, {'bbox': (124, 288, 168, 325)},
{"bbox": (242, 291, 379, 340)}, {'bbox': (242, 291, 379, 340)},
{"bbox": (55, 117, 121, 154)}, {'bbox': (55, 117, 121, 154)},
{"bbox": (266, 183, 384, 217)}, ], (124, 288, 168, 325), {'bbox': (55, 117, 121, 154)}), {'bbox': (266, 183, 384, 217)}, ], (124, 288, 168, 325), {'bbox': (55, 117, 121, 154)}),
([{"bbox": (239, 115, 379, 167)}, ([{'bbox': (239, 115, 379, 167)},
{"bbox": (33, 237, 104, 262)}, {'bbox': (33, 237, 104, 262)},
{"bbox": (124, 288, 168, 325)}, {'bbox': (124, 288, 168, 325)},
{"bbox": (242, 291, 379, 340)}, {'bbox': (242, 291, 379, 340)},
{"bbox": (55, 117, 119, 154)}, {'bbox': (55, 117, 119, 154)},
{"bbox": (266, 183, 384, 217)}, ], (124, 288, 168, 325), None), # x没有重合 {'bbox': (266, 183, 384, 217)}, ], (124, 288, 168, 325), None), # x没有重合
([{"bbox": (80, 90, 249, 200)}, ([{'bbox': (80, 90, 249, 200)},
{"bbox": (183, 100, 240, 155)}, ], (183, 100, 240, 155), None), # 包含 {'bbox': (183, 100, 240, 155)}, ], (183, 100, 240, 155), None), # 包含
]) ])
def test_find_top_nearest_text_bbox(pymu_blocks: list, obj_box: tuple, target_boxs: dict) -> None: def test_find_top_nearest_text_bbox(pymu_blocks: list, obj_box: tuple, target_boxs: dict) -> None:
assert target_boxs == find_top_nearest_text_bbox(pymu_blocks, obj_box) assert target_boxs == find_top_nearest_text_bbox(pymu_blocks, obj_box)
# 寻找下方距离自己最近的box, x方向有重合,y方向最近的 # 寻找下方距离自己最近的box, x方向有重合,y方向最近的
@pytest.mark.parametrize("pymu_blocks, obj_box, target_boxs", [ @pytest.mark.parametrize('pymu_blocks, obj_box, target_boxs', [
([{"bbox": (165, 96, 300, 114)}, ([{'bbox': (165, 96, 300, 114)},
{"bbox": (11, 157, 139, 201)}, {'bbox': (11, 157, 139, 201)},
{"bbox": (124, 208, 265, 262)}, {'bbox': (124, 208, 265, 262)},
{"bbox": (124, 283, 248, 306)}, {'bbox': (124, 283, 248, 306)},
{"bbox": (39, 267, 84, 301)}, {'bbox': (39, 267, 84, 301)},
{"bbox": (36, 89, 114, 145)}, ], (165, 96, 300, 114), {"bbox": (124, 208, 265, 262)}), {'bbox': (36, 89, 114, 145)}, ], (165, 96, 300, 114), {'bbox': (124, 208, 265, 262)}),
([{"bbox": (187, 37, 303, 49)}, ([{'bbox': (187, 37, 303, 49)},
{"bbox": (2, 227, 90, 283)}, {'bbox': (2, 227, 90, 283)},
{"bbox": (158, 174, 200, 212)}, {'bbox': (158, 174, 200, 212)},
{"bbox": (259, 174, 324, 228)}, {'bbox': (259, 174, 324, 228)},
{"bbox": (205, 61, 316, 97)}, {'bbox': (205, 61, 316, 97)},
{"bbox": (295, 248, 374, 287)}, ], (205, 61, 316, 97), {"bbox": (259, 174, 324, 228)}), # y有两个最近的, x只有一个重合 {'bbox': (295, 248, 374, 287)}, ], (205, 61, 316, 97), {'bbox': (259, 174, 324, 228)}), # y有两个最近的, x只有一个重合
# ([{"bbox": (187, 37, 303, 49)}, # ([{"bbox": (187, 37, 303, 49)},
# {"bbox": (2, 227, 90, 283)}, # {"bbox": (2, 227, 90, 283)},
# {"bbox": (259, 174, 324, 228)}, # {"bbox": (259, 174, 324, 228)},
...@@ -410,31 +422,31 @@ def test_find_top_nearest_text_bbox(pymu_blocks: list, obj_box: tuple, target_bo ...@@ -410,31 +422,31 @@ def test_find_top_nearest_text_bbox(pymu_blocks: list, obj_box: tuple, target_bo
# {"bbox": (295, 248, 374, 287)}, # {"bbox": (295, 248, 374, 287)},
# {"bbox": (158, 174, 209, 212)}, ], (205, 61, 316, 97), # {"bbox": (158, 174, 209, 212)}, ], (205, 61, 316, 97),
# [{"bbox": (259, 174, 324, 228)}, {"bbox": (158, 174, 209, 212)}]), # x有重合,y有两个最近的 Error # [{"bbox": (259, 174, 324, 228)}, {"bbox": (158, 174, 209, 212)}]), # x有重合,y有两个最近的 Error
([{"bbox": (287, 132, 398, 191)}, ([{'bbox': (287, 132, 398, 191)},
{"bbox": (44, 141, 163, 188)}, {'bbox': (44, 141, 163, 188)},
{"bbox": (132, 191, 240, 241)}, {'bbox': (132, 191, 240, 241)},
{"bbox": (81, 25, 142, 67)}, {'bbox': (81, 25, 142, 67)},
{"bbox": (74, 297, 116, 314)}, {'bbox': (74, 297, 116, 314)},
{"bbox": (77, 84, 224, 107)}, ], (287, 132, 398, 191), None), # x没有重合 {'bbox': (77, 84, 224, 107)}, ], (287, 132, 398, 191), None), # x没有重合
([{"bbox": (80, 90, 249, 200)}, ([{'bbox': (80, 90, 249, 200)},
{"bbox": (183, 100, 240, 155)}, ], (183, 100, 240, 155), None), # 包含 {'bbox': (183, 100, 240, 155)}, ], (183, 100, 240, 155), None), # 包含
]) ])
def test_find_bottom_nearest_text_bbox(pymu_blocks: list, obj_box: tuple, target_boxs: dict) -> None: def test_find_bottom_nearest_text_bbox(pymu_blocks: list, obj_box: tuple, target_boxs: dict) -> None:
assert target_boxs == find_bottom_nearest_text_bbox(pymu_blocks, obj_box) assert target_boxs == find_bottom_nearest_text_bbox(pymu_blocks, obj_box)
# 寻找左侧距离自己最近的box, y方向有重叠,x方向最近 # 寻找左侧距离自己最近的box, y方向有重叠,x方向最近
@pytest.mark.parametrize("pymu_blocks, obj_box, target_boxs", [ @pytest.mark.parametrize('pymu_blocks, obj_box, target_boxs', [
([{"bbox": (80, 90, 249, 200)}, {"bbox": (183, 100, 240, 155)}], (183, 100, 240, 155), None), # 包含 ([{'bbox': (80, 90, 249, 200)}, {'bbox': (183, 100, 240, 155)}], (183, 100, 240, 155), None), # 包含
([{"bbox": (28, 90, 77, 126)}, {"bbox": (35, 84, 84, 120)}], (35, 84, 84, 120), None), # y:重叠,x:重叠大于2 ([{'bbox': (28, 90, 77, 126)}, {'bbox': (35, 84, 84, 120)}], (35, 84, 84, 120), None), # y:重叠,x:重叠大于2
([{"bbox": (28, 90, 77, 126)}, {"bbox": (75, 84, 134, 120)}], (75, 84, 134, 120), {"bbox": (28, 90, 77, 126)}), ([{'bbox': (28, 90, 77, 126)}, {'bbox': (75, 84, 134, 120)}], (75, 84, 134, 120), {'bbox': (28, 90, 77, 126)}),
# y:重叠,x:重叠小于等于2 # y:重叠,x:重叠小于等于2
([{"bbox": (239, 115, 379, 167)}, ([{'bbox': (239, 115, 379, 167)},
{"bbox": (33, 237, 104, 262)}, {'bbox': (33, 237, 104, 262)},
{"bbox": (124, 288, 168, 325)}, {'bbox': (124, 288, 168, 325)},
{"bbox": (242, 291, 379, 340)}, {'bbox': (242, 291, 379, 340)},
{"bbox": (55, 113, 161, 154)}, {'bbox': (55, 113, 161, 154)},
{"bbox": (266, 123, 384, 217)}], (266, 123, 384, 217), {"bbox": (55, 113, 161, 154)}), # y重叠,x left {'bbox': (266, 123, 384, 217)}], (266, 123, 384, 217), {'bbox': (55, 113, 161, 154)}), # y重叠,x left
# ([{"bbox": (136, 219, 268, 240)}, # ([{"bbox": (136, 219, 268, 240)},
# {"bbox": (169, 115, 268, 181)}, # {"bbox": (169, 115, 268, 181)},
# {"bbox": (33, 237, 104, 262)}, # {"bbox": (33, 237, 104, 262)},
...@@ -448,17 +460,17 @@ def test_find_left_nearest_text_bbox(pymu_blocks: list, obj_box: tuple, target_b ...@@ -448,17 +460,17 @@ def test_find_left_nearest_text_bbox(pymu_blocks: list, obj_box: tuple, target_b
# 寻找右侧距离自己最近的box, y方向有重叠,x方向最近 # 寻找右侧距离自己最近的box, y方向有重叠,x方向最近
@pytest.mark.parametrize("pymu_blocks, obj_box, target_boxs", [ @pytest.mark.parametrize('pymu_blocks, obj_box, target_boxs', [
([{"bbox": (80, 90, 249, 200)}, {"bbox": (183, 100, 240, 155)}], (183, 100, 240, 155), None), # 包含 ([{'bbox': (80, 90, 249, 200)}, {'bbox': (183, 100, 240, 155)}], (183, 100, 240, 155), None), # 包含
([{"bbox": (28, 90, 77, 126)}, {"bbox": (35, 84, 84, 120)}], (28, 90, 77, 126), None), # y:重叠,x:重叠大于2 ([{'bbox': (28, 90, 77, 126)}, {'bbox': (35, 84, 84, 120)}], (28, 90, 77, 126), None), # y:重叠,x:重叠大于2
([{"bbox": (28, 90, 77, 126)}, {"bbox": (75, 84, 134, 120)}], (28, 90, 77, 126), {"bbox": (75, 84, 134, 120)}), ([{'bbox': (28, 90, 77, 126)}, {'bbox': (75, 84, 134, 120)}], (28, 90, 77, 126), {'bbox': (75, 84, 134, 120)}),
# y:重叠,x:重叠小于等于2 # y:重叠,x:重叠小于等于2
([{"bbox": (239, 115, 379, 167)}, ([{'bbox': (239, 115, 379, 167)},
{"bbox": (33, 237, 104, 262)}, {'bbox': (33, 237, 104, 262)},
{"bbox": (124, 288, 168, 325)}, {'bbox': (124, 288, 168, 325)},
{"bbox": (242, 291, 379, 340)}, {'bbox': (242, 291, 379, 340)},
{"bbox": (55, 113, 161, 154)}, {'bbox': (55, 113, 161, 154)},
{"bbox": (266, 123, 384, 217)}], (55, 113, 161, 154), {"bbox": (239, 115, 379, 167)}), # y重叠,x right {'bbox': (266, 123, 384, 217)}], (55, 113, 161, 154), {'bbox': (239, 115, 379, 167)}), # y重叠,x right
# ([{"bbox": (169, 115, 298, 181)}, # ([{"bbox": (169, 115, 298, 181)},
# {"bbox": (169, 219, 268, 240)}, # {"bbox": (169, 219, 268, 240)},
# {"bbox": (33, 177, 104, 262)}, # {"bbox": (33, 177, 104, 262)},
...@@ -472,7 +484,7 @@ def test_find_right_nearest_text_bbox(pymu_blocks: list, obj_box: tuple, target_ ...@@ -472,7 +484,7 @@ def test_find_right_nearest_text_bbox(pymu_blocks: list, obj_box: tuple, target_
# 判断两个矩形框的相对位置关系 (left, right, bottom, top) # 判断两个矩形框的相对位置关系 (left, right, bottom, top)
@pytest.mark.parametrize("box1, box2, target_box", [ @pytest.mark.parametrize('box1, box2, target_box', [
# (None, None, "Error"), # Error # (None, None, "Error"), # Error
((80, 90, 249, 200), (183, 100, 240, 155), (False, False, False, False)), # 包含 ((80, 90, 249, 200), (183, 100, 240, 155), (False, False, False, False)), # 包含
# ((124, 81, 222, 173), (60, 221, 123, 358), (False, True, False, True)), # 分离,右上 Error # ((124, 81, 222, 173), (60, 221, 123, 358), (False, True, False, True)), # 分离,右上 Error
...@@ -494,7 +506,7 @@ def test_bbox_relative_pos(box1: tuple, box2: tuple, target_box: tuple) -> None: ...@@ -494,7 +506,7 @@ def test_bbox_relative_pos(box1: tuple, box2: tuple, target_box: tuple) -> None:
""" """
@pytest.mark.parametrize("box1, box2, target_num", [ @pytest.mark.parametrize('box1, box2, target_num', [
# (None, None, "Error"), # Error # (None, None, "Error"), # Error
((80, 90, 249, 200), (183, 100, 240, 155), 0.0), # 包含 ((80, 90, 249, 200), (183, 100, 240, 155), 0.0), # 包含
((142, 109, 238, 164), (134, 211, 224, 270), 47.0), # 分离,上 ((142, 109, 238, 164), (134, 211, 224, 270), 47.0), # 分离,上
...@@ -514,17 +526,17 @@ def test_bbox_relative_pos(box1: tuple, box2: tuple, target_box: tuple) -> None: ...@@ -514,17 +526,17 @@ def test_bbox_relative_pos(box1: tuple, box2: tuple, target_box: tuple) -> None:
def test_bbox_distance(box1: tuple, box2: tuple, target_num: float) -> None: def test_bbox_distance(box1: tuple, box2: tuple, target_num: float) -> None:
assert target_num - bbox_distance(box1, box2) < 1 assert target_num - bbox_distance(box1, box2) < 1
@pytest.mark.skip(reason="skip")
@pytest.mark.skip(reason='skip')
# 根据bucket_name获取s3配置ak,sk,endpoint # 根据bucket_name获取s3配置ak,sk,endpoint
def test_get_s3_config() -> None: def test_get_s3_config() -> None:
bucket_name = os.getenv('bucket_name') bucket_name = os.getenv('bucket_name')
target_data = os.getenv('target_data') target_data = os.getenv('target_data')
assert convert_string_to_list(target_data) == list(get_s3_config(bucket_name)) assert convert_string_to_list(target_data) == list(get_s3_config(bucket_name))
def convert_string_to_list(s):
def convert_string_to_list(s): cleaned_s = s.strip("'")
cleaned_s = s.strip("'") items = cleaned_s.split(',')
items = cleaned_s.split(',') cleaned_items = [item.strip() for item in items]
cleaned_items = [item.strip() for item in items] return cleaned_items
return cleaned_items
\ No newline at end of file
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