Views
No views yet
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 |
1from PIL import Image
2from transformers import TrOCRProcessor, VisionEncoderDecoderModel
3
4repo_id = "arkhabbazan/ocr-match-captcha"
5processor = TrOCRProcessor.from_pretrained(repo_id, token=True)
6model = VisionEncoderDecoderModel.from_pretrained(repo_id, token=True)
7
8image = Image.open("captcha.jpeg").convert("RGB")
9pixel_values = processor(images=image, return_tensors="pt").pixel_values
10generated_ids = model.generate(pixel_values, num_beams=4, max_length=32)
11prediction = processor.batch_decode(
12 generated_ids, skip_special_tokens=True
13)[0]
14print(prediction.replace(" ", ""))