Downloads · 30 days
0
ml6team/mgp-str-onnx
mgp-str-onnx is a machine learning model from ml6team. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
This is an ONNX export of the MGP-STR model for text recognition.
Downloads · 30 days
0
Access
Public
Updated Aug 3, 2023
Repo size
592 MB
Likes
0
Public
Click a slice to open those files.
.onnx592 MB · 100%
From the Hugging Face model README
This is an ONNX export of the MGP-STR model for text recognition.
It can be run as follows:
import onnxruntime as ort
from transformers import MgpstrProcessor
processor = MgpstrProcessor.from_pretrained("alibaba-damo/mgp-str-base")
mpg_str_onnx = hf_hub_download(repo_id="ml6team/mgp-str-onnx", filename="mgp-str.onnx", repo_type="model")
providers = [('CUDAExecutionProvider', {"cudnn_conv_algo_search": "DEFAULT"}), 'CPUExecutionProvider'] if ort.get_device() == 'GPU' else ['CPUExecutionProvider']
session = ort.InferenceSession(
mpg_str_onnx, providers=providers,
)
image = Image.open("path_to_your_image")convert("RGB")
pixel_values = processor(images=image, return_tensors="pt").pixel_values
inputs = {"pixel_values": pixel_values.numpy()}
warmup = mgp_str_session.run(None, inputs)
outputs = session.run(None, inputs)
outputs = [torch.tensor(i) for i in outputs]
out_strs = processor.batch_decode(tuple(outputs))
print(out_strs["generated_text"])