irandoc_ocr / src /ui /gradio_ui.py
Alizmoh98's picture
refine ui
b6dc727
raw
history blame contribute delete
603 Bytes
import gradio as gr
from ..processing.parse_img import parse_img
def ui_predict_fn(image):
# Wrapper to format data specifically for Gradio Gallery
_, gallery_items = parse_img(image)
return gallery_items
# Define the Interface/Blocks
with gr.Blocks(title="DocLayout Parser") as gradio_app:
gr.Markdown("## Irandoc OCR")
with gr.Row():
input_img = gr.Image(type="pil", label="Upload Document")
output_gal = gr.Gallery(label="Parsed Regions")
btn = gr.Button("Parse", variant="primary")
btn.click(fn=ui_predict_fn, inputs=input_img, outputs=output_gal)