File size: 1,013 Bytes
2666f25
51ed507
34c602a
 
51ed507
 
 
 
 
 
 
34c602a
51ed507
34c602a
51ed507
34c602a
51ed507
 
 
34c602a
 
51ed507
34c602a
 
51ed507
 
 
 
 
 
 
 
34c602a
2666f25
34c602a
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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")