Spaces:
Runtime error
Runtime error
File size: 795 Bytes
7b71279 c155511 7b71279 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import os
os.system("curl -L -o tensor.pt https://seyarabata.com/633f1312c0c21; sleep 3")
import gradio as gr
import torch
from PIL import Image
from strhub.data.module import SceneTextDataModule
# from strhub.models.utils import load_from_checkpoint, parse_model_args
parseq = torch.load('tensor.pt', map_location=torch.device('cpu')).eval()
img_transform = SceneTextDataModule.get_transform(parseq.hparams.img_size)
def captcha_solver(img):
img = img.convert('RGB')
img = img_transform(img).unsqueeze(0)
logits = parseq(img)
logits.shape
# # Greedy decoding
pred = logits.softmax(-1)
label, confidence = parseq.tokenizer.decode(pred)
return label[0]
demo = gr.Interface(fn=captcha_solver, inputs=gr.inputs.Image(type="pil"), outputs=gr.outputs.Textbox())
demo.launch() |