Downloads · 30 days
7
5% of all-time downloads
Nzyoka19/nyansapo-ocr-trocr-lora_v1
nyansapo-ocr-trocr-lora_v1 is a image-to-text model from Nzyoka19. Use it when you need a caption or text from an image. It is set up for peft. The card lists the license as mit.
Fine-tuned OCR model by Nyansapo built on microsoft/trocr-base-handwritten with LoRA adapters on the decoder.
Downloads · 30 days
7
5% of all-time downloads
All-time downloads
136
Public
Repo size
20.1 MB
Likes
0
Public
Click a slice to open those files.
.safetensors20.1 MB · 86%
From the Hugging Face model README
Fine-tuned OCR model by Nyansapo built on microsoft/trocr-base-handwritten
with LoRA adapters on the decoder.
from transformers import VisionEncoderDecoderModel, TrOCRProcessor
from peft import PeftModel
from PIL import Image
base = VisionEncoderDecoderModel.from_pretrained('microsoft/trocr-base-handwritten')
processor = TrOCRProcessor.from_pretrained('Nzyoka19/nyansapo-ocr-trocr-lora_v1')
base.decoder = PeftModel.from_pretrained(base.decoder, 'Nzyoka19/nyansapo-ocr-trocr-lora_v1')
base.eval()
image = Image.open('image.png').convert('RGB')
pixel_values = processor(images=image, return_tensors='pt').pixel_values
ids = base.generate(pixel_values)
print(processor.batch_decode(ids, skip_special_tokens=True)[0])