Skip to content
ModelListedExternal
Download

Resnet18 Crnn Ocr

This repository hosts a lightweight, high-performance Convolutional Recurrent Neural Network (CRNN) using a ResNet18 backbone for sequence-based handwritten text recognition (OCR). The model is optimized for...

KindOtherVersionModel18 crnn ocrCgrade

Model source

Kind
Other
File size
55.9 MB
Version
vModel18 crnn ocr
Updated
Oct 23, 2026
Source
Hugging Face

Source description

ResNet18-CRNN Handwritten Text Recognition

This repository hosts a lightweight, high-performance Convolutional Recurrent Neural Network (CRNN) using a ResNet18 backbone for sequence-based handwritten text recognition (OCR). The model is optimized for processing line-level handwriting imagery and maps visual patterns directly to text strings using Connectionist Temporal Classification (CTC) decoding.

Model Architecture Details

The model leverages a custom CNN-RNN hybrid architecture designed for sequence extraction:

  • Backbone: ResNet18 (ImageNet pre-trained).
    • Modification: To preserve spatial sequences, downsampling in layer3 and layer4 was modified (strides adjusted to (2, 1) and (1, 1)).
    • Freezing: conv1, bn1, layer1, and layer2 were frozen during training to retain low-level feature extraction capabilities.
  • Sequence Mapping: A custom SeqToMap linear projection compresses the feature maps to 256 dimensions.
  • Recurrent Layers: A 2-layer Bidirectional LSTM (Hidden Size: 256, Dropout: 0.5) captures contextual character dependencies.
  • Classifier: Fully connected layer outputting 80 unique character classes (plus the CTC blank token).

Training Configuration & Hyperparameters

The model was trained utilizing a highly optimized pipeline:

  • Hardware: Multi-GPU supported setup.
  • Epochs: 40
  • Batch Size: 128
  • Optimizer: Adam
  • Learning Rate: Initial 0.0006, utilizing a CosineAnnealingLR scheduler decaying to a minimum of 0.000003.
  • Loss Function: CTCLoss (zero_infinity=True).
  • Input Resolution: Images scaled dynamically in width, with a fixed height of 96px.

Data Augmentation Pipeline

To ensure robust generalization against varying handwriting styles and scan qualities, the following augmentations were applied during training:

  • Random Affine: Slight rotations (±2°), translations (2%), and scaling (95%-105%).
  • Color Jitter: Brightness and contrast variations (±20%).
  • Gaussian Blur: Applied with a 30% probability to simulate out-of-focus scans.
  • Normalization: Standard ImageNet mean and standard deviation.

Training Metrics & Performance

The model shows robust generalization and steep error reduction over the 40-epoch training horizon.

Evaluation Summary

MetricFinal Value
Train Loss0.2461
Test Loss0.4371
Train Character Error Rate (CER)6.67%
Test Character Error Rate (CER)11.48%

Convergence Curves

Loss Performance

Loss Progression

Character Error Rate (CER) Convergence

CER Progression


Qualitative Sample Predictions

The following visual samples display the original target text lines along with their respective ground truth labels, predicted text, and calculated Character Error Rates (CER).

Perfect Match Samples (CER: 0.000)

Sample 1

Sample 2

Close Approximation Samples (CER: 0.075)

Sample 3

Sample 4

Sources

1 source
Hugging FacePrimaryVersion b619416da0ee0c20d877f3e1f058259c42c8775b
huggingface.co/Shad0wKillar/resnet18-crnn-ocr/tree/b619416da0ee0c20d877f3e1f058259c42c8775b

Verified Oct 23

Model artifacts

1 artifact

model18_crnn_ocr.pth

pth · 55.9 MB · SHA-256 2ebc0fc83e61…bf28 · Hugging Face

Download file

Source excerpts

2 excerpts

--- language: en license: mit pipeline_tag: image-to-text tags: - ocr - crnn - resnet18 - pytorch - handwritten-text-recognition - ctc metrics: - cer --- # ResNet18-CRNN Handwritten Text Recognition This repository hosts a lightweight, high-performance Convolutional Recurrent Neural Network (CRNN) using a **ResNet18** backbone for sequence-based handwritten text recognition (OCR). The model is optimized for processing line-level handwriting imagery and maps visual patterns directly to text strings using Connectionist Temporal Classification (CTC) decoding. ## Model Architecture Details The model leverages a custom CNN-RNN hybrid architecture designed for sequence extraction: - **Backbone:** ResNet18 (ImageNet pre-trained). - *Modification:* To preserve spatial sequences, downsampling in `layer3` and `layer4` was modified (strides adjusted to `(2, 1)` and `(1, 1)`). - *Freezing:* `conv1`, `bn1`, `layer1`, and `layer2` were frozen during training to retain low-level feature extraction capabilities. - **Sequence Mapping:** A custom `SeqToMap` linear projection compresses the feature maps to 256 dimensions. - **Recurrent Layers:** A 2-layer Bidirectional LSTM (Hidden Size: 256, Dropout: 0.5) captures contextual character dependencies. - **Classifier:** Fully connected layer outputting 80 unique character classes (plus the CTC blank token). --- ## Training Configuration & Hyperparameters The model was trained utilizing a highly optimized pipeline: - **Hardware:** Multi-GPU supported setup. - **Epochs:** 40 - **Batch Size:** 128 - **Optimizer:** Adam - **Learning Rate:** Initial `0.0006`, utilizing a `CosineAnnealingLR` scheduler decaying to a minimum of `0.000003`. - **Loss Function:** `CTCLoss` (zero_infinity=True). - **Input Resolution:** Images scaled dynamically in width, with a fixed height of `96px`. ### Data Augmentation Pipeline To ensure robust generalization against varying handwriting styles and scan qualities, the following augmentations were applied during training: - **Random Affine:** Slight rotations (±2°), translations (2%), and scaling (95%-105%). - **Color Jitter:** Brightness and contrast variations (±20%). - **Gaussian Blur:** Applied with a 30% probability to simulate out-of-focus scans. - **Normalization:** Standard ImageNet mean and standard deviation. --- ## Training Metrics & Performance The model shows robust generalizati...

Source context: 0 downloads · 0 likes · Pipeline image-to-text · Repo Shad0wKillar/resnet18-crnn-ocr