Image-to-Text
PyTorch
Azerbaijani
ocr
azerbaijani
cyrillic
crnn
ctc
azerbaijani-ocr-crnn / example.py
vrashad's picture
Add Azerbaijani CRNN line recogniser
62067c9 verified
Raw History Blame Contribute Delete
406 Bytes
"""Minimal usage example."""
import torch
from PIL import Image
from huggingface_hub import hf_hub_download
from modeling import load, preprocess, ctc_greedy
path = hf_hub_download("LocalDoc/azerbaijani-ocr-crnn", "model.pt")
model, itos = load(path)
img = Image.open("line.png") # crop of ONE text line
with torch.no_grad():
logits = model(preprocess(img))
print(ctc_greedy(logits, itos))