File size: 651 Bytes
0f94953 e84172e 0f94953 e84172e 0f94953 e84172e d153dea |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
import gradio as gr
from craft_hw_ocr import OCR
trocr = OCR.load_TrOCRmodel()
def do_ocr(inp):
img, results = OCR.craft_detection(inp)
bboxes, text = OCR.text_recoginition(img, results, trocr[0], trocr[1])
return OCR.visualize(img, results), text
inputs = gr.inputs.Image()
o1 = gr.outputs.Image()
o2 = gr.outputs.Textbox()
title = "CRAFT-OCR"
description = "OCR of both handwriting and printed text using CRAFT Text detector and TrOCR recoginition"
examples=[['example_1.png'],['example_2.jpg']]
gr.Interface(fn=do_ocr, inputs=inputs, outputs=[o1, o2], title=title, description=description, examples=examples,enable_queue=True).launch()
|