Image-to-Text
Transformers
Safetensors
vision-encoder-decoder
image-text-to-text
trocr
ocr
captcha
math-captcha
synthetic-data
Instructions to use arkhabbazan/ocr-match-captcha with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use arkhabbazan/ocr-match-captcha with Transformers:
# Use a pipeline as a high-level helper # Warning: Pipeline type "image-to-text" is no longer supported in transformers v5. # You must load the model directly (see below) or downgrade to v4.x with: # 'pip install "transformers<5.0.0' from transformers import pipeline pipe = pipeline("image-to-text", model="arkhabbazan/ocr-match-captcha")# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("arkhabbazan/ocr-match-captcha") model = AutoModelForMultimodalLM.from_pretrained("arkhabbazan/ocr-match-captcha", device_map="auto") - Notebooks
- Google Colab
- Kaggle
OCR Match Captcha
A TrOCR model fine-tuned to recognize short mathematical captcha
expressions such as 26+7=? and 45-6=?.
![]() |
![]() |
![]() |
![]() |
Model details
- Architecture: Vision Encoder-Decoder / TrOCR
- Base model:
microsoft/trocr-base-printed - Task: Image-to-text OCR
- Target geometry: 130x30 RGB images
- Output: Mathematical expressions without spaces
Training configuration
| Parameter | Value |
|---|---|
| Epochs | 5 |
| Learning rate | 5e-6 |
| Batch size | 8 |
| Gradient accumulation | 2 |
| Operator-token weight | 3.0 |
| Generation beams | 4 |
| Maximum output length | 32 |
Usage
from PIL import Image
from transformers import TrOCRProcessor, VisionEncoderDecoderModel
repo_id = "arkhabbazan/ocr-match-captcha"
processor = TrOCRProcessor.from_pretrained(repo_id, token=True)
model = VisionEncoderDecoderModel.from_pretrained(repo_id, token=True)
image = Image.open("captcha.jpeg").convert("RGB")
pixel_values = processor(images=image, return_tensors="pt").pixel_values
generated_ids = model.generate(pixel_values, num_beams=4, max_length=32)
prediction = processor.batch_decode(
generated_ids, skip_special_tokens=True
)[0]
print(prediction.replace(" ", ""))
Limitations
- Training data is primarily synthetic.
- Unseen fonts and layouts may reduce accuracy.
- The model is intended for short expressions, not document OCR.
- Usage must be authorized and compliant with applicable policies.
- Downloads last month
- 32
Model tree for arkhabbazan/ocr-match-captcha
Base model
microsoft/trocr-base-printed


