ONNX - NDL
| Model | FP32 | Task |
|---|---|---|
| PARSeq-tiny | parseq-tiny_30.onnx, parseq-tiny_50.onnx, parseq-tiny_100.onnx | text recognition (Japanese, vertical and horizontal lines) |
Usage
# onnxruntime-gpu for run it on GPU
pip install onnxruntime opencv-python numpy
Every model folder has the same layout:
src/helper.py= onnx session builder (provider selection, threads, memory options)src/example.py= full pipeline: image preprocess, inference, postprocessonnx/= the model file
Run the commands from the repository root.
Test images used by the examples:
- jp_vert_1.jpg = vertical text block
PARSeq-tiny
python3 PARSeq-tiny/src/example.py jp_vert_1.jpg
0.997674 | ๆฅๆฌ่ชใฎ็ธฆๆธใใๆๅญ
0.999972 | ่ช่ญใงใใใใฉใใใฎ
0.999093 | ใในใใ
Note:
- Input = a single text line, laid horizontally: a vertical column is rotated 90 degrees counter-clockwise first
(the characters lie on their side, that is how the model was trained). - The example reads an image wider than tall as one line. An image taller than wide is taken as a vertical text block:
split into columns on the blank gaps, read from right to left. - Input = RGB image resized to the model size without keeping the aspect ratio, scaled to -1..1, CHW with batch dimension.
- Three models, same network, different line length:
parseq-tiny_30.onnx=[1, 3, 24, 256], up to 30 characters;
parseq-tiny_50.onnx=[1, 3, 24, 384], up to 50 characters;
parseq-tiny_100.onnx=[1, 3, 24, 768], up to 100 characters. - Model choice = start from the shortest one, skip it when the line is too long for it (width / height over its
character count minus 5), read again with the next one when the text fills it. - Output =
[1, count + 1, 7142]raw logits, one row per character: argmax per row, stop at index 0 (end of text). - Character map = index 0 is the end of text, 1..7141 are the lines of
PARSeq-tiny/onnx/dictionary.txt. - Score = mean of the softmax probability of the kept characters.
- onnxruntime prints many
ScatterNDwarnings when these models are loaded: the example silences them with
onnxruntime.set_default_logger_severity(3).