ndlocr-lite 1.4.0.dev0__tar.gz → 2.0.0.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.
- {ndlocr_lite-1.4.0.dev0/src/ndlocr_lite.egg-info → ndlocr_lite-2.0.0.dev0}/PKG-INFO +27 -12
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/README.md +25 -11
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/ndlocr-lite-gui/main.py +749 -149
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/pyproject.toml +1 -1
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/requirements.txt +1 -0
- ndlocr_lite-2.0.0.dev0/src/config/ndl.yaml +32 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/deim.py +69 -17
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/model_download.py +9 -9
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/ndl_parser.py +33 -16
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0/src/ndlocr_lite.egg-info}/PKG-INFO +27 -12
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/ndlocr_lite.egg-info/SOURCES.txt +1 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/ndlocr_lite.egg-info/requires.txt +1 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/ocr.py +279 -59
- ndlocr_lite-2.0.0.dev0/src/optional_features/table_structure.py +139 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/parseq.py +10 -4
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/pdf_output_utils.py +23 -7
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/reading_order/xy_cut/block_xy_cut.py +1 -1
- ndlocr_lite-2.0.0.dev0/src/uicomponent/localelabel.py +226 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/uicomponent/textdaisy.py +693 -98
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/version.py +1 -1
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/tests/test_cli_arguments.py +1 -1
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/tests/test_model_download.py +24 -3
- ndlocr_lite-1.4.0.dev0/src/config/ndl.yaml +0 -21
- ndlocr_lite-1.4.0.dev0/src/uicomponent/localelabel.py +0 -118
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/LICENCE +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/LICENCE_DEPENDENCEIES +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/MANIFEST.in +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/ndlocr-lite-gui/__init__.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/ndlocr-lite-gui/assets/icon.png +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/ndlocr-lite-gui/gui_config.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/setup.cfg +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/setup.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/cli.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/config/NDLmoji.yaml +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/config/__init__.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/model/__init__.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/ndlocr_lite.egg-info/dependency_links.txt +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/ndlocr_lite.egg-info/entry_points.txt +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/ndlocr_lite.egg-info/top_level.txt +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/optional_features/__init__.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/reading_order/__init__.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/reading_order/order/__init__.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/reading_order/order/parse_xml.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/reading_order/order/reorder.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/reading_order/order/smooth_order.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/reading_order/order/warichu_block.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/reading_order/order/wrap_dataset.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/reading_order/utils/__init__.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/reading_order/utils/file.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/reading_order/utils/logger.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/reading_order/utils/time.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/reading_order/utils/xml.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/reading_order/xy_cut/__init__.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/reading_order/xy_cut/eval.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/tcy_wrapper.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/src/tools/ndlkoten2tei.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/tests/test_gui_command.py +0 -0
- {ndlocr_lite-1.4.0.dev0 → ndlocr_lite-2.0.0.dev0}/tests/test_set_version.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: ndlocr-lite
|
|
3
|
-
Version:
|
|
3
|
+
Version: 2.0.0.dev0
|
|
4
4
|
Summary: NDLOCR-Lite CLI Application
|
|
5
5
|
Requires-Python: >=3.11
|
|
6
6
|
Description-Content-Type: text/markdown
|
|
@@ -24,9 +24,12 @@ Requires-Dist: onnxruntime==1.31.1; python_version >= "3.11" and sys_platform !=
|
|
|
24
24
|
Requires-Dist: onnxruntime==1.23.2; python_version == "3.10" or sys_platform == "darwin"
|
|
25
25
|
Requires-Dist: pypdf==6.21.4
|
|
26
26
|
Requires-Dist: cryptography==50.0.2
|
|
27
|
+
Requires-Dist: markdown-it-py==4.3.0
|
|
27
28
|
Dynamic: license-file
|
|
28
29
|
|
|
29
30
|
# NDLOCR-Liteアプリケーションのリポジトリ
|
|
31
|
+
**(2026/11/24追記)v2から読書バリアフリー機能を強化しています。また、PyPIによるインストールに対応しています。**
|
|
32
|
+
|
|
30
33
|
**(2026/04/24追記)v1.2から手書き文字の認識等を強化しています。**
|
|
31
34
|
|
|
32
35
|
NDLOCR-Liteを利用してテキスト化を実行するためのアプリケーションを提供するリポジトリです。
|
|
@@ -63,15 +66,12 @@ https://github.com/facebookresearch/dinov3/blob/main/LICENSE.md
|
|
|
63
66
|
|
|
64
67
|
## コマンドラインからの利用
|
|
65
68
|
|
|
66
|
-
※コマンドラインから操作を行うにはPython 3.
|
|
69
|
+
※コマンドラインから操作を行うにはPython 3.11以上が必要です。
|
|
67
70
|
|
|
68
71
|
事前準備
|
|
69
72
|
|
|
70
73
|
```bash
|
|
71
|
-
|
|
72
|
-
cd ndlocr-lite
|
|
73
|
-
pip install -r requirements.txt
|
|
74
|
-
cd src
|
|
74
|
+
pip install ndlocr-lite
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
実行例1.(同階層にある「9892834_0001」という名称のディレクトリ内の画像を一括処理し、tmpdirという名称のディレクトリに結果を出力する。)
|
|
@@ -102,6 +102,18 @@ uv tool install .
|
|
|
102
102
|
ndlocr-lite --sourceimg digidepo_1287221_00000002.jpg --output tmpdir
|
|
103
103
|
```
|
|
104
104
|
|
|
105
|
+
PyPIから導入する場合、現時点のCLI版は開発版のため、`--pre`を指定してください(Python 3.11以上が必要です)。
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
pip install --pre ndlocr-lite
|
|
109
|
+
# uvの場合
|
|
110
|
+
uv tool install --prerelease allow ndlocr-lite
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
pip/uvでインストールする配布物にはONNXモデルを含めません。`ndlocr-lite`の初回OCR実行時に、未指定のモデルを`https://lab.ndl.go.jp/dataset/ndlocr-lite/onnx/v2/`から取得し、SHA-256を検証してユーザーのキャッシュに保存します。初回はネット接続と約157 MBの空き容量が必要です。以降はキャッシュを再利用します。`--help`と`--version`ではダウンロードしません。
|
|
114
|
+
|
|
115
|
+
キャッシュ先はWindowsでは`%LOCALAPPDATA%\ndlocr-lite\models\v2`、macOSでは`~/Library/Caches/ndlocr-lite/models/v2`、Linuxでは`${XDG_CACHE_HOME:-~/.cache}/ndlocr-lite/models/v2`です。各`--*-weights`オプションで指定したファイルはそのまま使用します。GUI版と`python ocr.py`は従来どおり同梱モデルを使用し、ダウンロードしません。
|
|
116
|
+
|
|
105
117
|
### パラメータの説明
|
|
106
118
|
|
|
107
119
|
#### `--sourcedir`オプション
|
|
@@ -151,20 +163,21 @@ OCR結果を保存する出力先ディレクトリを相対パスまたは絶
|
|
|
151
163
|
|
|
152
164
|
[NDLOCR ver.2.1の評価結果](https://lab.ndl.go.jp/data_set/r4ocr/r4_software#5-3-文字認識性能の評価結果)と同様の評価用データセット・同様の評価手法による値です。
|
|
153
165
|
|
|
154
|
-
### 手書き文字に対する評価(NDLOCR-Lite ver.
|
|
166
|
+
### 手書き文字に対する評価(NDLOCR-Lite ver.2.0.0)
|
|
155
167
|
|
|
156
168
|
Maeda, K., & Okazaki, N. JaWildText: A Benchmark for Vision-Language Models on Japanese Scene Text Understanding. arXiv preprint arXiv:2603.27942, 2026.(<https://arxiv.org/abs/2603.27942>)
|
|
157
169
|
|
|
158
170
|
によって作成された[JaWildText(外部サイト)](https://huggingface.co/datasets/llm-jp/jawildtext)のうち、手書き文字データセット1,065画像を用いて評価しました。
|
|
159
171
|
|
|
160
|
-
|
|
172
|
+
全体CER(中央値) : 0.1327 全体F値(中央値) : 0.8927 (対象: 1065 ファイル)
|
|
161
173
|
|
|
162
|
-
|
|
174
|
+
縦書きCER(中央値) : 0.1776 縦書きF値(中央値) : 0.8536 (対象: 295 ファイル)
|
|
163
175
|
|
|
164
|
-
|
|
176
|
+
横書きCER(中央値) : 0.1156 横書きF値(中央値) : 0.9050 (対象: 768 ファイル)
|
|
165
177
|
|
|
166
178
|
※CER(Character Error Rate、文字誤り率):0から1までの範囲を取り、0に近いほど高い性能を表すスコア
|
|
167
179
|
|
|
180
|
+
|
|
168
181
|
## モデルの再学習及びカスタマイズについて(開発者向け情報)
|
|
169
182
|
|
|
170
183
|
[学習及びモデル変換手順](/train/README.md)をご覧ください。
|
|
@@ -173,10 +186,12 @@ Maeda, K., & Okazaki, N. JaWildText: A Benchmark for Vision-Language Models on J
|
|
|
173
186
|
|
|
174
187
|
NDLOCR-Liteは「レイアウト認識」、「文字列認識」、「読み順整序」の3つの機能(モジュール)を組み合わせて実現しています。
|
|
175
188
|
|
|
176
|
-
レイアウト認識にはDEIMv2[1]、文字列認識にはPARSeq[2]をそれぞれ用いており、読み順整序については当館が公開している[NDLOCR](https://github.com/ndl-lab/ndlocr_cli)と同様のモジュールを用いています。
|
|
189
|
+
レイアウト認識にはDEIMv2[1]、文字列認識にはPARSeq[2]、表構造認識にはTableCenterNet[3]をそれぞれ用いており、読み順整序については当館が公開している[NDLOCR](https://github.com/ndl-lab/ndlocr_cli)と同様のモジュールを用いています。
|
|
177
190
|
|
|
178
|
-
[1]Shihua Huang and Yongjie Hou and Longfei Liu and Xuanlong Yu and Xi Shen. Real-Time Object Detection Meets DINOv3. arXiv
|
|
191
|
+
[1]Shihua Huang and Yongjie Hou and Longfei Liu and Xuanlong Yu and Xi Shen. Real-Time Object Detection Meets DINOv3. arXiv:2509.20787, 2025.(<https://arxiv.org/abs/2509.20787>)
|
|
179
192
|
|
|
180
193
|
[2]Darwin Bautista, Rowel Atienza. Scene text recognition with permuted autoregressive sequence models. arXiv:2212.06966, 2022. (<https://arxiv.org/abs/2207.06966>)
|
|
181
194
|
|
|
195
|
+
[3]Anyi Xiao and Cihui Yang. TableCenterNet: A one-stage network for table structure recognition. arXiv:2504.17522, 2025. (<https://arxiv.org/abs/2504.17522>)
|
|
196
|
+
|
|
182
197
|
レイアウト認識及び文字列認識の機械学習モデルは、いずれもpytorchをフレームワークとした学習を行った後にONNX形式に変換して利用しています。詳しくは[学習及びモデル変換手順](/train/README.md)をご覧ください。
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
# NDLOCR-Liteアプリケーションのリポジトリ
|
|
2
|
+
**(2026/11/24追記)v2から読書バリアフリー機能を強化しています。また、PyPIによるインストールに対応しています。**
|
|
3
|
+
|
|
2
4
|
**(2026/04/24追記)v1.2から手書き文字の認識等を強化しています。**
|
|
3
5
|
|
|
4
6
|
NDLOCR-Liteを利用してテキスト化を実行するためのアプリケーションを提供するリポジトリです。
|
|
@@ -35,15 +37,12 @@ https://github.com/facebookresearch/dinov3/blob/main/LICENSE.md
|
|
|
35
37
|
|
|
36
38
|
## コマンドラインからの利用
|
|
37
39
|
|
|
38
|
-
※コマンドラインから操作を行うにはPython 3.
|
|
40
|
+
※コマンドラインから操作を行うにはPython 3.11以上が必要です。
|
|
39
41
|
|
|
40
42
|
事前準備
|
|
41
43
|
|
|
42
44
|
```bash
|
|
43
|
-
|
|
44
|
-
cd ndlocr-lite
|
|
45
|
-
pip install -r requirements.txt
|
|
46
|
-
cd src
|
|
45
|
+
pip install ndlocr-lite
|
|
47
46
|
```
|
|
48
47
|
|
|
49
48
|
実行例1.(同階層にある「9892834_0001」という名称のディレクトリ内の画像を一括処理し、tmpdirという名称のディレクトリに結果を出力する。)
|
|
@@ -74,6 +73,18 @@ uv tool install .
|
|
|
74
73
|
ndlocr-lite --sourceimg digidepo_1287221_00000002.jpg --output tmpdir
|
|
75
74
|
```
|
|
76
75
|
|
|
76
|
+
PyPIから導入する場合、現時点のCLI版は開発版のため、`--pre`を指定してください(Python 3.11以上が必要です)。
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install --pre ndlocr-lite
|
|
80
|
+
# uvの場合
|
|
81
|
+
uv tool install --prerelease allow ndlocr-lite
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
pip/uvでインストールする配布物にはONNXモデルを含めません。`ndlocr-lite`の初回OCR実行時に、未指定のモデルを`https://lab.ndl.go.jp/dataset/ndlocr-lite/onnx/v2/`から取得し、SHA-256を検証してユーザーのキャッシュに保存します。初回はネット接続と約157 MBの空き容量が必要です。以降はキャッシュを再利用します。`--help`と`--version`ではダウンロードしません。
|
|
85
|
+
|
|
86
|
+
キャッシュ先はWindowsでは`%LOCALAPPDATA%\ndlocr-lite\models\v2`、macOSでは`~/Library/Caches/ndlocr-lite/models/v2`、Linuxでは`${XDG_CACHE_HOME:-~/.cache}/ndlocr-lite/models/v2`です。各`--*-weights`オプションで指定したファイルはそのまま使用します。GUI版と`python ocr.py`は従来どおり同梱モデルを使用し、ダウンロードしません。
|
|
87
|
+
|
|
77
88
|
### パラメータの説明
|
|
78
89
|
|
|
79
90
|
#### `--sourcedir`オプション
|
|
@@ -123,20 +134,21 @@ OCR結果を保存する出力先ディレクトリを相対パスまたは絶
|
|
|
123
134
|
|
|
124
135
|
[NDLOCR ver.2.1の評価結果](https://lab.ndl.go.jp/data_set/r4ocr/r4_software#5-3-文字認識性能の評価結果)と同様の評価用データセット・同様の評価手法による値です。
|
|
125
136
|
|
|
126
|
-
### 手書き文字に対する評価(NDLOCR-Lite ver.
|
|
137
|
+
### 手書き文字に対する評価(NDLOCR-Lite ver.2.0.0)
|
|
127
138
|
|
|
128
139
|
Maeda, K., & Okazaki, N. JaWildText: A Benchmark for Vision-Language Models on Japanese Scene Text Understanding. arXiv preprint arXiv:2603.27942, 2026.(<https://arxiv.org/abs/2603.27942>)
|
|
129
140
|
|
|
130
141
|
によって作成された[JaWildText(外部サイト)](https://huggingface.co/datasets/llm-jp/jawildtext)のうち、手書き文字データセット1,065画像を用いて評価しました。
|
|
131
142
|
|
|
132
|
-
|
|
143
|
+
全体CER(中央値) : 0.1327 全体F値(中央値) : 0.8927 (対象: 1065 ファイル)
|
|
133
144
|
|
|
134
|
-
|
|
145
|
+
縦書きCER(中央値) : 0.1776 縦書きF値(中央値) : 0.8536 (対象: 295 ファイル)
|
|
135
146
|
|
|
136
|
-
|
|
147
|
+
横書きCER(中央値) : 0.1156 横書きF値(中央値) : 0.9050 (対象: 768 ファイル)
|
|
137
148
|
|
|
138
149
|
※CER(Character Error Rate、文字誤り率):0から1までの範囲を取り、0に近いほど高い性能を表すスコア
|
|
139
150
|
|
|
151
|
+
|
|
140
152
|
## モデルの再学習及びカスタマイズについて(開発者向け情報)
|
|
141
153
|
|
|
142
154
|
[学習及びモデル変換手順](/train/README.md)をご覧ください。
|
|
@@ -145,10 +157,12 @@ Maeda, K., & Okazaki, N. JaWildText: A Benchmark for Vision-Language Models on J
|
|
|
145
157
|
|
|
146
158
|
NDLOCR-Liteは「レイアウト認識」、「文字列認識」、「読み順整序」の3つの機能(モジュール)を組み合わせて実現しています。
|
|
147
159
|
|
|
148
|
-
レイアウト認識にはDEIMv2[1]、文字列認識にはPARSeq[2]をそれぞれ用いており、読み順整序については当館が公開している[NDLOCR](https://github.com/ndl-lab/ndlocr_cli)と同様のモジュールを用いています。
|
|
160
|
+
レイアウト認識にはDEIMv2[1]、文字列認識にはPARSeq[2]、表構造認識にはTableCenterNet[3]をそれぞれ用いており、読み順整序については当館が公開している[NDLOCR](https://github.com/ndl-lab/ndlocr_cli)と同様のモジュールを用いています。
|
|
149
161
|
|
|
150
|
-
[1]Shihua Huang and Yongjie Hou and Longfei Liu and Xuanlong Yu and Xi Shen. Real-Time Object Detection Meets DINOv3. arXiv
|
|
162
|
+
[1]Shihua Huang and Yongjie Hou and Longfei Liu and Xuanlong Yu and Xi Shen. Real-Time Object Detection Meets DINOv3. arXiv:2509.20787, 2025.(<https://arxiv.org/abs/2509.20787>)
|
|
151
163
|
|
|
152
164
|
[2]Darwin Bautista, Rowel Atienza. Scene text recognition with permuted autoregressive sequence models. arXiv:2212.06966, 2022. (<https://arxiv.org/abs/2207.06966>)
|
|
153
165
|
|
|
166
|
+
[3]Anyi Xiao and Cihui Yang. TableCenterNet: A one-stage network for table structure recognition. arXiv:2504.17522, 2025. (<https://arxiv.org/abs/2504.17522>)
|
|
167
|
+
|
|
154
168
|
レイアウト認識及び文字列認識の機械学習モデルは、いずれもpytorchをフレームワークとした学習を行った後にONNX形式に変換して利用しています。詳しくは[学習及びモデル変換手順](/train/README.md)をご覧ください。
|