TrOCR
Use Microsoft's TrOCR for text recognition on a Dedicated Deployment or self-hosted Inference
Code sample
3
Run the model
import base64
import os
import cv2
import requests
import supervision as sv
URL = "https://your-deployment.roboflow.cloud"
image = sv.load_image_from_url("https://media.roboflow.com/inference/license_plate_1.jpg")
_, buffer = cv2.imencode(".jpg", image)
image_base64 = base64.b64encode(buffer).decode("utf-8")
response = requests.post(
f"{URL}/ocr/trocr",
json={
"api_key": os.environ["ROBOFLOW_API_KEY"],
"image": {"type": "base64", "value": image_base64},
},
)
print(response.json()["result"])TOTALInference speed
Model
Latency (ms)
Use with Inference (self-hosted)
Last updated
Was this helpful?