OCRBase<T>

Base Classes · AiDotNet.ComputerVision.OCR

Base class for OCR models.

Inheritance: ModelBase<T, Tensor<T>, Tensor<T>> → VisionTaskModelBase<T> → OCRBase<T>

Implements: IRecognitionTrainingModel<T>

Known derived types: CRNN<T>, TrOCR<T>

Properties

Property Summary
int MaxSequenceLength { get; } Gets the maximum number of characters the decoder will emit for one text region.
int VocabularySize { get; } Gets the vocabulary size (number of classes).
string CharacterSet { get; } Gets the set of characters this model can emit.
string Name { get; } Name of this OCR model.

Methods

Method Summary
OCRResult<T> Recognize(Tensor<T> image) Recognizes text in an image.
Task LoadWeightsAsync(string pathOrUrl, CancellationToken cancellationToken) Loads pretrained weights.
Tensor<T> Predict(Tensor<T> input) Returns the model’s raw, differentiable recognition output (see ForwardLogits).
ValueTuple<string, T> RecognizeText(Tensor<T> croppedImage) Recognizes text in a cropped text region.
long GetParameterCount() Gets the total parameter count.
void SaveWeights(string path) Saves model weights.
void TrainRecognition(Tensor<T> images, IReadOnlyList<string> transcriptions) One training step on text-line images and their transcriptions, using the model’s own recognition objective (CTC for CRNN, teacher-forced cross-entropy for TrOCR).