加载中…
加载中…
This model is a fine-tuned version of kazars24/trocr-base-handwritten-ru for recognizing handwritten text in Church Slavonic, Russian and Ukrainian.
TrOCR (Transformer-based OCR) is a vision-to-text model using a ViT encoder and a causal language model decoder. This version is fine-tuned specifically on Church Slavonic, Russian, and Ukrainian handwriting.
| Metric | Value |
|---|---|
| CER (Validation) | 0.253278 |
| Qualitative results | The model performs well despite noisy labels and image distortions. |
Note: Some ground truth annotations were incorrect or mismatched, which affects the overall CER. The model, however, correctly predicts many visually accurate texts.
Decode with no_repeat_ngram_size=0 and max_length=128. The tokenizer splits Cyrillic into single letters or smaller pieces, so a repeat block suppresses ordinary letter sequences that recur within a line. In our tests, decoding without the block gave a lower error rate. A limit of 64 tokens cuts off long lines. In October 2026 both values in generation_config.json were changed (from 3 and 64).
from transformers import TrOCRProcessor, VisionEncoderDecoderModel
from PIL import Image
import requests
# Load processor and model
processor = TrOCRProcessor.from_pretrained("cyrillic-trocr/trocr-handwritten-cyrillic")
model = VisionEncoderDecoderModel.from_pretrained("cyrillic-trocr/trocr-handwritten-cyrillic")
# Load and prepare image
image = Image.open("your_image.jpg").convert("RGB")
pixel_values = processor(images=image, return_tensors="pt").pixel_values
# Generate prediction
generated_ids = model.generate(pixel_values, num_beams=4, no_repeat_ngram_size=0, max_length=128)
predicted_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(predicted_text)