SathvikGanta commited on
Commit
22ebb3e
·
verified ·
1 Parent(s): b6fb9fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -10
app.py CHANGED
@@ -1,17 +1,25 @@
1
  import gradio as gr
2
- from parse_bhel_po import extract_po_details # Import the extraction function from parse_bhel_po.py
3
 
4
- def process_uploaded_pdf(uploaded_file):
5
- # Pass the file-like object directly to extract_po_details
6
- df = extract_po_details(uploaded_file)
7
- return df
 
 
 
 
8
 
9
- # Create a Gradio interface for the application
10
  interface = gr.Interface(
11
- fn=process_uploaded_pdf,
12
- inputs="file", # "file" input type to handle file uploads
13
- outputs="dataframe", # Display the extracted data as a dataframe
14
- title="BHEL PO Details Extraction"
 
 
 
 
15
  )
16
 
17
  if __name__ == "__main__":
 
1
  import gradio as gr
2
+ from parse_bhel_po import extract_po_details # Import directly from parse_bhel_po.py
3
 
4
+ # Define a function to handle file processing based on the selected format
5
+ def process_pdf(uploaded_file, selected_format):
6
+ if selected_format == "BHEL":
7
+ # Use the BHEL parser to extract data
8
+ df = extract_po_details(uploaded_file)
9
+ return df.to_string(index=False)
10
+ else:
11
+ return "Selected format not supported."
12
 
13
+ # Set up Gradio interface
14
  interface = gr.Interface(
15
+ fn=process_pdf,
16
+ inputs=[
17
+ gr.Dropdown(label="Select Format", choices=["BHEL"], value="BHEL"),
18
+ gr.File(label="Upload PDF"),
19
+ ],
20
+ outputs="text",
21
+ title="PO Details Extraction",
22
+ description="Select the format and upload the PO PDF to extract details."
23
  )
24
 
25
  if __name__ == "__main__":