Downloads · 30 days
77.4K
9% of all-time downloads
anuashok/ocr-captcha-v3
ocr-captcha-v3 is a machine learning model from anuashok. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
This model is a fine-tuned version of microsoft/trocr-base-printed on Captchas of the type shown below
Downloads · 30 days
77.4K
9% of all-time downloads
All-time downloads
896K
Public
Parameters
334M
1.3 GB on disk
Likes
38
Public
Click a slice to open those files.
.safetensors1.3 GB · 100%
From the Hugging Face model README
This model is a fine-tuned version of microsoft/trocr-base-printed on Captchas of the type shown below


from transformers import VisionEncoderDecoderModel, TrOCRProcessor
import torch
from PIL import Image
# Load model and processor
processor = TrOCRProcessor.from_pretrained("anuashok/ocr-captcha-v3")
model = VisionEncoderDecoderModel.from_pretrained("anuashok/ocr-captcha-v3")
# Load image
image = Image.open('path_to_your_image.jpg').convert("RGB")
# Load and preprocess image for display
image = Image.open(image_path).convert("RGBA")
# Create white background
background = Image.new("RGBA", image.size, (255, 255, 255))
combined = Image.alpha_composite(background, image).convert("RGB")
# Prepare image
pixel_values = processor(combined, return_tensors="pt").pixel_values
# Generate text
generated_ids = model.generate(pixel_values)
generated_text = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(generated_text)