Downloads · 30 days
8
6% of all-time downloads
KvaytG/trocr-base-printed-onnx
trocr-base-printed-onnx is a image-to-text model from KvaytG. Use it when you need a caption or text from an image. It is set up for optimum. The card lists the license as mit.
This repository contains an optimized ONNX version of the microsoft/trocr-base-printed model. It was exported using the optimum library for faster inference on CPU and GPU.
Downloads · 30 days
8
6% of all-time downloads
All-time downloads
129
Public
Repo size
2.7 GB
Likes
0
Public
Click a slice to open those files.
.onnx2.7 GB · 100%
From the Hugging Face model README
This repository contains an optimized ONNX version of the microsoft/trocr-base-printed model.
It was exported using the optimum library for faster inference on CPU and GPU.
from optimum.onnxruntime import ORTModelForVision2Seq
from transformers import TrOCRProcessor
import torch
model_id = "KvaytG/trocr-base-printed-onnx"
providers = ["CUDAExecutionProvider", "CPUExecutionProvider"] if torch.cuda.is_available() else ["CPUExecutionProvider"]
processor = TrOCRProcessor.from_pretrained(model_id)
model = ORTModelForVision2Seq.from_pretrained(
model_id,
providers=providers,
decoder_file_name="decoder_model.onnx",
decoder_with_past_file_name="decoder_with_past_model.onnx"
)
inputs = processor(images=image, return_tensors="pt").to(device)
generated_ids = model.generate(
inputs.pixel_values,
use_cache=True
)
text = processor.batch_decode(generated_ids, skip_special_tokens=True)
print(text)
Original model by Microsoft.
Licensed under the MIT license.