Downloads · 30 days
16
9% of all-time downloads
u-haru/NDLOCR-Lite-HF
NDLOCR-Lite-HF is a machine learning model from u-haru. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
NDLOCR-Lite を Hugging Face の trustremotecode 互換で使えるようにした移植版です。
Downloads · 30 days
16
9% of all-time downloads
All-time downloads
182
Public
Parameters
1
267 MB on disk
Likes
0
Public
Click a slice to open those files.
.onnx267 MB · 100%
From the Hugging Face model README
NDLOCR-Lite を Hugging Face の trust_remote_code 互換で使えるようにした移植版です。
from transformers import AutoModel, pipeline
model = AutoModel.from_pretrained("u-haru/NDLOCR-Lite-HF", trust_remote_code=True)
result = model.predict("/path/to/image.png")
print(result["text"])
batch_result = model.predict(["/path/to/image1.png", "/path/to/image2.png"])
print(batch_result[0]["text"])
ocr = pipeline(
task="ndlocr",
model="u-haru/NDLOCR-Lite-HF",
trust_remote_code=True,
)
print(ocr("/path/to/image.png")["text"])
print(ocr(["/path/to/image1.png", "/path/to/image2.png"])[0]["text"])
複数入力時は、レイアウト検出は複数 DEIM インスタンスで並列処理し、文字認識は画像をまたいで行単位に集約してからカスケード認識します。config.json では max_page_batch_size, max_recognizer_batch_size, detector_workers を指定できます。
PARSEQ の ONNX を dynamic batch 化するスクリプトは tools/patch_parseq_dynamic_batch.py です。
uv run tools/patch_parseq_dynamic_batch.py
これは参考記事
https://note.com/ponpaku/n/n8c2355d1f377
を踏まえた graph surgery です。生成される *_dynamic.onnx は現在の batch 推論で実際に使っています。