YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

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 を指定できます。

Dynamic Batch Patch

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 推論で実際に使っています。

Downloads last month
90
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support