| 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() |