yomitoku 0.5.3__tar.gz → 0.7.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {yomitoku-0.5.3 → yomitoku-0.7.0}/.github/workflows/lint-and-test.yml +3 -1
- {yomitoku-0.5.3 → yomitoku-0.7.0}/.gitignore +3 -1
- yomitoku-0.7.0/.python-version +1 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/PKG-INFO +21 -9
- {yomitoku-0.5.3 → yomitoku-0.7.0}/README.md +14 -6
- {yomitoku-0.5.3 → yomitoku-0.7.0}/README_EN.md +8 -2
- yomitoku-0.7.0/configs/table_structure_recognitizer.yaml +67 -0
- yomitoku-0.7.0/configs/text_recognizer.yaml +32 -0
- yomitoku-0.7.0/demo/setting_document_anaysis.py +6 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/demo/simple_document_analysis.py +4 -7
- {yomitoku-0.5.3 → yomitoku-0.7.0}/demo/simple_layout.py +1 -1
- {yomitoku-0.5.3 → yomitoku-0.7.0}/demo/simple_ocr.py +1 -1
- {yomitoku-0.5.3 → yomitoku-0.7.0}/docs/installation.en.md +12 -1
- {yomitoku-0.5.3 → yomitoku-0.7.0}/docs/installation.ja.md +11 -1
- {yomitoku-0.5.3 → yomitoku-0.7.0}/docs/usage.en.md +25 -78
- {yomitoku-0.5.3 → yomitoku-0.7.0}/docs/usage.ja.md +27 -73
- {yomitoku-0.5.3 → yomitoku-0.7.0}/mkdocs.yml +1 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/pyproject.toml +13 -4
- {yomitoku-0.5.3 → yomitoku-0.7.0}/scripts/register_hugging_face_hub.py +1 -1
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/cli/main.py +47 -1
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/configs/__init__.py +2 -0
- yomitoku-0.7.0/src/yomitoku/configs/cfg_text_recognizer_parseq_small.py +51 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/document_analyzer.py +229 -26
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/export/export_csv.py +39 -2
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/export/export_html.py +2 -1
- yomitoku-0.7.0/src/yomitoku/export/export_json.py +72 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/export/export_markdown.py +2 -1
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/layout_analyzer.py +1 -5
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/layout_parser.py +58 -4
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/models/layers/rtdetr_backbone.py +5 -15
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/models/layers/rtdetr_hybrid_encoder.py +6 -18
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/models/layers/rtdetrv2_decoder.py +17 -42
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/models/parseq.py +9 -9
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/ocr.py +24 -27
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/postprocessor/rtdetr_postprocessor.py +4 -13
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/table_structure_recognizer.py +79 -9
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/text_detector.py +57 -7
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/text_recognizer.py +80 -16
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/utils/misc.py +20 -13
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/utils/visualizer.py +5 -5
- yomitoku-0.7.0/tests/data/invalid.pdf +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/test_cli.py +16 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/test_document_analyzer.py +6 -6
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/test_export.py +103 -1
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/test_layout_analyzer.py +0 -9
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/test_ocr.py +0 -9
- {yomitoku-0.5.3 → yomitoku-0.7.0}/uv.lock +383 -336
- yomitoku-0.5.3/.python-version +0 -1
- yomitoku-0.5.3/configs/table_structure_recognitizer.yaml +0 -2
- yomitoku-0.5.3/configs/text_recognizer.yaml +0 -14
- yomitoku-0.5.3/demo/setting_document_anaysis.py +0 -23
- yomitoku-0.5.3/src/yomitoku/export/export_json.py +0 -34
- {yomitoku-0.5.3 → yomitoku-0.7.0}/.github/release-drafter.yml +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/.github/workflows/build-and-publish-docs.yaml +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/.github/workflows/build-and-publish.yml +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/.github/workflows/create-release.yml +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/.pre-commit-config.yaml +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/configs/layout_parser_rtdetrv2.yaml +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/configs/text_detector.yaml +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/demo/sample.pdf +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/demo/text_detector.yaml +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/dockerfile +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/docs/assets/logo.svg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/docs/index.en.md +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/docs/index.ja.md +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/gallery.md +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/pytest.ini +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/__init__.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/base.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/cli/__init__.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/configs/cfg_layout_parser_rtdtrv2.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/configs/cfg_table_structure_recognizer_rtdtrv2.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/configs/cfg_text_detector_dbnet.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/configs/cfg_text_recognizer_parseq.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/constants.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/data/__init__.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/data/dataset.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/data/functions.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/export/__init__.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/models/__init__.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/models/dbnet_plus.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/models/layers/__init__.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/models/layers/activate.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/models/layers/dbnet_feature_attention.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/models/layers/parseq_transformer.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/models/rtdetr.py +0 -0
- /yomitoku-0.5.3/src/yomitoku/utils/__init__.py → /yomitoku-0.7.0/src/yomitoku/onnx/.gitkeep +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/postprocessor/__init__.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/postprocessor/dbnet_postporcessor.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/postprocessor/parseq_tokenizer.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/reading_order.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/resource/MPLUS1p-Medium.ttf +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/resource/charset.txt +0 -0
- /yomitoku-0.5.3/tests/data/invalid.jpg → /yomitoku-0.7.0/src/yomitoku/utils/__init__.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/utils/graph.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/src/yomitoku/utils/logger.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/in/demo.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/in/gallery1.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/in/gallery2.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/in/gallery3.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/in/gallery4.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/in/gallery5.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/in/gallery6.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/logo/horizontal.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/demo_html.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_demo_p1_figure_0.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_gallery1_p1_figure_0.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_gallery1_p1_figure_1.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_gallery1_p1_figure_10.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_gallery1_p1_figure_2.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_gallery1_p1_figure_3.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_gallery1_p1_figure_4.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_gallery1_p1_figure_5.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_gallery1_p1_figure_6.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_gallery1_p1_figure_7.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_gallery1_p1_figure_8.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_gallery1_p1_figure_9.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_gallery3_p1_figure_0.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_gallery3_p1_figure_1.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_gallery5_p1_figure_0.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_gallery5_p1_figure_1.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_gallery6_p1_figure_0.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/figures/in_gallery6_p1_figure_1.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_demo_p1.html +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_demo_p1.md +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_demo_p1_layout.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_demo_p1_ocr.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery1_p1.html +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery1_p1.md +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery1_p1_layout.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery1_p1_ocr.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery2_p1.html +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery2_p1.md +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery2_p1_layout.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery2_p1_ocr.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery3_p1.html +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery3_p1.md +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery3_p1_layout.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery3_p1_ocr.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery4_p1.html +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery4_p1.md +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery4_p1_layout.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery4_p1_ocr.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery5_p1.html +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery5_p1.md +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery5_p1_layout.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery5_p1_ocr.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery6_p1.html +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery6_p1.md +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery6_p1_layout.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/static/out/in_gallery6_p1_ocr.jpg +0 -0
- /yomitoku-0.5.3/tests/data/invalid.pdf → /yomitoku-0.7.0/tests/data/invalid.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/data/rgba.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/data/small.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/data/subdir/test.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/data/test.bmp +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/data/test.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/data/test.pdf +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/data/test.png +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/data/test.tiff +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/data/test.txt +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/data/test_gray.jpg +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/test_base.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/test_data.py +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/yaml/layout_parser.yaml +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/yaml/table_structure_recognizer.yaml +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/yaml/text_detector.yaml +0 -0
- {yomitoku-0.5.3 → yomitoku-0.7.0}/tests/yaml/text_recognizer.yaml +0 -0
@@ -30,6 +30,8 @@ jobs:
|
|
30
30
|
enable-cache: true
|
31
31
|
- name: pin python version
|
32
32
|
run: uv python pin 3.12
|
33
|
+
- name: Update apt
|
34
|
+
run: sudo apt update
|
33
35
|
- name: Install dependencies
|
34
36
|
run: sudo apt install -y libopencv-dev poppler-utils
|
35
37
|
- name: Install tox-uv
|
@@ -37,4 +39,4 @@ jobs:
|
|
37
39
|
- name: Run linter
|
38
40
|
run: tox -e lint
|
39
41
|
- name: Run tests
|
40
|
-
run:
|
42
|
+
run: tox -p -e py310,py311,py312
|
@@ -0,0 +1 @@
|
|
1
|
+
3.10
|
@@ -1,14 +1,16 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: yomitoku
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.7.0
|
4
4
|
Summary: Yomitoku is an AI-powered document image analysis package designed specifically for the Japanese language.
|
5
5
|
Author-email: Kotaro Kinoshita <kotaro.kinoshita@mlism.com>
|
6
6
|
License: CC BY-NC-SA 4.0
|
7
7
|
Keywords: Deep Learning,Japanese,OCR
|
8
|
-
Requires-Python: <3.13,>=3.
|
8
|
+
Requires-Python: <3.13,>=3.10
|
9
9
|
Requires-Dist: huggingface-hub>=0.26.1
|
10
10
|
Requires-Dist: lxml>=5.3.0
|
11
11
|
Requires-Dist: omegaconf>=2.3.0
|
12
|
+
Requires-Dist: onnx>=1.17.0
|
13
|
+
Requires-Dist: onnxruntime>=1.20.1
|
12
14
|
Requires-Dist: opencv-python>=4.10.0.84
|
13
15
|
Requires-Dist: pyclipper>=1.3.0.post6
|
14
16
|
Requires-Dist: pydantic>=2.9.2
|
@@ -17,13 +19,15 @@ Requires-Dist: shapely>=2.0.6
|
|
17
19
|
Requires-Dist: timm>=1.0.11
|
18
20
|
Requires-Dist: torch>=2.5.0
|
19
21
|
Requires-Dist: torchvision>=0.20.0
|
22
|
+
Provides-Extra: gpu
|
23
|
+
Requires-Dist: onnxruntime-gpu>=1.20.1; extra == 'gpu'
|
20
24
|
Description-Content-Type: text/markdown
|
21
25
|
|
22
26
|
日本語版 | [English](README_EN.md)
|
23
27
|
|
24
28
|
<img src="static/logo/horizontal.png" width="800px">
|
25
29
|
|
26
|
-

