File size: 616 Bytes
83c00db
 
 
 
 
 
 
 
 
 
 
da56309
83c00db
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import gradio as gr
from inference import run_ocr

def ocr_ui(image, model_name):
    return run_ocr(image, model_name)

UI = gr.Interface(
        fn=ocr_ui,
        inputs=[
            gr.Image(type="pil", label="Upload Image"),
            gr.Dropdown(
                choices=["tesseract", "trocr"],
                value="tesseract",
                label="OCR Model"
            )
        ],
        outputs=gr.Textbox(lines=10, label="Extracted Text"),
        title="Handwriting Recognition and Translation",
        # description="Switch between classical OCR and Transformer-based OCR."
    )

UI.launch()