Spaces:
Runtime error
Runtime error
Download src/app.py from jayanth-2005/output: direct link, hf CLI and curl.
- Browser
- Download file 1.01 kB
-
https://huggingface.co/spaces/jayanth-2005/output/resolve/main/src/app.py
- Command line
-
hf download hf://spaces/jayanth-2005/output/src/app.py
-
curl -L -o app.py https://huggingface.co/spaces/jayanth-2005/output/resolve/main/src/app.py
1.01 kB
| import streamlit as st | |
| import pandas as pd | |
| import numpy as np | |
| from PIL import Image | |
| from ocr_engine import extract_text | |
| from classifier import classify_invoice | |
| from extractor import extract_fields | |
| from formatter import format_for_ca | |
| from validator import validate | |
| st.set_page_config(page_title="Invoice AI") | |
| st.title("AI Invoice Automation for CA Firms") | |
| uploaded_file = st.file_uploader("Upload Invoice", type=["jpg","png","jpeg"]) | |
| if uploaded_file: | |
| image = Image.open(uploaded_file).convert("RGB") | |
| image_np = np.array(image) | |
| with st.spinner("Running OCR..."): | |
| text = extract_text(image_np) | |
| invoice_type = classify_invoice(text) | |
| extracted = extract_fields(text) | |
| formatted = format_for_ca(extracted, invoice_type) | |
| validated = validate(formatted) | |
| df = pd.DataFrame([validated]) | |
| st.dataframe(df) | |
| df.to_excel("output.xlsx", index=False) | |
| with open("output.xlsx", "rb") as f: | |
| st.download_button("Download Excel", f, "invoice.xlsx") | |