Downloads · 30 days
1.9K
2% of all-time downloads
kazars24/trocr-base-handwritten-ru
trocr-base-handwritten-ru is a image-to-text model from kazars24. Use it when you need a caption or text from an image. It is set up for transformers.
TrOCR model by microsoft fine-tuned on the Cyrillic Handwriting Dataset. The original model was introduced in the paper TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models by Li et al.
Downloads · 30 days
1.9K
2% of all-time downloads
All-time downloads
114K
Public
Parameters
334M
1.3 GB on disk
Likes
18
Public
Click a slice to open those files.
.safetensors1.3 GB · 100%
From the Hugging Face model README
TrOCR model by microsoft fine-tuned on the Cyrillic Handwriting Dataset. The original model was introduced in the paper TrOCR: Transformer-based Optical Character Recognition with Pre-trained Models by Li et al.
The TrOCR model is an encoder-decoder model, consisting of an image Transformer as encoder, and a text Transformer as decoder. The image encoder was initialized from the weights of BEiT, while the text decoder was initialized from the weights of RoBERTa.
Images are presented to the model as a sequence of fixed-size patches (resolution 16x16), which are linearly embedded. One also adds absolute position embeddings before feeding the sequence to the layers of the Transformer encoder. Next, the Transformer text decoder autoregressively generates tokens.
Here is how to use this model in PyTorch:
from transformers import TrOCRProcessor, VisionEncoderDecoderModel
from PIL import Image
import requests
image = Image.open("<image file path or url>").convert("RGB")
processor = TrOCRProcessor.from_pretrained('kazars24/trocr-base-handwritten-ru')
model = VisionEncoderDecoderModel.from_pretrained('kazars24/trocr-base-handwritten-ru')
pixel_values = processor(images=image, return_tensors="pt").pixel_values
generated_ids = model.generate(pixel_values)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
Cyrillic Handwriting Dataset for OCR tasks, which is composed of 73830 segments of handwriting texts (crops) in Russian and splited into train, and test sets with a split of 95%, 5%, respectively. The dataset is provided by SHIFT Lab CFT.
For more information see Explore Cyrillic Handwriting Dataset notebook.
Number of training examples: 57827
Number of validation examples: 14457
5 epochs and default hyperparameters.
Character error rate (CER)
Training Loss: 0.026100
Validation Loss: 0.120961
CER: 0.048542