Downloads · 30 days
36
14% of all-time downloads
arkhabbazan/ocr-math-captcha
ocr-math-captcha is a image-to-text model from arkhabbazan. Use it when you need a caption or text from an image. It is set up for transformers.
A TrOCR model fine-tuned to recognize short mathematical captcha expressions such as 26+7=? and 45-6=?.
Downloads · 30 days
36
14% of all-time downloads
All-time downloads
259
Public
Parameters
334M
5.5 GB on disk
Likes
2
Public
Click a slice to open those files.
.onnx2.8 GB · 68%
From the Hugging Face model README
A TrOCR model fine-tuned to recognize short mathematical captcha
expressions such as 26+7=? and 45-6=?.
microsoft/trocr-base-printed| 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 |
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(" ", ""))