File size: 401 Bytes
0f94953
e84172e
0f94953
e84172e
0f94953
e84172e
 
 
 
 
 
 
 
5f03b05
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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()
gr.Interface(fn=do_ocr, inputs=inputs, outputs=[o1, o2]).launch()