zenoda's picture
Update README.md
b82e30b
metadata
datasets:
  - zenoda/trocr-captcha-killer
language:
  - en
  - zh

accuracy: 0.937338

from transformers import VisionEncoderDecoderModel, TrOCRProcessor
from PIL import Image
import requests

processor = TrOCRProcessor.from_pretrained("zenoda/trocr-captcha-killer")
model = VisionEncoderDecoderModel.from_pretrained("zenoda/trocr-captcha-killer")
model.to('cuda')
url = 'https://huggingface.co/datasets/zenoda/trocr-captcha-killer/resolve/main/106-1688354008849.png'
image = Image.open(requests.get(url, stream=True).raw).convert("RGB")
generated_ids = model.generate(processor(image, return_tensors="pt").pixel_values.to('cuda'))
predictText = processor.batch_decode(generated_ids, skip_special_tokens=True)[0]
print(predictText)