Spaces:
Runtime error
Runtime error
File size: 1,328 Bytes
b4f1e0d b1ba1ed b4f1e0d b1ba1ed b4f1e0d b1ba1ed b4f1e0d b1ba1ed b4f1e0d b1ba1ed |
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 38 39 40 |
import gradio as gr
import pandas as pd
from utils import create_docs
def process_invoices(file_list):
if not file_list:
return "No files uploaded. Please upload at least one PDF invoice.", None
try:
df = create_docs(file_list)
if not isinstance(df, pd.DataFrame):
return "Error: The extracted data is not in the expected format.", None
if df.empty:
return "No data extracted from the PDFs.", None
return "Data extraction completed! 🎉", df
except Exception as e:
return f"Error processing PDFs: {str(e)}", None
demo = gr.Interface(
fn=process_invoices,
inputs=gr.File(
file_types=[".pdf"],
file_count="multiple",
label="Upload PDF invoices"
),
outputs=[
gr.Textbox(label="Status"),
gr.Dataframe(label="Extracted Invoice Data")
],
title="Invoice Extraction Bot 🤖",
description="Upload your PDF invoices to extract key information like invoice number, date, items, totals, and contact info.",
allow_flagging="never"
)
if __name__ == "__main__":
demo.launch(
server_name="0.0.0.0", # Bind to all interfaces for local deployment
server_port=7860, # Default Gradio port
show_error=True # Show detailed errors in the UI
) |