Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from pipeline import extract_text_from_pdf, extract_key_values_with_gemini, FORMS
|
| 3 |
+
|
| 4 |
+
def process(pdf_file, form_type):
|
| 5 |
+
text = extract_text_from_pdf(pdf_file.name)
|
| 6 |
+
result = extract_key_values_with_gemini(text, form_type=form_type)
|
| 7 |
+
return result
|
| 8 |
+
|
| 9 |
+
iface = gr.Interface(
|
| 10 |
+
fn=process,
|
| 11 |
+
inputs=[
|
| 12 |
+
gr.File(label="Upload Document (PDF only)"),
|
| 13 |
+
gr.Dropdown(choices=list(FORMS.keys()), value="pancard_form", label="Form Type")
|
| 14 |
+
],
|
| 15 |
+
outputs="json",
|
| 16 |
+
title="🧾 AutoFill Form Extractor",
|
| 17 |
+
description="Upload a document and extract structured fields using OCR + Gemini LLM"
|
| 18 |
+
)
|
| 19 |
+
|
| 20 |
+
iface.launch()
|