Spaces:
Sleeping
Sleeping
| 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) | |