Sobes.tech
Middle — Senior

What is CTC loss in OCR?

sobes.tech AI

Answer from AI

CTC loss (Connectionist Temporal Classification) is a loss function widely used in sequence recognition tasks such as OCR (optical character recognition), where the alignment between input data and the target sequence is unknown.

In OCR, the model receives a sequence of features (for example, from an image of text), and the target sequence is the text to be recognized. The problem is that the length of the input sequence and the length of the text do not match, and it is unknown which parts of the input correspond to which characters.

CTC loss solves this problem by allowing the model to predict a sequence with possible blank symbols, and automatically computes the probability of all possible alignments between the input and the target sequence. This enables training the model without explicit alignment annotations.

Example of application:

  • The model outputs probabilities for each symbol (including blank) at each time step.
  • CTC loss sums the probabilities of all paths that can lead to the target sequence and minimizes the negative log of this sum.

Thus, CTC loss allows efficient training of models for text recognition where the exact alignment between input and output is unknown.