CtcDecoder class

Greedy CTC decoder over a fixed character dictionary.

PP-OCR recognizers output, per timestep, a score over a vocabulary whose index 0 is the CTC blank and whose remaining indices map to dictionary (so score index i is dictionary[i - 1]); the final index is conventionally a space. Greedy decoding takes the argmax per timestep, then collapses runs of the same index and drops blanks (§ CTC).

Confidence depends on what the model emits. PaddleOCR's recognition inference model ends in a softmax, so its per-step scores are already probabilities and the kept character's value is its probability directly (this mirrors PaddleOCR's own CTCLabelDecode, which reads the per-step max as the confidence) - that is applySoftmax false, the default. If a model emits raw logits instead, set applySoftmax true so each step is softmaxed before its probability is read; otherwise an unbounded logit would clamp the reported confidence to 1.0 and defeat any min-confidence filter. The decoded text is identical either way (argmax is invariant under softmax) - only the confidence differs.

Constructors

CtcDecoder(List<String> dictionary, {int blankIndex = 0, bool applySoftmax = false})

Properties

applySoftmax → bool
Whether to softmax each timestep before reading the winning class's probability - set this when the model emits raw logits rather than softmax probabilities.
final
blankIndex → int
The vocabulary index reserved for the CTC blank.
final
dictionary → List<String>
Characters for vocabulary indices 1..dictionary.length (index 0 is the blank). Build it from a PP-OCR dict file with parseDictionary.
final
hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

decode(Float32List predictions, int timesteps, int vocab) → CtcResult
Decodes predictions, a timesteps x vocab row-major matrix of the recognizer's per-step scores (probabilities, or logits when applySoftmax).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited