Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,41 +1,24 @@
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
from ALNISF import process_pdf as process_alnisf
|
3 |
from federal_electric import process_pdf as process_federal_electric
|
4 |
from bhel import process_pdf as process_bhel
|
5 |
|
6 |
-
# Unified function to handle extractors
|
7 |
def process_file(pdf_file, extractor):
|
8 |
-
"""
|
9 |
-
Processes the uploaded PDF using the selected extractor.
|
10 |
-
Args:
|
11 |
-
pdf_file: Uploaded PDF file.
|
12 |
-
extractor: The selected extractor script (ALNISF, Federal Electric, BHEL).
|
13 |
-
Returns:
|
14 |
-
The extracted file and status message.
|
15 |
-
"""
|
16 |
try:
|
17 |
if extractor == "ALNISF":
|
18 |
-
|
19 |
elif extractor == "Federal Electric":
|
20 |
-
|
21 |
elif extractor == "BHEL":
|
22 |
-
|
23 |
else:
|
24 |
return None, "Invalid extractor selected."
|
25 |
-
|
26 |
-
# Validate the output
|
27 |
-
if not output_file:
|
28 |
-
return None, "Processing failed. Please ensure the PDF file is valid."
|
29 |
-
|
30 |
-
return output_file, status
|
31 |
except Exception as e:
|
32 |
return None, f"An error occurred: {str(e)}"
|
33 |
|
34 |
-
# Gradio interface setup
|
35 |
def create_main_interface():
|
36 |
-
"""
|
37 |
-
Creates the main Gradio interface that integrates all extractors.
|
38 |
-
"""
|
39 |
return gr.Interface(
|
40 |
fn=process_file,
|
41 |
inputs=[
|
|
|
1 |
+
# app.py
|
2 |
+
|
3 |
import gradio as gr
|
4 |
from ALNISF import process_pdf as process_alnisf
|
5 |
from federal_electric import process_pdf as process_federal_electric
|
6 |
from bhel import process_pdf as process_bhel
|
7 |
|
|
|
8 |
def process_file(pdf_file, extractor):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
try:
|
10 |
if extractor == "ALNISF":
|
11 |
+
return process_alnisf(pdf_file)
|
12 |
elif extractor == "Federal Electric":
|
13 |
+
return process_federal_electric(pdf_file)
|
14 |
elif extractor == "BHEL":
|
15 |
+
return process_bhel(pdf_file)
|
16 |
else:
|
17 |
return None, "Invalid extractor selected."
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
except Exception as e:
|
19 |
return None, f"An error occurred: {str(e)}"
|
20 |
|
|
|
21 |
def create_main_interface():
|
|
|
|
|
|
|
22 |
return gr.Interface(
|
23 |
fn=process_file,
|
24 |
inputs=[
|