import gradio as gr from pp_ocr import inference_img, inference_json title = "基于PP-OCRv3文本识别" description = """ PaddleOCR是百度开源的超轻量级OCR模型库,提供了数十种文本检测、识别模型,旨在打造一套丰富、领先、实用的文字检测、识别模型/工具库。 > 项目地址:PaddleOCR github 地址: https://github.com/PaddlePaddle/PaddleOCR """ with gr.Blocks() as app: gr.Markdown("

" + title + "

") gr.Markdown(description) with gr.Tab("图片"): with gr.Row(): with gr.Column(): img_input = gr.Image() img_btn = gr.Button("识别") with gr.Column(): img_output = gr.Image(label="Result") with gr.Tab("JSON"): with gr.Row(): with gr.Column(): json_input = gr.Image() json_btn = gr.Button("识别") with gr.Column(): json_output = gr.Json(label="Result") img_btn.click(inference_img, inputs=img_input, outputs=img_output) json_btn.click(inference_json, inputs=json_input, outputs=json_output) app.launch()