import gradio as gr from pipeline import extract_info_batch, extract_reimbursement_form_info, extract_medical_info, extract_medical_info_batch from PIL import Image with gr.Blocks() as demo: with gr.Tabs(): with gr.Tab("Receipts Upload"): with gr.Row(): with gr.Column(scale=2): batch_img_input = gr.File( file_types=["image"], label="Batch Image Upload", elem_id="batch-upload-img", show_label=True, file_count="multiple" ) with gr.Column(scale=2): gr.Markdown("## Receipt Reimbursement Portal") batch_output_box = gr.Markdown( value="Upload Images to extract information", label="Batch Extracted Info", elem_id="batch-output-box", show_label=True ) batch_img_input.change( fn=extract_info_batch, inputs=batch_img_input, outputs=batch_output_box ) with gr.Tab("Reimbursement Forms"): with gr.Row(): with gr.Column(scale=2): reimbursement_img_input = gr.File( file_types=["image"], label="Batch Image Upload", elem_id="batch-upload-img", show_label=True, file_count="multiple" ) with gr.Column(scale=2): # Dropdown for form names gr.Markdown("## Reimbursement Forms") form_name = gr.Dropdown(choices=["Child Fee Reimbursement Form", "Internet Charges Form", "Mobile Reimbursement Form"], interactive=True, multiselect=False) # 2x2 grid for info fields with gr.Row(): emp_name = gr.Textbox(label="Employee Name") emp_code = gr.Textbox(label="Employee Code") with gr.Row(): department = gr.Textbox(label="Department") upload_btn = gr.Button("Upload and Process") preview_output = gr.File(label="Download Filled Form") upload_btn.click( fn=extract_reimbursement_form_info, inputs=[reimbursement_img_input, emp_name, emp_code, department,form_name], outputs=preview_output ) with gr.Tab("Medical Reimbursement Form"): with gr.Row(): with gr.Column(scale=2): medical_img_input = gr.File( label="Upload Medical Form Images (Multiple Allowed)", file_count="multiple", file_types=["image"], elem_id="medical-upload-img-batch", show_label=True ) with gr.Column(scale=2): with gr.Row(): med_company_name = gr.Dropdown(choices=["NetSol Technologies Ltd.","NetSol Innovation Private Ltd."], interactive=True, multiselect=False) med_emp_name = gr.Textbox(label="Employee Name") med_department = gr.Textbox(label="Department") with gr.Row(): med_designation = gr.Textbox(label="Designation") med_ext_code = gr.Textbox(label="Extention No.") med_emp_code = gr.Textbox(label="Employee Code") medical_upload_btn = gr.Button("Upload and Process Batch") preview_medical_output = gr.File(label="Download Consolidated Form (HTML)") medical_upload_btn.click( fn=extract_medical_info_batch, inputs=[medical_img_input,med_emp_name,med_emp_code,med_department,med_designation,med_company_name,med_ext_code], outputs=preview_medical_output ) # CSS: gr.HTML(""" """) demo.launch()