yomitoku 0.4.0.post1.dev0__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.
Files changed (151) hide show
  1. yomitoku-0.4.0.post1.dev0/.github/release-drafter.yml +62 -0
  2. yomitoku-0.4.0.post1.dev0/.github/workflows/build-and-publish-docs.yaml +18 -0
  3. yomitoku-0.4.0.post1.dev0/.github/workflows/build-and-publish.yml +28 -0
  4. yomitoku-0.4.0.post1.dev0/.github/workflows/create-release.yml +23 -0
  5. yomitoku-0.4.0.post1.dev0/.github/workflows/lint-and-test.yml +40 -0
  6. yomitoku-0.4.0.post1.dev0/.gitignore +23 -0
  7. yomitoku-0.4.0.post1.dev0/.pre-commit-config.yaml +13 -0
  8. yomitoku-0.4.0.post1.dev0/.python-version +1 -0
  9. yomitoku-0.4.0.post1.dev0/PKG-INFO +127 -0
  10. yomitoku-0.4.0.post1.dev0/README.md +106 -0
  11. yomitoku-0.4.0.post1.dev0/configs/layout_parser_rtdetrv2.yaml +67 -0
  12. yomitoku-0.4.0.post1.dev0/configs/table_structure_recognitizer.yaml +2 -0
  13. yomitoku-0.4.0.post1.dev0/configs/text_detector.yaml +30 -0
  14. yomitoku-0.4.0.post1.dev0/configs/text_recognizer.yaml +14 -0
  15. yomitoku-0.4.0.post1.dev0/demo/sample.pdf +0 -0
  16. yomitoku-0.4.0.post1.dev0/demo/setting_document_anaysis.py +25 -0
  17. yomitoku-0.4.0.post1.dev0/demo/simple_document_analysis.py +20 -0
  18. yomitoku-0.4.0.post1.dev0/demo/simple_layout.py +15 -0
  19. yomitoku-0.4.0.post1.dev0/demo/simple_ocr.py +15 -0
  20. yomitoku-0.4.0.post1.dev0/demo/text_detector.yaml +4 -0
  21. yomitoku-0.4.0.post1.dev0/dockerfile +37 -0
  22. yomitoku-0.4.0.post1.dev0/docs/assets/logo.svg +97 -0
  23. yomitoku-0.4.0.post1.dev0/docs/index.md +37 -0
  24. yomitoku-0.4.0.post1.dev0/docs/installation.md +55 -0
  25. yomitoku-0.4.0.post1.dev0/docs/usage.md +220 -0
  26. yomitoku-0.4.0.post1.dev0/gallery.md +13 -0
  27. yomitoku-0.4.0.post1.dev0/mkdocs.yml +72 -0
  28. yomitoku-0.4.0.post1.dev0/pyproject.toml +67 -0
  29. yomitoku-0.4.0.post1.dev0/pytest.ini +0 -0
  30. yomitoku-0.4.0.post1.dev0/scripts/register_hugging_face_hub.py +49 -0
  31. yomitoku-0.4.0.post1.dev0/src/yomitoku/__init__.py +20 -0
  32. yomitoku-0.4.0.post1.dev0/src/yomitoku/base.py +136 -0
  33. yomitoku-0.4.0.post1.dev0/src/yomitoku/cli/__init__.py +0 -0
  34. yomitoku-0.4.0.post1.dev0/src/yomitoku/cli/main.py +230 -0
  35. yomitoku-0.4.0.post1.dev0/src/yomitoku/configs/__init__.py +13 -0
  36. yomitoku-0.4.0.post1.dev0/src/yomitoku/configs/cfg_layout_parser_rtdtrv2.py +89 -0
  37. yomitoku-0.4.0.post1.dev0/src/yomitoku/configs/cfg_table_structure_recognizer_rtdtrv2.py +80 -0
  38. yomitoku-0.4.0.post1.dev0/src/yomitoku/configs/cfg_text_detector_dbnet.py +49 -0
  39. yomitoku-0.4.0.post1.dev0/src/yomitoku/configs/cfg_text_recognizer_parseq.py +51 -0
  40. yomitoku-0.4.0.post1.dev0/src/yomitoku/constants.py +32 -0
  41. yomitoku-0.4.0.post1.dev0/src/yomitoku/data/__init__.py +3 -0
  42. yomitoku-0.4.0.post1.dev0/src/yomitoku/data/dataset.py +40 -0
  43. yomitoku-0.4.0.post1.dev0/src/yomitoku/data/functions.py +279 -0
  44. yomitoku-0.4.0.post1.dev0/src/yomitoku/document_analyzer.py +315 -0
  45. yomitoku-0.4.0.post1.dev0/src/yomitoku/export/__init__.py +6 -0
  46. yomitoku-0.4.0.post1.dev0/src/yomitoku/export/export_csv.py +71 -0
  47. yomitoku-0.4.0.post1.dev0/src/yomitoku/export/export_html.py +188 -0
  48. yomitoku-0.4.0.post1.dev0/src/yomitoku/export/export_json.py +34 -0
  49. yomitoku-0.4.0.post1.dev0/src/yomitoku/export/export_markdown.py +145 -0
  50. yomitoku-0.4.0.post1.dev0/src/yomitoku/layout_analyzer.py +66 -0
  51. yomitoku-0.4.0.post1.dev0/src/yomitoku/layout_parser.py +189 -0
  52. yomitoku-0.4.0.post1.dev0/src/yomitoku/models/__init__.py +9 -0
  53. yomitoku-0.4.0.post1.dev0/src/yomitoku/models/dbnet_plus.py +272 -0
  54. yomitoku-0.4.0.post1.dev0/src/yomitoku/models/layers/__init__.py +0 -0
  55. yomitoku-0.4.0.post1.dev0/src/yomitoku/models/layers/activate.py +38 -0
  56. yomitoku-0.4.0.post1.dev0/src/yomitoku/models/layers/dbnet_feature_attention.py +160 -0
  57. yomitoku-0.4.0.post1.dev0/src/yomitoku/models/layers/parseq_transformer.py +218 -0
  58. yomitoku-0.4.0.post1.dev0/src/yomitoku/models/layers/rtdetr_backbone.py +333 -0
  59. yomitoku-0.4.0.post1.dev0/src/yomitoku/models/layers/rtdetr_hybrid_encoder.py +433 -0
  60. yomitoku-0.4.0.post1.dev0/src/yomitoku/models/layers/rtdetrv2_decoder.py +811 -0
  61. yomitoku-0.4.0.post1.dev0/src/yomitoku/models/parseq.py +243 -0
  62. yomitoku-0.4.0.post1.dev0/src/yomitoku/models/rtdetr.py +22 -0
  63. yomitoku-0.4.0.post1.dev0/src/yomitoku/ocr.py +87 -0
  64. yomitoku-0.4.0.post1.dev0/src/yomitoku/postprocessor/__init__.py +9 -0
  65. yomitoku-0.4.0.post1.dev0/src/yomitoku/postprocessor/dbnet_postporcessor.py +137 -0
  66. yomitoku-0.4.0.post1.dev0/src/yomitoku/postprocessor/parseq_tokenizer.py +128 -0
  67. yomitoku-0.4.0.post1.dev0/src/yomitoku/postprocessor/rtdetr_postprocessor.py +107 -0
  68. yomitoku-0.4.0.post1.dev0/src/yomitoku/reading_order.py +214 -0
  69. yomitoku-0.4.0.post1.dev0/src/yomitoku/resource/MPLUS1p-Medium.ttf +0 -0
  70. yomitoku-0.4.0.post1.dev0/src/yomitoku/resource/charset.txt +1 -0
  71. yomitoku-0.4.0.post1.dev0/src/yomitoku/table_structure_recognizer.py +244 -0
  72. yomitoku-0.4.0.post1.dev0/src/yomitoku/text_detector.py +103 -0
  73. yomitoku-0.4.0.post1.dev0/src/yomitoku/text_recognizer.py +128 -0
  74. yomitoku-0.4.0.post1.dev0/src/yomitoku/utils/__init__.py +0 -0
  75. yomitoku-0.4.0.post1.dev0/src/yomitoku/utils/graph.py +20 -0
  76. yomitoku-0.4.0.post1.dev0/src/yomitoku/utils/logger.py +15 -0
  77. yomitoku-0.4.0.post1.dev0/src/yomitoku/utils/misc.py +102 -0
  78. yomitoku-0.4.0.post1.dev0/src/yomitoku/utils/visualizer.py +179 -0
  79. yomitoku-0.4.0.post1.dev0/static/in/demo.jpg +0 -0
  80. yomitoku-0.4.0.post1.dev0/static/in/gallery1.jpg +0 -0
  81. yomitoku-0.4.0.post1.dev0/static/in/gallery2.jpg +0 -0
  82. yomitoku-0.4.0.post1.dev0/static/in/gallery3.jpg +0 -0
  83. yomitoku-0.4.0.post1.dev0/static/in/gallery4.jpg +0 -0
  84. yomitoku-0.4.0.post1.dev0/static/in/gallery5.jpg +0 -0
  85. yomitoku-0.4.0.post1.dev0/static/in/gallery6.jpg +0 -0
  86. yomitoku-0.4.0.post1.dev0/static/logo/horizontal.png +0 -0
  87. yomitoku-0.4.0.post1.dev0/static/out/demo_html.png +0 -0
  88. yomitoku-0.4.0.post1.dev0/static/out/figures/in_demo_p1_figure_0.png +0 -0
  89. yomitoku-0.4.0.post1.dev0/static/out/figures/in_gallery1_p1_figure_0.png +0 -0
  90. yomitoku-0.4.0.post1.dev0/static/out/figures/in_gallery1_p1_figure_1.png +0 -0
  91. yomitoku-0.4.0.post1.dev0/static/out/figures/in_gallery1_p1_figure_10.png +0 -0
  92. yomitoku-0.4.0.post1.dev0/static/out/figures/in_gallery1_p1_figure_2.png +0 -0
  93. yomitoku-0.4.0.post1.dev0/static/out/figures/in_gallery1_p1_figure_3.png +0 -0
  94. yomitoku-0.4.0.post1.dev0/static/out/figures/in_gallery1_p1_figure_4.png +0 -0
  95. yomitoku-0.4.0.post1.dev0/static/out/figures/in_gallery1_p1_figure_5.png +0 -0
  96. yomitoku-0.4.0.post1.dev0/static/out/figures/in_gallery1_p1_figure_6.png +0 -0
  97. yomitoku-0.4.0.post1.dev0/static/out/figures/in_gallery1_p1_figure_7.png +0 -0
  98. yomitoku-0.4.0.post1.dev0/static/out/figures/in_gallery1_p1_figure_8.png +0 -0
  99. yomitoku-0.4.0.post1.dev0/static/out/figures/in_gallery1_p1_figure_9.png +0 -0
  100. yomitoku-0.4.0.post1.dev0/static/out/figures/in_gallery3_p1_figure_0.png +0 -0
  101. yomitoku-0.4.0.post1.dev0/static/out/figures/in_gallery3_p1_figure_1.png +0 -0
  102. yomitoku-0.4.0.post1.dev0/static/out/figures/in_gallery5_p1_figure_0.png +0 -0
  103. yomitoku-0.4.0.post1.dev0/static/out/figures/in_gallery5_p1_figure_1.png +0 -0
  104. yomitoku-0.4.0.post1.dev0/static/out/figures/in_gallery6_p1_figure_0.png +0 -0
  105. yomitoku-0.4.0.post1.dev0/static/out/figures/in_gallery6_p1_figure_1.png +0 -0
  106. yomitoku-0.4.0.post1.dev0/static/out/in_demo_p1.html +86 -0
  107. yomitoku-0.4.0.post1.dev0/static/out/in_demo_p1.md +38 -0
  108. yomitoku-0.4.0.post1.dev0/static/out/in_demo_p1_layout.jpg +0 -0
  109. yomitoku-0.4.0.post1.dev0/static/out/in_demo_p1_ocr.jpg +0 -0
  110. yomitoku-0.4.0.post1.dev0/static/out/in_gallery1_p1.md +78 -0
  111. yomitoku-0.4.0.post1.dev0/static/out/in_gallery1_p1_layout.jpg +0 -0
  112. yomitoku-0.4.0.post1.dev0/static/out/in_gallery1_p1_ocr.jpg +0 -0
  113. yomitoku-0.4.0.post1.dev0/static/out/in_gallery2_p1.md +24 -0
  114. yomitoku-0.4.0.post1.dev0/static/out/in_gallery2_p1_layout.jpg +0 -0
  115. yomitoku-0.4.0.post1.dev0/static/out/in_gallery2_p1_ocr.jpg +0 -0
  116. yomitoku-0.4.0.post1.dev0/static/out/in_gallery3_p1.md +49 -0
  117. yomitoku-0.4.0.post1.dev0/static/out/in_gallery3_p1_layout.jpg +0 -0
  118. yomitoku-0.4.0.post1.dev0/static/out/in_gallery3_p1_ocr.jpg +0 -0
  119. yomitoku-0.4.0.post1.dev0/static/out/in_gallery4_p1.md +23 -0
  120. yomitoku-0.4.0.post1.dev0/static/out/in_gallery4_p1_layout.jpg +0 -0
  121. yomitoku-0.4.0.post1.dev0/static/out/in_gallery4_p1_ocr.jpg +0 -0
  122. yomitoku-0.4.0.post1.dev0/static/out/in_gallery5_p1.md +47 -0
  123. yomitoku-0.4.0.post1.dev0/static/out/in_gallery5_p1_layout.jpg +0 -0
  124. yomitoku-0.4.0.post1.dev0/static/out/in_gallery5_p1_ocr.jpg +0 -0
  125. yomitoku-0.4.0.post1.dev0/static/out/in_gallery6_p1.md +34 -0
  126. yomitoku-0.4.0.post1.dev0/static/out/in_gallery6_p1_layout.jpg +0 -0
  127. yomitoku-0.4.0.post1.dev0/static/out/in_gallery6_p1_ocr.jpg +0 -0
  128. yomitoku-0.4.0.post1.dev0/tests/data/invalid.jpg +0 -0
  129. yomitoku-0.4.0.post1.dev0/tests/data/invalid.pdf +0 -0
  130. yomitoku-0.4.0.post1.dev0/tests/data/rgba.png +0 -0
  131. yomitoku-0.4.0.post1.dev0/tests/data/small.jpg +0 -0
  132. yomitoku-0.4.0.post1.dev0/tests/data/subdir/test.jpg +0 -0
  133. yomitoku-0.4.0.post1.dev0/tests/data/test.bmp +0 -0
  134. yomitoku-0.4.0.post1.dev0/tests/data/test.jpg +0 -0
  135. yomitoku-0.4.0.post1.dev0/tests/data/test.pdf +0 -0
  136. yomitoku-0.4.0.post1.dev0/tests/data/test.png +0 -0
  137. yomitoku-0.4.0.post1.dev0/tests/data/test.tiff +0 -0
  138. yomitoku-0.4.0.post1.dev0/tests/data/test.txt +1 -0
  139. yomitoku-0.4.0.post1.dev0/tests/data/test_gray.jpg +0 -0
  140. yomitoku-0.4.0.post1.dev0/tests/test_base.py +118 -0
  141. yomitoku-0.4.0.post1.dev0/tests/test_cli.py +199 -0
  142. yomitoku-0.4.0.post1.dev0/tests/test_data.py +189 -0
  143. yomitoku-0.4.0.post1.dev0/tests/test_document_analyzer.py +100 -0
  144. yomitoku-0.4.0.post1.dev0/tests/test_export.py +490 -0
  145. yomitoku-0.4.0.post1.dev0/tests/test_layout_analyzer.py +61 -0
  146. yomitoku-0.4.0.post1.dev0/tests/test_ocr.py +57 -0
  147. yomitoku-0.4.0.post1.dev0/tests/yaml/layout_parser.yaml +1 -0
  148. yomitoku-0.4.0.post1.dev0/tests/yaml/table_structure_recognizer.yaml +1 -0
  149. yomitoku-0.4.0.post1.dev0/tests/yaml/text_detector.yaml +2 -0
  150. yomitoku-0.4.0.post1.dev0/tests/yaml/text_recognizer.yaml +1 -0
  151. yomitoku-0.4.0.post1.dev0/uv.lock +1743 -0
