INVOICE / app.py
Anh1211's picture
Upload 4 files
3dd7866 verified
Raw
History Blame Contribute Delete
805 Bytes
import streamlit as st
from extractor import ocr_document, extract_fields
st.set_page_config(page_title="InvoiceExtract", layout="centered")
st.title("🧾 InvoiceExtract — OCR + Extraction")
file = st.file_uploader("Upload une facture (PDF ou image)", type=["pdf", "png", "jpg", "jpeg"])
if file:
file_bytes = file.read()
is_pdf = file.type == "application/pdf"
with st.spinner("Analyse OCR en cours..."):
text, images_to_show = ocr_document(file_bytes, is_pdf)
if images_to_show:
st.image(images_to_show[0], caption="Aperçu du document", use_container_width=True)
st.subheader("Données Extraites (JSON)")
data = extract_fields(text)
st.json(data) # [cite: 15, 26]
with st.expander("Voir le texte brut (OCR)"):
st.text(text) # [cite: 17]