File size: 717 Bytes
9e23cf3
0f2dc3c
 
 
 
 
 
 
 
 
9e23cf3
 
 
 
 
0f2dc3c
9e23cf3
 
 
 
 
0f2dc3c
45c9e03
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import gradio as gr
from pipeline import extract_text_from_pdf, extract_key_values_with_gemini

FIELDS = [
    "Name", "DOB", "Gender", "FatherName", "MotherName",
    "Address", "City", "State", "Pincode", "Mobile", "Email",
    "DocumentType", "DocumentNumber", "IssueAuthority",
    "IssueDate", "ExpiryDate"
]

def process_pdf(file):
    if not file:
        return {"error": "No file uploaded."}
    text = extract_text_from_pdf(file.name)
    return extract_key_values_with_gemini(text, FIELDS)

with gr.Blocks() as demo:
    gr.Markdown("## AutoForm Extractor")
    file_input = gr.File(label="Upload PDF")
    output = gr.JSON()
    file_input.change(process_pdf, file_input, output)

demo.launch(share=True)