Table of Contents

Class CRNN<T>

Namespace
AiDotNet.ComputerVision.OCR.Recognition
Assembly
AiDotNet.dll

CRNN (Convolutional Recurrent Neural Network) for text recognition.

public class CRNN<T> : OCRBase<T>

Type Parameters

T

The numeric type used for calculations.

Inheritance
CRNN<T>
Inherited Members

Remarks

For Beginners: CRNN combines CNNs for visual feature extraction with RNNs (specifically LSTM) for sequence modeling. It's trained with CTC loss to handle variable-length text without requiring character-level alignment.

Key features: - CNN backbone for visual features - Bidirectional LSTM for sequence modeling - CTC (Connectionist Temporal Classification) decoding - Handles variable-length text naturally

Reference: Shi et al., "An End-to-End Trainable Neural Network for Image-based Sequence Recognition and Its Application to Scene Text Recognition", TPAMI 2017

Constructors

CRNN(OCROptions<T>)

Creates a new CRNN text recognizer.

public CRNN(OCROptions<T> options)

Parameters

options OCROptions<T>

Properties

Name

Name of this OCR model.

public override string Name { get; }

Property Value

string

Methods

GetParameterCount()

Gets the total parameter count.

public override long GetParameterCount()

Returns

long

LoadWeightsAsync(string, CancellationToken)

Loads pretrained weights.

public override Task LoadWeightsAsync(string pathOrUrl, CancellationToken cancellationToken = default)

Parameters

pathOrUrl string
cancellationToken CancellationToken

Returns

Task

Recognize(Tensor<T>)

Recognizes text in an image.

public override OCRResult<T> Recognize(Tensor<T> image)

Parameters

image Tensor<T>

Input image tensor [batch, channels, height, width].

Returns

OCRResult<T>

OCR result with recognized text.

RecognizeText(Tensor<T>)

Recognizes text in a cropped text region.

public override (string text, T confidence) RecognizeText(Tensor<T> croppedImage)

Parameters

croppedImage Tensor<T>

Cropped text region tensor.

Returns

(string Label, T Confidence)

Recognized text and confidence.

SaveWeights(string)

Saves model weights.

public override void SaveWeights(string path)

Parameters

path string