ChequeEasy / app.py
shivi's picture
Update app.py
4acf91b
raw
history blame
3.4 kB
import os
import glob
import gradio as gr
from predict_cheque_parser import parse_cheque_with_donut
##Create list of examples to be loaded
example_list = glob.glob("examples/cheque_parser/*")
example_list = list(map(lambda el:[el], example_list))
demo = gr.Blocks()
with demo:
gr.Markdown("# **<p align='center'>ChequeEasy: Banking with Transformers </p>**")
gr.Markdown("ChequeEasy is a project that aims to simplify the process of approval of cheques. Leveraging recent advances in Visual Document Understanding (VDU) domain to extract relevant data from cheques and make the whole process quicker and easier for both bank officials and customers. \
This project leverages Donut model proposed in this <a href=\"https://arxiv.org/abs/2111.15664/\">paper </a> for the parsing of the required data from cheques." \
"Donut is based on a very simple transformer encoder and decoder architecture. It's main USP is that it is an OCR-free approach to information extraction from documents. \
OCR based techniques come with several limitations such as use of additional downstream models, lack of understanding about document structure, use of hand crafted rules,etc. \
Donut helps you get rid of all of these OCR specific limitations. The model for the project has been trained using this <a href=\"https://huggingface.co/datasets/shivi/cheques_sample_data/\"> dataset </a>. This HF dataset is actually a filtered version of this <a href=\"https://www.kaggle.com/datasets/medali1992/cheque-images/\"> kaggle dataset </a>.")
with gr.Tabs():
with gr.TabItem("Cheque Parser"):
gr.Markdown("This module is used to extract details filled by a bank customer from cheques. At present the model is trained to extract details like - payee_name, amount_in_words, amount_in_figures. \
This model can be further trained to parse additional details like micr_code, cheque_number, account_number, etc")
with gr.Box():
gr.Markdown("**Upload Cheque**")
input_image_parse = gr.Image(type='filepath', label="Input Cheque")
with gr.Box():
gr.Markdown("**Parsed Cheque Data**")
payee_name = gr.Textbox(label="Payee Name")
amt_in_words = gr.Textbox(label="Courtesy Amount")
amt_in_figures = gr.Textbox(label="Legal Amount")
cheque_date = gr.Textbox(label="Cheque Date")
amts_matching = gr.Checkbox(label="Legal & Courtesy Amount Matching")
stale_check = gr.Checkbox(label="Stale Cheque")
with gr.Box():
gr.Markdown("**Predict**")
with gr.Row():
parse_cheque = gr.Button("Call Donut 🍩")
with gr.Column():
gr.Examples(example_list, [input_image_parse],
[payee_name,amt_in_words,amt_in_figures,cheque_date],parse_cheque_with_donut,cache_examples=False)
parse_cheque.click(parse_cheque_with_donut, inputs=input_image_parse, outputs=[payee_name,amt_in_words,amt_in_figures,cheque_date,amts_matching,stale_check])
gr.Markdown('\n Solution built by: <a href=\"https://www.linkedin.com/in/shivalika-singh/\">Shivalika Singh</a>')
demo.launch()