manga-ocr-2025 ONNX with past key values
An ONNX export of jzhang533/manga-ocr-base-2025
(revision 1e64d5beb41ee6bee72c200838ddb93ad541482a). The weights are unchanged. The decoder reuses its
key/value state between steps, so each greedy step processes one new token instead of the whole sequence.
It is used by Yomu.
Files
| file | inputs | outputs |
|---|---|---|
encoder_model.onnx |
pixel_values [1, 3, 224, 224] |
last_hidden_state [1, 197, 192] |
decoder_model_merged.onnx |
input_ids [1, 1], encoder_hidden_states, past_key_values.{0,1}.{decoder,encoder}.{key,value} [1, 12, n, 64], use_cache_branch [1] bool |
logits [1, 1, 6144], present.{0,1}.{decoder,encoder}.{key,value} |
vocab.txt |
the base model's vocabulary |
The first decoder step passes use_cache_branch = false and empty pasts [1, 12, 0, 64]. Later steps pass
true and the previous step's presents. On those steps the encoder presents come back empty, so keep the
first step's. Start from [CLS] (id 2) and stop at [SEP]. Pixels are scaled to 224 × 224 and normalized
as (x / 255 - 0.5) / 0.5.
How it was made
Optimum refuses image-to-text-with-past for a BERT decoder, so the export registers a decoder config
shaped like Optimum's TrOCR one:
scripts/spike-339-export.py. The tools were optimum 2.1.0,
optimum-onnx 0.1.0, transformers 4.57.6, torch 2.14.1, onnx 1.23.2 and onnxruntime 1.31.0.
With greedy decoding, the text matches l0wgear/manga-ocr-2025-onnx (an export without past key values) on
every crop tested.
License
Apache-2.0, the same as the base model. Credit for the model goes to its authors; see the base model card.