|
|
import gradio as gr |
|
|
import tempfile, shutil, os |
|
|
import pandas as pd |
|
|
from pipeline import run_pipeline |
|
|
|
|
|
def analyze_pdfs_gradio(files): |
|
|
"""Process multiple PDFs and return SC API results.""" |
|
|
with tempfile.TemporaryDirectory() as tmpdirname: |
|
|
for file in files: |
|
|
dest = os.path.join(tmpdirname, os.path.basename(file)) |
|
|
shutil.copy(file, dest) |
|
|
|
|
|
results = run_pipeline(tmpdirname) |
|
|
return results |
|
|
|
|
|
iface = gr.Interface( |
|
|
fn=analyze_pdfs_gradio, |
|
|
inputs=gr.File( |
|
|
type="filepath", |
|
|
file_types=[".pdf"], |
|
|
file_count="multiple", |
|
|
label="Upload PDF(s)" |
|
|
), |
|
|
outputs=gr.Dataframe(type="pandas", label="SC API Results"), |
|
|
title="SC API", |
|
|
description="Upload PDFs and get SC scores." |
|
|
) |
|
|
|
|
|
if __name__ == "__main__": |
|
|
iface.queue() |
|
|
iface.launch(server_name="0.0.0.0", server_port=7860) |
|
|
|