Update app.py
Browse files
app.py
CHANGED
|
@@ -6,19 +6,12 @@ from pipeline import run_pipeline
|
|
| 6 |
DATASET_PATH = "dataset.csv"
|
| 7 |
|
| 8 |
def analyze_pdfs_gradio(files):
|
| 9 |
-
"""
|
| 10 |
-
files: list of uploaded PDFs
|
| 11 |
-
"""
|
| 12 |
with tempfile.TemporaryDirectory() as tmpdirname:
|
| 13 |
-
file_paths = []
|
| 14 |
for file in files:
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
shutil.copyfileobj(file, f)
|
| 18 |
-
file_paths.append(file_path)
|
| 19 |
|
| 20 |
results = run_pipeline(tmpdirname)
|
| 21 |
-
json_result = results.to_dict(orient="records")
|
| 22 |
|
| 23 |
if os.path.exists(DATASET_PATH):
|
| 24 |
dataset = pd.read_csv(DATASET_PATH)
|
|
@@ -29,13 +22,12 @@ def analyze_pdfs_gradio(files):
|
|
| 29 |
dataset.to_csv(DATASET_PATH, index=False)
|
| 30 |
return results
|
| 31 |
|
| 32 |
-
# Corrected Gradio UI
|
| 33 |
iface = gr.Interface(
|
| 34 |
fn=analyze_pdfs_gradio,
|
| 35 |
-
inputs=gr.File(file_types=[".pdf"], type="
|
| 36 |
outputs=gr.Dataframe(type="pandas", label="SC API Results"),
|
| 37 |
title="SC API",
|
| 38 |
-
description="Upload PDFs and get SC scores."
|
| 39 |
)
|
| 40 |
|
| 41 |
if __name__ == "__main__":
|
|
|
|
| 6 |
DATASET_PATH = "dataset.csv"
|
| 7 |
|
| 8 |
def analyze_pdfs_gradio(files):
|
|
|
|
|
|
|
|
|
|
| 9 |
with tempfile.TemporaryDirectory() as tmpdirname:
|
|
|
|
| 10 |
for file in files:
|
| 11 |
+
dest = os.path.join(tmpdirname, os.path.basename(file))
|
| 12 |
+
shutil.copy(file, dest)
|
|
|
|
|
|
|
| 13 |
|
| 14 |
results = run_pipeline(tmpdirname)
|
|
|
|
| 15 |
|
| 16 |
if os.path.exists(DATASET_PATH):
|
| 17 |
dataset = pd.read_csv(DATASET_PATH)
|
|
|
|
| 22 |
dataset.to_csv(DATASET_PATH, index=False)
|
| 23 |
return results
|
| 24 |
|
|
|
|
| 25 |
iface = gr.Interface(
|
| 26 |
fn=analyze_pdfs_gradio,
|
| 27 |
+
inputs=gr.File(file_types=[".pdf"], type="filepath", label="Upload PDF(s)", file_count="multiple"),
|
| 28 |
outputs=gr.Dataframe(type="pandas", label="SC API Results"),
|
| 29 |
title="SC API",
|
| 30 |
+
description="Upload PDFs and get SC scores."
|
| 31 |
)
|
| 32 |
|
| 33 |
if __name__ == "__main__":
|