import os import glob import gradio as gr import yaml from utils import load_config, get_args, download_model from ocr import OCR import PIL import numpy as np config = load_config() download_model('inference.pdmodel', config['inference.pdmodel']) download_model('inference.pdiparams', config['inference.pdiparams']) model = OCR(get_args(config['svtr_nums']['params'])) def process_image(image): img = image.convert('RGB') img = np.array(img) val, conf = model(img) return val, conf title = "Interactive demo: SVTR-Tiny" description = "Demo for SVTR-Tiny. The model supports only digit recognition. To use it, simply upload a (single-text line) image or use one of the example images below and click 'submit'. Results will show up in a few seconds." article = "
SVTR: Scene Text Recognition with a Single Visual Model | Github Repo
" demo = gr.Interface(fn=process_image, inputs=gr.inputs.Image(type="pil"), outputs=gr.outputs.Textbox(), title=title, description=description, article=article, examples=glob.glob('examples/*.jpeg')) demo.launch(server_name="0.0.0.0", server_port=7860, debug=True)