|
27
31
|

|
28
32
|

|
29
33
|

|
@@ -69,23 +73,30 @@ Markdown でエクスポートした結果は関してはリポジトリ内の[s
|
|
69
73
|
pip install yomitoku
|
70
74
|
```
|
71
75
|
|
72
|
-
|
73
|
-
|
76
|
+
onnxruntimeの実行にGPUを使用する場合
|
77
|
+
```
|
78
|
+
pip install yomitoku[gpu]
|
79
|
+
```
|
80
|
+
|
81
|
+
- pytorch はご自身の CUDA のバージョンにあったものをインストールしてください。デフォルトでは CUDA12.4 以上に対応したものがインストールされます。
|
82
|
+
- pytorch は 2.5 以上のバージョンに対応しています。その関係で CUDA11.8 以上のバージョンが必要になります。対応できない場合は、リポジトリ内の Dockerfile を利用してください。
|
74
83
|
|
75
84
|
## 🚀 実行方法
|
76
85
|
|
77
86
|
```
|
78
|
-
yomitoku ${path_data} -f md -o results -v --figure
|
87
|
+
yomitoku ${path_data} -f md -o results -v --figure --lite
|
79
88
|
```
|
80
89
|
|
81
90
|
- `${path_data}` 解析対象の画像が含まれたディレクトリか画像ファイルのパスを直接して指定してください。ディレクトリを対象とした場合はディレクトリのサブディレクトリ内の画像も含めて処理を実行します。
|
82
91
|
- `-f`, `--format` 出力形式のファイルフォーマットを指定します。(json, csv, html, md をサポート)
|
83
92
|
- `-o`, `--outdir` 出力先のディレクトリ名を指定します。存在しない場合は新規で作成されます。
|
84
93
|
- `-v`, `--vis` を指定すると解析結果を可視化した画像を出力します。
|
94
|
+
- `-l`, `--lite` を指定すると軽量モデルで推論を実行します。通常より高速に推論できますが、若干、精度が低下する可能性があります。
|
85
95
|
- `-d`, `--device` モデルを実行するためのデバイスを指定します。gpu が利用できない場合は cpu で推論が実行されます。(デフォルト: cuda)
|
86
96
|
- `--ignore_line_break` 画像の改行位置を無視して、段落内の文章を連結して返します。(デフォルト:画像通りの改行位置位置で改行します。)
|
87
97
|
- `--figure_letter` 検出した図表に含まれる文字も出力ファイルにエクスポートします。
|
88
|
-
- `--figure` 検出した図、画像を出力ファイルにエクスポートします。
|
98
|
+
- `--figure` 検出した図、画像を出力ファイルにエクスポートします。
|
99
|
+
- `--encoding` エクスポートする出力ファイルの文字エンコーディングを指定します。サポートされていない文字コードが含まれる場合は、その文字を無視します。(utf-8, utf-8-sig, shift-jis, enc-jp, cp932)
|
89
100
|
|
90
101
|
その他のオプションに関しては、ヘルプを参照
|
91
102
|
|
@@ -94,6 +105,7 @@ yomitoku --help
|
|
94
105
|
```
|
95
106
|
|
96
107
|
**NOTE**
|
108
|
+
|
97
109
|
- GPU での実行を推奨します。CPU を用いての推論向けに最適化されておらず、処理時間が長くなります。
|
98
110
|
- 活字のみ識別をサポートしております。手書き文字に関しては、読み取れる場合もありますが、公式にはサポートしておりません。
|
99
111
|
- Yomitoku は文書 OCR 向けに最適化されており、情景 OCR(看板など紙以外にプリントされた文字の読み取り)向けには最適化されていません。
|
@@ -107,6 +119,6 @@ yomitoku --help
|
|
107
119
|
|
108
120
|
本リポジトリ内に格納されているソースコードおよび本プロジェクトに関連する HuggingFaceHub 上のモデルの重みファイルのライセンスは CC BY-NC-SA 4.0 に従います。
|
109
121
|
非商用での個人利用、研究目的での利用はご自由にお使いください。
|
110
|
-
|
122
|
+
商用目的での利用に関しては、別途、商用ライセンスを提供しますので、https://www.mlism.com/ にお問い合わせください。
|
111
123
|
|
112
124
|
YomiToku © 2024 by Kotaro Kinoshita is licensed under CC BY-NC-SA 4.0. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/4.0/
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<img src="static/logo/horizontal.png" width="800px">
|
4
4
|
|
5
|
-

|
6
6
|

|
7
7
|

|
8
8
|

|
@@ -48,23 +48,30 @@ Markdown でエクスポートした結果は関してはリポジトリ内の[s
|
|
48
48
|
pip install yomitoku
|
49
49
|
```
|
50
50
|
|
51
|
-
|
52
|
-
|
51
|
+
onnxruntimeの実行にGPUを使用する場合
|
52
|
+
```
|
53
|
+
pip install yomitoku[gpu]
|
54
|
+
```
|
55
|
+
|
56
|
+
- pytorch はご自身の CUDA のバージョンにあったものをインストールしてください。デフォルトでは CUDA12.4 以上に対応したものがインストールされます。
|
57
|
+
- pytorch は 2.5 以上のバージョンに対応しています。その関係で CUDA11.8 以上のバージョンが必要になります。対応できない場合は、リポジトリ内の Dockerfile を利用してください。
|
53
58
|
|
54
59
|
## 🚀 実行方法
|
55
60
|
|
56
61
|
```
|
57
|
-
yomitoku ${path_data} -f md -o results -v --figure
|
62
|
+
yomitoku ${path_data} -f md -o results -v --figure --lite
|
58
63
|
```
|
59
64
|
|
60
65
|
- `${path_data}` 解析対象の画像が含まれたディレクトリか画像ファイルのパスを直接して指定してください。ディレクトリを対象とした場合はディレクトリのサブディレクトリ内の画像も含めて処理を実行します。
|
61
66
|
- `-f`, `--format` 出力形式のファイルフォーマットを指定します。(json, csv, html, md をサポート)
|
62
67
|
- `-o`, `--outdir` 出力先のディレクトリ名を指定します。存在しない場合は新規で作成されます。
|
63
68
|
- `-v`, `--vis` を指定すると解析結果を可視化した画像を出力します。
|
69
|
+
- `-l`, `--lite` を指定すると軽量モデルで推論を実行します。通常より高速に推論できますが、若干、精度が低下する可能性があります。
|
64
70
|
- `-d`, `--device` モデルを実行するためのデバイスを指定します。gpu が利用できない場合は cpu で推論が実行されます。(デフォルト: cuda)
|
65
71
|
- `--ignore_line_break` 画像の改行位置を無視して、段落内の文章を連結して返します。(デフォルト:画像通りの改行位置位置で改行します。)
|
66
72
|
- `--figure_letter` 検出した図表に含まれる文字も出力ファイルにエクスポートします。
|
67
|
-
- `--figure` 検出した図、画像を出力ファイルにエクスポートします。
|
73
|
+
- `--figure` 検出した図、画像を出力ファイルにエクスポートします。
|
74
|
+
- `--encoding` エクスポートする出力ファイルの文字エンコーディングを指定します。サポートされていない文字コードが含まれる場合は、その文字を無視します。(utf-8, utf-8-sig, shift-jis, enc-jp, cp932)
|
68
75
|
|
69
76
|
その他のオプションに関しては、ヘルプを参照
|
70
77
|
|
@@ -73,6 +80,7 @@ yomitoku --help
|
|
73
80
|
```
|
74
81
|
|
75
82
|
**NOTE**
|
83
|
+
|
76
84
|
- GPU での実行を推奨します。CPU を用いての推論向けに最適化されておらず、処理時間が長くなります。
|
77
85
|
- 活字のみ識別をサポートしております。手書き文字に関しては、読み取れる場合もありますが、公式にはサポートしておりません。
|
78
86
|
- Yomitoku は文書 OCR 向けに最適化されており、情景 OCR(看板など紙以外にプリントされた文字の読み取り)向けには最適化されていません。
|
@@ -86,6 +94,6 @@ yomitoku --help
|
|
86
94
|
|
87
95
|
本リポジトリ内に格納されているソースコードおよび本プロジェクトに関連する HuggingFaceHub 上のモデルの重みファイルのライセンスは CC BY-NC-SA 4.0 に従います。
|
88
96
|
非商用での個人利用、研究目的での利用はご自由にお使いください。
|
89
|
-
|
97
|
+
商用目的での利用に関しては、別途、商用ライセンスを提供しますので、https://www.mlism.com/ にお問い合わせください。
|
90
98
|
|
91
99
|
YomiToku © 2024 by Kotaro Kinoshita is licensed under CC BY-NC-SA 4.0. To view a copy of this license, visit https://creativecommons.org/licenses/by-nc-sa/4.0/
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<img src="static/logo/horizontal.png" width="800px">
|
4
4
|
|
5
|
-

|
6
6
|

|
7
7
|

|
8
8
|

|
@@ -49,6 +49,10 @@ Source of the image: Created by processing content from “Reiwa 6 Edition Infor
|
|
49
49
|
pip install yomitoku
|
50
50
|
```
|
51
51
|
|
52
|
+
Using GPU with onnxruntime
|
53
|
+
```
|
54
|
+
pip install yomitoku[gpu]
|
55
|
+
```
|
52
56
|
|
53
57
|
- Please install the version of PyTorch that matches your CUDA version. By default, a version compatible with CUDA 12.4 or higher will be installed.
|
54
58
|
- PyTorch versions 2.5 and above are supported. As a result, CUDA version 11.8 or higher is required. If this is not feasible, please use the Dockerfile provided in the repository.
|
@@ -63,10 +67,12 @@ yomitoku ${path_data} -f md -o results -v --figure
|
|
63
67
|
- `-f`, `--format`: Specify the output file format. Supported formats are json, csv, html, and md.
|
64
68
|
- `-o`, `--outdir`: Specify the name of the output directory. If it does not exist, it will be created.
|
65
69
|
- `-v`, `--vis`: If specified, outputs visualized images of the analysis results.
|
70
|
+
- `-l`, `--lite`: inference is performed using a lightweight model. This enables fast inference even on a CPU.
|
66
71
|
- `-d`, `--device`: Specify the device for running the model. If a GPU is unavailable, inference will be executed on the CPU. (Default: cuda)
|
67
72
|
- `--ignore_line_break`: Ignores line breaks in the image and concatenates sentences within a paragraph. (Default: respects line breaks as they appear in the image.)
|
68
73
|
- `--figure_letter`: Exports characters contained within detected figures and tables to the output file.
|
69
|
-
- `--figure`: Exports detected figures and images to the output file
|
74
|
+
- `--figure`: Exports detected figures and images to the output file
|
75
|
+
- `--encoding` Specifies the character encoding for the output file to be exported. If unsupported characters are included, they will be ignored. (utf-8, utf-8-sig, shift-jis, enc-jp, cp932)
|
70
76
|
|
71
77
|
|
72
78
|
For other options, please refer to the help documentation.
|
@@ -0,0 +1,67 @@
|
|
1
|
+
hf_hub_repo: KotaroKinoshita/yomitoku-table-structure-recognizer-rtdtrv2-open-beta
|
2
|
+
thresh_score: 0.4
|
3
|
+
data:
|
4
|
+
img_size:
|
5
|
+
- 640
|
6
|
+
- 640
|
7
|
+
PResNet:
|
8
|
+
depth: 50
|
9
|
+
variant: d
|
10
|
+
freeze_at: 0
|
11
|
+
return_idx:
|
12
|
+
- 1
|
13
|
+
- 2
|
14
|
+
- 3
|
15
|
+
num_stages: 4
|
16
|
+
freeze_norm: true
|
17
|
+
HybridEncoder:
|
18
|
+
in_channels:
|
19
|
+
- 512
|
20
|
+
- 1024
|
21
|
+
- 2048
|
22
|
+
feat_strides:
|
23
|
+
- 8
|
24
|
+
- 16
|
25
|
+
- 32
|
26
|
+
hidden_dim: 256
|
27
|
+
use_encoder_idx:
|
28
|
+
- 2
|
29
|
+
num_encoder_layers: 1
|
30
|
+
nhead: 8
|
31
|
+
dim_feedforward: 1024
|
32
|
+
dropout: 0.0
|
33
|
+
enc_act: gelu
|
34
|
+
expansion: 1.0
|
35
|
+
depth_mult: 1
|
36
|
+
act: silu
|
37
|
+
RTDETRTransformerv2:
|
38
|
+
num_classes: 3
|
39
|
+
feat_channels:
|
40
|
+
- 256
|
41
|
+
- 256
|
42
|
+
- 256
|
43
|
+
feat_strides:
|
44
|
+
- 8
|
45
|
+
- 16
|
46
|
+
- 32
|
47
|
+
hidden_dim: 256
|
48
|
+
num_levels: 3
|
49
|
+
num_layers: 6
|
50
|
+
num_queries: 300
|
51
|
+
num_denoising: 100
|
52
|
+
label_noise_ratio: 0.5
|
53
|
+
box_noise_scale: 1.0
|
54
|
+
eval_spatial_size:
|
55
|
+
- 640
|
56
|
+
- 640
|
57
|
+
eval_idx: -1
|
58
|
+
num_points:
|
59
|
+
- 4
|
60
|
+
- 4
|
61
|
+
- 4
|
62
|
+
cross_attn_method: default
|
63
|
+
query_select_method: default
|
64
|
+
category:
|
65
|
+
- row
|
66
|
+
- col
|
67
|
+
- span
|
@@ -0,0 +1,32 @@
|
|
1
|
+
hf_hub_repo: KotaroKinoshita/yomitoku-text-recognizer-parseq-open-beta
|
2
|
+
charset: /home/kinoshita/Projects/know-how/yomitoku/src/yomitoku/resource/charset.txt
|
3
|
+
num_tokens: 7312
|
4
|
+
max_label_length: 100
|
5
|
+
decode_ar: 1
|
6
|
+
refine_iters: 1
|
7
|
+
data:
|
8
|
+
num_workers: 4
|
9
|
+
batch_size: 128
|
10
|
+
img_size:
|
11
|
+
- 32
|
12
|
+
- 800
|
13
|
+
encoder:
|
14
|
+
patch_size:
|
15
|
+
- 8
|
16
|
+
- 8
|
17
|
+
num_heads: 8
|
18
|
+
embed_dim: 512
|
19
|
+
mlp_ratio: 4
|
20
|
+
depth: 12
|
21
|
+
decoder:
|
22
|
+
embed_dim: 512
|
23
|
+
num_heads: 8
|
24
|
+
mlp_ratio: 4
|
25
|
+
depth: 1
|
26
|
+
visualize:
|
27
|
+
font: /home/kinoshita/Projects/know-how/yomitoku/src/yomitoku/resource/MPLUS1p-Medium.ttf
|
28
|
+
color:
|
29
|
+
- 0
|
30
|
+
- 0
|
31
|
+
- 255
|
32
|
+
font_size: 18
|
@@ -4,17 +4,14 @@ from yomitoku import DocumentAnalyzer
|
|
4
4
|
from yomitoku.data.functions import load_pdf
|
5
5
|
|
6
6
|
if __name__ == "__main__":
|
7
|
-
PATH_IMGE = ""
|
8
|
-
|
9
|
-
analyzer = DocumentAnalyzer(configs=None, visualize=True, device="cuda")
|
7
|
+
PATH_IMGE = "demo/sample.pdf"
|
8
|
+
analyzer = DocumentAnalyzer(visualize=True, device="cuda")
|
10
9
|
# PDFファイルを読み込み
|
11
|
-
imgs = load_pdf(
|
10
|
+
imgs = load_pdf(PATH_IMGE)
|
12
11
|
for i, img in enumerate(imgs):
|
13
12
|
results, ocr_vis, layout_vis = analyzer(img)
|
14
|
-
|
15
13
|
# HTML形式で解析結果をエクスポート
|
16
|
-
results.to_html(f"output_{i}.html")
|
17
|
-
|
14
|
+
results.to_html(f"output_{i}.html", img=img)
|
18
15
|
# 可視化画像を保存
|
19
16
|
cv2.imwrite(f"output_ocr_{i}.jpg", ocr_vis)
|
20
17
|
cv2.imwrite(f"output_layout_{i}.jpg", layout_vis)
|
@@ -4,7 +4,7 @@ from yomitoku import LayoutAnalyzer
|
|
4
4
|
from yomitoku.data.functions import load_pdf
|
5
5
|
|
6
6
|
if __name__ == "__main__":
|
7
|
-
analyzer = LayoutAnalyzer(
|
7
|
+
analyzer = LayoutAnalyzer(visualize=True, device="cuda")
|
8
8
|
# PDFファイルを読み込み
|
9
9
|
imgs = load_pdf("demo/sample.pdf")
|
10
10
|
for i, img in enumerate(imgs):
|
@@ -4,7 +4,7 @@ from yomitoku import OCR
|
|
4
4
|
from yomitoku.data.functions import load_pdf
|
5
5
|
|
6
6
|
if __name__ == "__main__":
|
7
|
-
ocr = OCR(
|
7
|
+
ocr = OCR(visualize=True, device="cuda")
|
8
8
|
# PDFファイルを読み込み
|
9
9
|
imgs = load_pdf("demo/sample.pdf")
|
10
10
|
for i, img in enumerate(imgs):
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Installation
|
2
2
|
|
3
3
|
|
4
|
-
This package requires Python 3.
|
4
|
+
This package requires Python 3.10 or later and PyTorch 2.5 or later for execution. PyTorch must be installed according to your CUDA version. A GPU with more than 8GB of VRAM is recommended. While it can run on a CPU, please note that the processing is not currently optimized for CPUs, which may result in longer execution times.
|
5
5
|
|
6
6
|
## from PYPI
|
7
7
|
|
@@ -9,6 +9,12 @@ This package requires Python 3.9 or later and PyTorch 2.5 or later for execution
|
|
9
9
|
pip install yomitoku
|
10
10
|
```
|
11
11
|
|
12
|
+
Using GPU with onnxruntime
|
13
|
+
```bash
|
14
|
+
pip install yomitoku[gpu]
|
15
|
+
```
|
16
|
+
|
17
|
+
|
12
18
|
## using uv
|
13
19
|
This repository uses the package management tool [uv](https://docs.astral.sh/uv/). After installing uv, clone the repository and execute the following commands:
|
14
20
|
|
@@ -16,6 +22,11 @@ This repository uses the package management tool [uv](https://docs.astral.sh/uv/
|
|
16
22
|
uv sync
|
17
23
|
```
|
18
24
|
|
25
|
+
Using GPU with onnxruntime
|
26
|
+
```bash
|
27
|
+
uv sync --extra gpu
|
28
|
+
```
|
29
|
+
|
19
30
|
When using uv, you need to modify the following part of the pyproject.toml file to match your CUDA version. By default, PyTorch compatible with CUDA 12.4 will be downloaded.
|
20
31
|
|
21
32
|
```pyproject.tom
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# Installation
|
2
2
|
|
3
|
-
本パッケージは Python3.
|
3
|
+
本パッケージは Python3.10+, Pytorch が実行に必要です。Pytorch はご自身の環境に合わせて、インストールが必要です。計算機は GPU(> VRAM 8G)を推奨しています。CPU でも動作しますが、現在、CPU 向けに処理が最適化されておらず、実行に時間がかかりますのでご注意ください。
|
4
4
|
|
5
5
|
## PYPI からインストール
|
6
6
|
|
@@ -8,6 +8,11 @@
|
|
8
8
|
pip install yomitoku
|
9
9
|
```
|
10
10
|
|
11
|
+
onnxruntimeの実行にGPUを使用する場合
|
12
|
+
```bash
|
13
|
+
pip install yomitoku[gpu]
|
14
|
+
```
|
15
|
+
|
11
16
|
## uv でのインストール
|
12
17
|
|
13
18
|
本リポジトリはパッケージ管理ツールに [uv](https://docs.astral.sh/uv/) を使用しています。uv をインストール後、リポジトリをクローンし、以下のコマンドを実行してください
|
@@ -16,6 +21,11 @@ pip install yomitoku
|
|
16
21
|
uv sync
|
17
22
|
```
|
18
23
|
|
24
|
+
onnxruntimeの実行にGPUを使用する場合
|
25
|
+
```bash
|
26
|
+
uv sync --extra gpu
|
27
|
+
```
|
28
|
+
|
19
29
|
uvを利用する場合、`pyproject.toml`の以下の部分をご自身のcudaのバージョンに合わせて修正する必要があります。デフォルトではCUDA12.4に対応したpytorchがダウンロードされます。
|
20
30
|
|
21
31
|
```pyproject.tom
|
@@ -12,12 +12,16 @@ yomitoku ${path_data} -f md -o results -v
|
|
12
12
|
- `-f`, `--format`: Specify the output file format. Supported formats are json, csv, html, and md.
|
13
13
|
- `-o`, `--outdir`: Specify the name of the output directory. If it does not exist, it will be created.
|
14
14
|
- `-v`, `--vis`: If specified, outputs visualized images of the analysis results.
|
15
|
+
- `-l`, `--lite`: inference is performed using a lightweight model. This enables fast inference even on a CPU.
|
15
16
|
- `-d`, `--device`: Specify the device for running the model. If a GPU is unavailable, inference will be executed on the CPU. (Default: cuda)
|
16
17
|
- `--ignore_line_break`: Ignores line breaks in the image and concatenates sentences within a paragraph. (Default: respects line breaks as they appear in the image.)
|
17
18
|
- `--figure_letter`: Exports characters contained within detected figures and tables to the output file.
|
18
|
-
- `--figure`: Exports detected figures and images to the output file
|
19
|
+
- `--figure`: Exports detected figures and images to the output file
|
20
|
+
- `--encoding` Specifies the character encoding for the output file to be exported. If unsupported characters are included, they will be ignored. (utf-8, utf-8-sig, shift-jis, enc-jp, cp932)
|
21
|
+
|
19
22
|
|
20
23
|
**NOTE**
|
24
|
+
|
21
25
|
- It is recommended to run on a GPU. The system is not optimized for inference on CPUs, which may result in significantly longer processing times.
|
22
26
|
- Only printed text recognition is supported. While it may occasionally read handwritten text, official support is not provided.
|
23
27
|
- YomiToku is optimized for document OCR and is not designed for scene OCR (e.g., text printed on non-paper surfaces like signs).
|
@@ -29,24 +33,11 @@ yomitoku ${path_data} -f md -o results -v
|
|
29
33
|
|
30
34
|
The Document Analyzer performs OCR and layout analysis, integrating these results into a comprehensive analysis output. It can be used for various use cases, including paragraph and table structure analysis, extraction, and figure/table detection.
|
31
35
|
|
32
|
-
|
33
|
-
import cv2
|
34
|
-
|
35
|
-
from yomitoku import DocumentAnalyzer
|
36
|
-
from yomitoku.data.functions import load_image
|
37
|
-
|
38
|
-
if __name__ == "__main__":
|
39
|
-
img = load_image(PATH_IMAGE)
|
40
|
-
analyzer = DocumentAnalyzer(configs=None, visualize=True, device="cuda")
|
41
|
-
results, ocr_vis, layout_vis = analyzer(img)
|
36
|
+
<!--codeinclude-->
|
42
37
|
|
43
|
-
|
44
|
-
results.to_html(PATH_OUTPUT)
|
38
|
+
[demo/simple_document_analysis.py](../demo/simple_document_analysis.py)
|
45
39
|
|
46
|
-
|
47
|
-
cv2.imwrite("output_ocr.jpg", ocr_vis)
|
48
|
-
cv2.imwrite("output_layout.jpg", layout_vis)
|
49
|
-
```
|
40
|
+
<!--/codeinclude-->
|
50
41
|
|
51
42
|
- Setting `visualize` to True enables the visualization of each processing result. The second and third return values will contain the OCR and layout analysis results, respectively. If set to False, None will be returned. Since visualization adds computational overhead, it is recommended to set it to False unless needed for debugging purposes.
|
52
43
|
- The `device` parameter specifies the computation device to be used. The default is "cuda". If a GPU is unavailable, it automatically switches to CPU mode for processing.
|
@@ -54,31 +45,20 @@ if __name__ == "__main__":
|
|
54
45
|
|
55
46
|
The results of DocumentAnalyzer can be exported in the following formats:
|
56
47
|
|
57
|
-
`to_json()`: JSON format (
|
58
|
-
`to_html()`: HTML format (
|
59
|
-
`to_csv()`: Comma-separated CSV format (
|
60
|
-
`to_markdown()`: Markdown format (
|
61
|
-
|
48
|
+
`to_json()`: JSON format (_.json)
|
49
|
+
`to_html()`: HTML format (_.html)
|
50
|
+
`to_csv()`: Comma-separated CSV format (_.csv)
|
51
|
+
`to_markdown()`: Markdown format (_.md)
|
62
52
|
|
63
53
|
### Using AI-OCR Only
|
64
54
|
|
65
|
-
AI-OCR performs text detection and recognition on the detected text, returning the positions of the text within the image along with the
|
55
|
+
AI-OCR performs text detection and recognition on the detected text, returning the positions of the text within the image along with the
|
66
56
|
|
67
|
-
|
68
|
-
import cv2
|
57
|
+
<!--codeinclude-->
|
69
58
|
|
70
|
-
|
71
|
-
from yomitoku.data.functions import load_image
|
59
|
+
[demo/simple_ocr.py](../demo/simple_ocr.py)
|
72
60
|
|
73
|
-
|
74
|
-
img = load_image(PATH_IMAGE)
|
75
|
-
ocr = OCR(configs=None, visualize=True, device="cuda")
|
76
|
-
results, ocr_vis = ocr(img)
|
77
|
-
|
78
|
-
# JSON形式で解析結果をエクスポート
|
79
|
-
results.to_json(PATH_OUTPUT)
|
80
|
-
cv2.imwrite("output_ocr.jpg", ocr_vis)
|
81
|
-
```
|
61
|
+
<!--/codeinclude-->
|
82
62
|
|
83
63
|
- Setting `visualize` to True enables the visualization of each processing result. The second and third return values will contain the OCR and layout analysis results, respectively. If set to False, None will be returned. Since visualization adds computational overhead, it is recommended to set it to False unless needed for debugging purposes.
|
84
64
|
- The `device` parameter specifies the computation device to be used. The default is "cuda". If a GPU is unavailable, it automatically switches to CPU mode for processing.
|
@@ -90,22 +70,11 @@ The results of OCR processing support export in JSON format (`to_json()`) only.
|
|
90
70
|
|
91
71
|
The `LayoutAnalyzer` performs text detection, followed by AI-based paragraph, figure/table detection, and table structure analysis. It analyzes the layout structure within the document.
|
92
72
|
|
93
|
-
|
94
|
-
import cv2
|
73
|
+
<!--codeinclude-->
|
95
74
|
|
96
|
-
|
97
|
-
from yomitoku.data.functions import load_image
|
98
|
-
|
99
|
-
if __name__ == "__main__":
|
100
|
-
img = load_image(PATH_IMAGE)
|
101
|
-
analyzer = LayoutAnalyzer(configs=None, visualize=True, device="cuda")
|
102
|
-
results, layout_vis = analyzer(img)
|
103
|
-
|
104
|
-
# JSON形式で解析結果をエクスポート
|
105
|
-
results.to_json(PATH_OUTPUT)
|
106
|
-
cv2.imwrite("output_layout.jpg", layout_vis)
|
107
|
-
```
|
75
|
+
[demo/simple_layout.py](../demo/simple_layout.py)
|
108
76
|
|
77
|
+
<!--/codeinclude-->
|
109
78
|
|
110
79
|
- Setting `visualize` to True enables the visualization of each processing result. The second and third return values will contain the OCR and layout analysis results, respectively. If set to False, None will be returned. Since visualization adds computational overhead, it is recommended to set it to False unless needed for debugging purposes.
|
111
80
|
- The `device` parameter specifies the computation device to be used. The default is "cuda". If a GPU is unavailable, it automatically switches to CPU mode for processing.
|
@@ -149,7 +118,6 @@ if __name__ == "__main__":
|
|
149
118
|
|
150
119
|
### Defining Parameters in an YAML File
|
151
120
|
|
152
|
-
|
153
121
|
By providing the path to a YAML file in the config, you can adjust detailed parameters for inference. Examples of YAML files can be found in the `configs` directory within the repository. While the model's network parameters cannot be modified, certain aspects like post-processing parameters and input image size can be adjusted.
|
154
122
|
|
155
123
|
For instance, you can define post-processing thresholds for the Text Detector in a YAML file and set its path in the config. The config file does not need to include all parameters; you only need to specify the parameters that require changes.
|
@@ -162,21 +130,11 @@ post_process:
|
|
162
130
|
|
163
131
|
Storing the Path to a YAML File in the Config
|
164
132
|
|
165
|
-
|
166
|
-
from yomitoku import DocumentAnalyzer
|
133
|
+
<!--codeinclude-->
|
167
134
|
|
168
|
-
|
169
|
-
# path_cfgに設定したymalのパスを記述する
|
170
|
-
configs = {
|
171
|
-
"ocr": {
|
172
|
-
"text_detector": {
|
173
|
-
"path_cfg": "text_detector.yaml"
|
174
|
-
}
|
175
|
-
}
|
176
|
-
}
|
135
|
+
[demo/setting_document_anaysis.py](../demo/setting_document_anaysis.py)
|
177
136
|
|
178
|
-
|
179
|
-
```
|
137
|
+
<!--/codeinclude-->
|
180
138
|
|
181
139
|
## Using in an Offline Environment
|
182
140
|
|
@@ -185,7 +143,6 @@ Yomitoku automatically downloads models from Hugging Face Hub during the first e
|
|
185
143
|
1. Install [Git Large File Storage](https://docs.github.com/ja/repositories/working-with-files/managing-large-files/installing-git-large-file-storage)
|
186
144
|
2. In an environment with internet access, download the model repository. Copy the cloned repository to your target environment using your preferred tools.
|
187
145
|
|
188
|
-
|
189
146
|
The following is the command to download the model repository from Hugging Face Hub.
|
190
147
|
|
191
148
|
```sh
|
@@ -206,18 +163,8 @@ hf_hub_repo: yomitoku-text-detector-dbnet-open-beta
|
|
206
163
|
|
207
164
|
4. Storing the Path to a YAML File in the Config
|
208
165
|
|
209
|
-
|
210
|
-
from yomitoku import DocumentAnalyzer
|
166
|
+
<!--codeinclude-->
|
211
167
|
|
212
|
-
|
213
|
-
# path_cfgに設定したymalのパスを記述する
|
214
|
-
configs = {
|
215
|
-
"ocr": {
|
216
|
-
"text_detector": {
|
217
|
-
"path_cfg": "text_detector.yaml"
|
218
|
-
}
|
219
|
-
}
|
220
|
-
}
|
168
|
+
[demo/setting_document_anaysis.py](../demo/setting_document_anaysis.py)
|
221
169
|
|
222
|
-
|
223
|
-
```
|
170
|
+
<!--/codeinclude-->
|