Spaces:
Sleeping
Sleeping
Download app.py from Aadityaramrame/AutoForm: direct link, hf CLI and curl.
- Browser
- Download file 717 Bytes
-
https://huggingface.co/spaces/Aadityaramrame/AutoForm/resolve/main/app.py
- Command line
-
hf download hf://spaces/Aadityaramrame/AutoForm/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Aadityaramrame/AutoForm/resolve/main/app.py
717 Bytes
| 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) | |