Spaces:
Sleeping
Sleeping
File size: 1,026 Bytes
d592078 b72ce3f 0c51219 22ebb3e b72ce3f 22ebb3e b72ce3f 22ebb3e b72ce3f 22ebb3e 0c51219 b72ce3f a72072c 22ebb3e a72072c d592078 0c51219 a72072c |
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 |
import gradio as gr
from parse_bhel_po import extract_po_details # Import the BHEL-specific parsing function
def process_pdf(uploaded_file, selected_format):
# Debug: Print the selected format
print(f"[DEBUG] Selected format: {selected_format}")
# Check selected format and process accordingly
if selected_format == "BHEL":
# Use the BHEL parser to extract data
df = extract_po_details(uploaded_file)
# Return as formatted text output
return df.to_string(index=False)
else:
# Return message if format is not recognized
return "Selected format not supported."
# Set up the Gradio interface
interface = gr.Interface(
fn=process_pdf,
inputs=[
gr.Dropdown(label="Select Format", choices=["BHEL"], value="BHEL"),
gr.File(label="Upload PDF"),
],
outputs="text",
title="PO Details Extraction",
description="Select the format and upload the PO PDF to extract details."
)
if __name__ == "__main__":
interface.launch()
|