@@ -0,0 +1,62 @@
1
+ ---
2
+ name-template: "v$RESOLVED_VERSION"
3
+ tag-template: "v$RESOLVED_VERSION"
4
+ categories: # categorize
5
+ - title: "🚀 機能追加"
6
+ labels:
7
+ - "enhancement"
8
+ - title: "🔧 リファクタ"
9
+ labels:
10
+ - "refactoring"
11
+ - title: "🐛 バグ修正"
12
+ labels:
13
+ - "bug"
14
+ - title: "✅ テスト"
15
+ labels:
16
+ - "test"
17
+ - title: "📖 ドキュメント"
18
+ labels:
19
+ - "documentation"
20
+ change-template: "- $TITLE @$AUTHOR (#$NUMBER)"
21
+ change-title-escapes: '\<*_&' # You can add # and @ to disable mentions, and add ` to disable code blocks.
22
+ autolabeler: # auto add labels based on branches or titles
23
+ - label: "enhancement"
24
+ branch:
25
+ - '/feature\/.+/'
26
+ - '/feat\/.+/'
27
+ - label: "release"
28
+ branch:
29
+ - '/release\/.+/'
30
+ - label: "refactoring"
31
+ branch:
32
+ - '/refactor\/.+/'
33
+ title:
34
+ - "/refactor/i"
35
+ - label: "bug"
36
+ branch:
37
+ - '/fix\/.+/'
38
+ - '/bug\/.+/'
39
+ title:
40
+ - "/fix/i"
41
+ - "/bug/i"
42
+ - label: "test"
43
+ branch:
44
+ - '/test\/.+/'
45
+ - label: "documentation"
46
+ branch:
47
+ - '/doc\/.+/'
48
+ title:
49
+ - "/doc/i"
50
+ version-resolver: # resolve next version based on tags ($RESOLVED_VERSION)
51
+ major:
52
+ labels:
53
+ - "breaking"
54
+ minor:
55
+ labels:
56
+ - "enhancement"
57
+ default: patch
58
+ template: |
59
+ ## 変更
60
+
61
+ $CHANGES
62
+
@@ -0,0 +1,18 @@
1
+ name: ci
2
+ on:
3
+ push:
4
+ branches:
5
+ - main
6
+ permissions:
7
+ contents: write
8
+ jobs:
9
+ deploy-docs:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v3
13
+ - uses: actions/setup-python@v4
14
+ with:
15
+ python-version: 3.x
16
+ - run: |
17
+ pip install tox
18
+ tox -e docs
@@ -0,0 +1,28 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ jobs:
8
+ publish_PyPI:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ with:
13
+ fetch-depth: 0
14
+ tags: true
15
+ - name: Set up Python 3.9
16
+ uses: actions/setup-python@v3
17
+ with:
18
+ python-version: "3.9"
19
+ - name: Install uv
20
+ uses: astral-sh/setup-uv@v3
21
+ with:
22
+ enable-cache: true
23
+ - name: Install dependencies
24
+ run: uv sync --dev
25
+ - name: build
26
+ run: uv build
27
+ - name: Publish to PyPI
28
+ run: uv publish --token ${{ secrets.PYPI }}
@@ -0,0 +1,23 @@
1
+ ---
2
+ name: Release Drafter
3
+
4
+ on:
5
+ push:
6
+ branches:
7
+ - main
8
+ pull_request_target:
9
+ types: [opened, reopened, synchronize]
10
+
11
+ permissions:
12
+ contents: read
13
+
14
+ jobs:
15
+ update_release_draft:
16
+ permissions:
17
+ contents: write
18
+ pull-requests: write
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: release-drafter/release-drafter@v6
22
+ env:
23
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -0,0 +1,40 @@
1
+ name: Python Lint
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ lint-and-test:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+ - name: Cleanup disk space
17
+ run: |
18
+ sudo apt-get clean
19
+ sudo rm -rf /usr/share/dotnet
20
+ sudo rm -rf /usr/local/lib/android
21
+ sudo rm -rf /opt/ghc
22
+ df -h
23
+ - name: Set up Python 3.12
24
+ uses: actions/setup-python@v5
25
+ with:
26
+ python-version: "3.12"
27
+ - name: Install uv
28
+ uses: astral-sh/setup-uv@v3
29
+ with:
30
+ enable-cache: true
31
+ - name: pin python version
32
+ run: uv python pin 3.12
33
+ - name: Install dependencies
34
+ run: sudo apt install -y libopencv-dev poppler-utils
35
+ - name: Install tox-uv
36
+ run: uv tool install tox --with tox-uv
37
+ - name: Run linter
38
+ run: tox -e lint
39
+ - name: Run tests
40
+ run: tox -p -e py39,py310,py311,py312
@@ -0,0 +1,23 @@
1
+ # Python-generated files
2
+ __pycache__/
3
+ *.py[oc]
4
+ build/
5
+ dist/
6
+ wheels/
7
+ *.egg-info
8
+
9
+ # Virtual environments
10
+ .venv
11
+ .tox
12
+
13
+ # Dev tools cache
14
+ .ruff_cache
15
+ .pytest_cache
16
+
17
+ .DS_Store
18
+
19
+ dataset/
20
+ weights/
21
+ results/
22
+
23
+ .coverage*
@@ -0,0 +1,13 @@
1
+ repos:
2
+ - repo: local
3
+ hooks:
4
+ - id: lint
5
+ name: lint
6
+ entry: bash -c '.tox/lint/bin/ruff check --fix'
7
+ language: system
8
+ types: [python]
9
+ - id: format
10
+ name: format
11
+ entry: bash -c '.tox/lint/bin/ruff format'
12
+ language: system
13
+ types: [python]
@@ -0,0 +1 @@
1
+ 3.9
@@ -0,0 +1,127 @@
1
+ Metadata-Version: 2.3
2
+ Name: yomitoku
3
+ Version: 0.4.0.post1.dev0
4
+ Summary: Yomitoku is a document image analysis package powered by AI technology for the Japanese language.
5
+ Author-email: Kotaro Kinoshita <kotaro.kinoshita@mlism.com>
6
+ License: CC BY-NC-SA 4.0
7
+ Keywords: Deep Learning,Japanese,OCR
8
+ Requires-Python: >=3.9
9
+ Requires-Dist: huggingface-hub>=0.26.1
10
+ Requires-Dist: lxml>=5.3.0
11
+ Requires-Dist: omegaconf>=2.3.0
12
+ Requires-Dist: opencv-python>=4.10.0.84
13
+ Requires-Dist: pdf2image>=1.17.0
14
+ Requires-Dist: pyclipper>=1.3.0.post6
15
+ Requires-Dist: pydantic>=2.9.2
16
+ Requires-Dist: shapely>=2.0.6
17
+ Requires-Dist: timm>=1.0.11
18
+ Requires-Dist: torch>=2.5.0
19
+ Requires-Dist: torchvision>=0.20.0
20
+ Description-Content-Type: text/markdown
21
+
22
+ # YomiToku
23
+
24
+ ![Python](https://img.shields.io/badge/Python-3.9|3.10|3.11|3.12-F9DC3E.svg?logo=python&logoColor=&style=flat)
25
+ ![Pytorch](https://img.shields.io/badge/Pytorch-2.5-EE4C2C.svg?logo=Pytorch&style=fla)
26
+ ![OS](https://img.shields.io/badge/OS-Linux|MacOS-1793D1.svg?&style=fla)
27
+ [![Document](https://img.shields.io/badge/docs-live-brightgreen)](https://kotaro-kinoshita.github.io/yomitoku-dev/)
28
+
29
+ <img src="static/logo/horizontal.png" width="800px">
30
+
31
+ ## 🌟 概要
32
+
33
+ YomiToku は日本語に特化した AI 文章画像解析エンジン(Document AI)です。画像内の文字の全文 OCR およびレイアウト解析機能を有しており、画像内の文字情報や図表を認識、抽出、変換します。
34
+
35
+ - 🤖 日本語データセットで学習した 4 種類(文字位置の検知、文字列認識、レイアウト解析、表の構造認識)の AI モデルを搭載しています。4 種類のモデルはすべて独自に学習されたモデルで日本語文書に対して、高精度に推論可能です。
36
+ - 🇯🇵 各モデルは日本語の文書画像に特化して学習されており、7000 文字を超える日本語文字の認識をサーポート、縦書きなど日本語特有のレイアウト構造の文書画像の解析も可能です。(日本語以外にも英語の文書に対しても対応しています)。
37
+ - 📈 レイアウト解析、表の構造解析, 読み順推定機能により、文書画像のレイアウトの意味的構造を壊さずに情報を抽出することが可能です。
38
+ - 📄 多様な出力形式をサポートしています。html やマークダウン、json、csv のいずれかのフォーマットに変換可能です。また、文書内に含まれる図表、画像の抽出の出力も可能です。
39
+ - ⚡ GPU 環境で高速に動作し、効率的に文書の文字起こし解析が可能です。また、VRAM も 8GB 以内で動作し、ハイエンドな GPU を用意する必要はありません。
40
+
41
+ ## 🖼️ デモ
42
+
43
+ [gallery.md](gallery.md)にも複数種類の画像の検証結果を掲載しています。
44
+
45
+ | 入力画像 | OCR の結果 |
46
+ | :--------------------------------------------------------: | :-----------------------------------------------------: |
47
+ | <img src="static/in/demo.jpg" width="400px"> | <img src="static/out/in_demo_p1_ocr.jpg" width="400px"> |
48
+ | レイアウト解析の結果 | エクスポート<br>(HTML で出力したものをスクショ) |
49
+ | <img src="static/out/in_demo_p1_layout.jpg" width="400px"> | <img src="static/out/demo_html.png" width="400px"> |
50
+
51
+ Markdown でエクスポートした結果は関してはリポジトリ内の[static/out/in_demo_p1.md](static/out/in_demo_p1.md)を参照
52
+
53
+ - `赤枠` : 図、画像等の位置
54
+ - `緑枠` : 表領域全体の位置
55
+ - `ピンク枠` : 表のセル構造(セル上の文字は [行番号, 列番号] (rowspan x colspan)を表します)
56
+ - `青枠` : 段落、テキストグループ領域
57
+ - `赤矢印` : 読み順推定の結果
58
+
59
+ 画像の出典:[「令和 6 年版情報通信白書 3 章 2 節 AI の進化に伴い発展するテクノロジー」](https://www.soumu.go.jp/johotsusintokei/whitepaper/ja/r06/pdf/n1410000.pdf):(総務省) を加工して作成
60
+
61
+ ## 📣 リリース情報
62
+
63
+ - 2024 年 12 月 XX YomiToku vX.X.X を公開
64
+
65
+ ## 💡 インストールの方法
66
+
67
+ ```
68
+ pip install git+https://github.com/kotaro-kinoshita/yomitoku-dev.git@main
69
+ ```
70
+
71
+ - pytorch がご自身の GPU の環境にあったものをインストールしてください
72
+
73
+ ### 依存ライブラリ
74
+
75
+ pdf ファイルの解析を行うためには、別途、[poppler](https://poppler.freedesktop.org/)のインストールが必要です。
76
+
77
+ **Mac**
78
+
79
+ ```
80
+ brew install poppler
81
+ ```
82
+
83
+ **Linux**
84
+
85
+ ```
86
+ apt install poppler-utils -y
87
+ ```
88
+
89
+ ## 🚀 実行方法
90
+
91
+ ```
92
+ yomitoku ${path_data} -f md -o results -v --figure
93
+ ```
94
+
95
+ - `${path_data}` 解析対象の画像が含まれたディレクトリか画像ファイルのパスを直接して指定してください。ディレクトリを対象とした場合はディレクトリのサブディレクトリ内の画像も含めて処理を実行します。
96
+ - `-f`, `--format` 出力形式のファイルフォーマットを指定します。(json, csv, html, md をサポート)
97
+ - `-o`, `--outdir` 出力先のディレクトリ名を指定します。存在しない場合は新規で作成されます。
98
+ - `-v`, `--vis` を指定すると解析結果を可視化した画像を出力します。
99
+ - `-d`, `--device` モデルを実行するためのデバイスを指定します。gpu が利用できない場合は cpu で推論が実行されます。(デフォルト: cuda)
100
+ - `--ignore_line_break` 画像の改行位置を無視して、段落内の文章を連結して返します。(デフォルト:画像通りの改行位置位置で改行します。)
101
+ - `figure_letter` 検出した図表に含まれる文字も出力ファイルにエクスポートします。
102
+ - `figure` 検出した図、画像を出力ファイルにエクスポートします。(html と markdown のみ)
103
+
104
+ その他のオプションに関しては、ヘルプを参照
105
+
106
+ ```
107
+ yomitoku --help
108
+ ```
109
+
110
+ ### Note
111
+
112
+ - CPU を用いての推論向けに最適化されておらず、処理時間が長くなりますので、GPU での実行を推奨します。
113
+ - 活字のみ識別をサポートしております。手書き文字に関しては、読み取れる場合もありますが、公式にはサポートしておりません。
114
+ - OCR は文書 OCR と情景 OCR(看板など紙以外にプリントされた文字)に大別されますが、Yomitoku は文書 OCR 向けに最適化されています。
115
+ - AI-OCR の識別精度を高めるために、入力画像の解像度が重要です。低解像度画像では識別精度が低下します。最低でも画像の短辺を 720px 以上の画像で推論することをお勧めします。
116
+
117
+ ## 📝 ドキュメント
118
+
119
+ パッケージの詳細は[ドキュメント](https://kotaro-kinoshita.github.io/yomitoku-dev/)を確認してください。
120
+
121
+ ## LICENSE
122
+
123
+ 本リポジトリ内に格納されているリソースのライセンスは YomiToku は CC BY-NC-SA 4.0 に従います。
124
+ 非商用での個人利用、研究目的での利用は自由に利用できます。
125
+ 商用目的での利用に関しては、別途、商用ライセンスを提供しますので、開発者にお問い合わせください。
126
+
127
+ YomiToku © 2024 by MLism Inc. 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/
@@ -0,0 +1,106 @@
1
+ # YomiToku
2
+
3
+ ![Python](https://img.shields.io/badge/Python-3.9|3.10|3.11|3.12-F9DC3E.svg?logo=python&logoColor=&style=flat)
4
+ ![Pytorch](https://img.shields.io/badge/Pytorch-2.5-EE4C2C.svg?logo=Pytorch&style=fla)
5
+ ![OS](https://img.shields.io/badge/OS-Linux|MacOS-1793D1.svg?&style=fla)
6
+ [![Document](https://img.shields.io/badge/docs-live-brightgreen)](https://kotaro-kinoshita.github.io/yomitoku-dev/)
7
+
8
+ <img src="static/logo/horizontal.png" width="800px">
9
+
10
+ ## 🌟 概要
11
+
12
+ YomiToku は日本語に特化した AI 文章画像解析エンジン(Document AI)です。画像内の文字の全文 OCR およびレイアウト解析機能を有しており、画像内の文字情報や図表を認識、抽出、変換します。
13
+
14
+ - 🤖 日本語データセットで学習した 4 種類(文字位置の検知、文字列認識、レイアウト解析、表の構造認識)の AI モデルを搭載しています。4 種類のモデルはすべて独自に学習されたモデルで日本語文書に対して、高精度に推論可能です。
15
+ - 🇯🇵 各モデルは日本語の文書画像に特化して学習されており、7000 文字を超える日本語文字の認識をサーポート、縦書きなど日本語特有のレイアウト構造の文書画像の解析も可能です。(日本語以外にも英語の文書に対しても対応しています)。
16
+ - 📈 レイアウト解析、表の構造解析, 読み順推定機能により、文書画像のレイアウトの意味的構造を壊さずに情報を抽出することが可能です。
17
+ - 📄 多様な出力形式をサポートしています。html やマークダウン、json、csv のいずれかのフォーマットに変換可能です。また、文書内に含まれる図表、画像の抽出の出力も可能です。
18
+ - ⚡ GPU 環境で高速に動作し、効率的に文書の文字起こし解析が可能です。また、VRAM も 8GB 以内で動作し、ハイエンドな GPU を用意する必要はありません。
19
+
20
+ ## 🖼️ デモ
21
+
22
+ [gallery.md](gallery.md)にも複数種類の画像の検証結果を掲載しています。
23
+
24
+ | 入力画像 | OCR の結果 |
25
+ | :--------------------------------------------------------: | :-----------------------------------------------------: |
26
+ | <img src="static/in/demo.jpg" width="400px"> | <img src="static/out/in_demo_p1_ocr.jpg" width="400px"> |
27
+ | レイアウト解析の結果 | エクスポート<br>(HTML で出力したものをスクショ) |
28
+ | <img src="static/out/in_demo_p1_layout.jpg" width="400px"> | <img src="static/out/demo_html.png" width="400px"> |
29
+
30
+ Markdown でエクスポートした結果は関してはリポジトリ内の[static/out/in_demo_p1.md](static/out/in_demo_p1.md)を参照
31
+
32
+ - `赤枠` : 図、画像等の位置
33
+ - `緑枠` : 表領域全体の位置
34
+ - `ピンク枠` : 表のセル構造(セル上の文字は [行番号, 列番号] (rowspan x colspan)を表します)
35
+ - `青枠` : 段落、テキストグループ領域
36
+ - `赤矢印` : 読み順推定の結果
37
+
38
+ 画像の出典:[「令和 6 年版情報通信白書 3 章 2 節 AI の進化に伴い発展するテクノロジー」](https://www.soumu.go.jp/johotsusintokei/whitepaper/ja/r06/pdf/n1410000.pdf):(総務省) を加工して作成
39
+
40
+ ## 📣 リリース情報
41
+
42
+ - 2024 年 12 月 XX YomiToku vX.X.X を公開
43
+
44
+ ## 💡 インストールの方法
45
+
46
+ ```
47
+ pip install git+https://github.com/kotaro-kinoshita/yomitoku-dev.git@main
48
+ ```
49
+
50
+ - pytorch がご自身の GPU の環境にあったものをインストールしてください
51
+
52
+ ### 依存ライブラリ
53
+
54
+ pdf ファイルの解析を行うためには、別途、[poppler](https://poppler.freedesktop.org/)のインストールが必要です。
55
+
56
+ **Mac**
57
+
58
+ ```
59
+ brew install poppler
60
+ ```
61
+
62
+ **Linux**
63
+
64
+ ```
65
+ apt install poppler-utils -y
66
+ ```
67
+
68
+ ## 🚀 実行方法
69
+
70
+ ```
71
+ yomitoku ${path_data} -f md -o results -v --figure
72
+ ```
73
+
74
+ - `${path_data}` 解析対象の画像が含まれたディレクトリか画像ファイルのパスを直接して指定してください。ディレクトリを対象とした場合はディレクトリのサブディレクトリ内の画像も含めて処理を実行します。
75
+ - `-f`, `--format` 出力形式のファイルフォーマットを指定します。(json, csv, html, md をサポート)
76
+ - `-o`, `--outdir` 出力先のディレクトリ名を指定します。存在しない場合は新規で作成されます。
77
+ - `-v`, `--vis` を指定すると解析結果を可視化した画像を出力します。
78
+ - `-d`, `--device` モデルを実行するためのデバイスを指定します。gpu が利用できない場合は cpu で推論が実行されます。(デフォルト: cuda)
79
+ - `--ignore_line_break` 画像の改行位置を無視して、段落内の文章を連結して返します。(デフォルト:画像通りの改行位置位置で改行します。)
80
+ - `figure_letter` 検出した図表に含まれる文字も出力ファイルにエクスポートします。
81
+ - `figure` 検出した図、画像を出力ファイルにエクスポートします。(html と markdown のみ)
82
+
83
+ その他のオプションに関しては、ヘルプを参照
84
+
85
+ ```
86
+ yomitoku --help
87
+ ```
88
+
89
+ ### Note
90
+
91
+ - CPU を用いての推論向けに最適化されておらず、処理時間が長くなりますので、GPU での実行を推奨します。
92
+ - 活字のみ識別をサポートしております。手書き文字に関しては、読み取れる場合もありますが、公式にはサポートしておりません。
93
+ - OCR は文書 OCR と情景 OCR(看板など紙以外にプリントされた文字)に大別されますが、Yomitoku は文書 OCR 向けに最適化されています。
94
+ - AI-OCR の識別精度を高めるために、入力画像の解像度が重要です。低解像度画像では識別精度が低下します。最低でも画像の短辺を 720px 以上の画像で推論することをお勧めします。
95
+
96
+ ## 📝 ドキュメント
97
+
98
+ パッケージの詳細は[ドキュメント](https://kotaro-kinoshita.github.io/yomitoku-dev/)を確認してください。
99
+
100
+ ## LICENSE
101
+
102
+ 本リポジトリ内に格納されているリソースのライセンスは YomiToku は CC BY-NC-SA 4.0 に従います。
103
+ 非商用での個人利用、研究目的での利用は自由に利用できます。
104
+ 商用目的での利用に関しては、別途、商用ライセンスを提供しますので、開発者にお問い合わせください。
105
+
106
+ YomiToku © 2024 by MLism Inc. 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/
@@ -0,0 +1,67 @@
1
+ hf_hub_repo: KotaroKinoshita/yomitoku-layout-parser-rtdtrv2-open-beta
2
+ thresh_score: 0.45
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
+ - paragraph
66
+ - figure
67
+ - table
@@ -0,0 +1,2 @@
1
+ hf_hub_repo: "KotaroKinoshita/yomitoku-table-structure-recognizer-rtdtrv2-open-beta"
2
+ thresh_score: 0.6
@@ -0,0 +1,30 @@
1
+ hf_hub_repo: KotaroKinoshita/yomitoku-text-detector-dbnet-open-beta
2
+ backbone:
3
+ name: resnet50
4
+ dilation: true
5
+ decoder:
6
+ in_channels:
7
+ - 256
8
+ - 512
9
+ - 1024
10
+ - 2048
11
+ hidden_dim: 256
12
+ adaptive: true
13
+ serial: true
14
+ smooth: false
15
+ k: 50
16
+ data:
17
+ shortest_size: 1280
18
+ limit_size: 1600
19
+ post_process:
20
+ min_size: 2
21
+ thresh: 0.2
22
+ box_thresh: 0.5
23
+ max_candidates: 1500
24
+ unclip_ratio: 2.0
25
+ visualize:
26
+ color:
27
+ - 0
28
+ - 255
29
+ - 0
30
+ heatmap: false
@@ -0,0 +1,14 @@
1
+ hf_hub_repo: KotaroKinoshita/yomitoku-text-recognizer-parseq-open-beta
2
+ max_label_length: 100
3
+ decode_ar: 1
4
+ refine_iters: 1
5
+ data:
6
+ num_workers: 4
7
+ batch_size: 128
8
+ visualize:
9
+ font: resource/MPLUS1p-Medium.ttf
10
+ color:
11
+ - 0
12
+ - 0
13
+ - 255
14
+ font_size: 18
@@ -0,0 +1,25 @@
1
+ import cv2
2
+
3
+ from yomitoku import DocumentAnalyzer
4
+ from yomitoku.data.functions import load_pdf
5
+
6
+ if __name__ == "__main__":
7
+ PATH_IMGE = ""
8
+
9
+ configs = {
10
+ "ocr": {"text_detector": {"path_cfg": "demo/text_detector.yaml"}}
11
+ }
12
+
13
+ analyzer = DocumentAnalyzer(configs=configs, visualize=True, device="cuda")
14
+
15
+ # PDFファイルを読み込み
16
+ imgs = load_pdf("demo/sample.pdf")
17
+ for i, img in enumerate(imgs):
18
+ results, ocr_vis, layout_vis = analyzer(img)
19
+
20
+ # HTML形式で解析結果をエクスポート
21
+ results.to_html(f"output_{i}.html")
22
+
23
+ # 可視化画像を保存
24
+ cv2.imwrite(f"output_ocr_{i}.jpg", ocr_vis)
25
+ cv2.imwrite(f"output_layout_{i}.jpg", layout_vis)
@@ -0,0 +1,20 @@
1
+ import cv2
2
+
3
+ from yomitoku import DocumentAnalyzer
4
+ from yomitoku.data.functions import load_pdf
5
+
6
+ if __name__ == "__main__":
7
+ PATH_IMGE = ""
8
+
9
+ analyzer = DocumentAnalyzer(configs=None, visualize=True, device="cuda")
10
+ # PDFファイルを読み込み
11
+ imgs = load_pdf("demo/sample.pdf")
12
+ for i, img in enumerate(imgs):
13
+ results, ocr_vis, layout_vis = analyzer(img)
14
+
15
+ # HTML形式で解析結果をエクスポート
16
+ results.to_html(f"output_{i}.html")
17
+
18
+ # 可視化画像を保存
19
+ cv2.imwrite(f"output_ocr_{i}.jpg", ocr_vis)
20
+ cv2.imwrite(f"output_layout_{i}.jpg", layout_vis)
@@ -0,0 +1,15 @@
1
+ import cv2
2
+
3
+ from yomitoku import LayoutAnalyzer
4
+ from yomitoku.data.functions import load_pdf
5
+
6
+ if __name__ == "__main__":
7
+ analyzer = LayoutAnalyzer(configs=None, visualize=True, device="cuda")
8
+ # PDFファイルを読み込み
9
+ imgs = load_pdf("demo/sample.pdf")
10
+ for i, img in enumerate(imgs):
11
+ results, layout_vis = analyzer(img)
12
+
13
+ # JSON形式で解析結果をエクスポート
14
+ results.to_json(f"output_{i}.json")
15
+ cv2.imwrite(f"output_layout_{i}.jpg", layout_vis)
@@ -0,0 +1,15 @@
1
+ import cv2
2
+
3
+ from yomitoku import OCR
4
+ from yomitoku.data.functions import load_pdf
5
+
6
+ if __name__ == "__main__":
7
+ ocr = OCR(configs=None, visualize=True, device="cuda")
8
+ # PDFファイルを読み込み
9
+ imgs = load_pdf("demo/sample.pdf")
10
+ for i, img in enumerate(imgs):
11
+ results, ocr_vis = ocr(img)
12
+
13
+ # JSON形式で解析結果をエクスポート
14
+ results.to_json(f"output_{i}.json")
15
+ cv2.imwrite(f"output_ocr_{i}.jpg", ocr_vis)
@@ -0,0 +1,4 @@
1
+ #hf_hub_repo: yomitoku-text-detector-dbnet-open-beta
2
+ post_process:
3
+ thresh: 0.1
4
+ unclip_ratio: 2.5