File size: 938 Bytes
a2d9609
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import easyocr
import gradio as gr
from PIL import Image

reader = easyocr.Reader(['en'])

def inference(img_path, width_ths):
    output = reader.readtext(img_path, detail=0, slope_ths=0.7, ycenter_ths=0.9,
                          height_ths=0.8, width_ths=width_ths, add_margin=0.2)

    output = "\n".join(output)

title = "Receipt RAG"
description = "A simple Gradio interface to query receipts using RAG"
examples = [["data/receipt_00000.JPG", 7.7],
            ["data/receipr_00001.jpg", 7.7]]

demo = gr.Interface(inference, 
                    inputs = [gr.Image(width=320, height=320, label="Input Receipt"), 
                              gr.Slider(0, 10, 7.7, 0.1, label="Width Threshold to merge bounding boxes")],
                    outputs= [gr.Textbox(label="OCR Output", type="text")],
                    title=title,
                    description=description,
                    examples=examples)

demo.launch()