from typing import List import pytesseract from PIL import Image import gradio as gr def tesseract_ocr(filepath: str, languages: List[str] = None): if not languages: languages = ['eng'] image = Image.open(filepath) lang_param = '+'.join(languages) return pytesseract.image_to_string(image=image, lang=lang_param) title = "Tesseract OCR" description = "Gradio demo for Tesseract. Tesseract is an open source text recognition (OCR) Engine." article = "
Tesseract documentation | Github Repo
" examples = [ ["examples/weird_unicode_math_symbols.png", []], ["examples/eurotext.png", ["eng"]], ["examples/tesseract_sample.png", ["jpn", "eng"]], ["examples/chi.jpg", ["chi_sim", "chi_tra"]], ] with gr.Blocks(title=title) as demo: gr.Markdown(f'