Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,17 +1,25 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
from parse_bhel_po import extract_po_details # Import
|
| 3 |
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
#
|
| 10 |
interface = gr.Interface(
|
| 11 |
-
fn=
|
| 12 |
-
inputs=
|
| 13 |
-
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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__":
|