File size: 1,008 Bytes
bed770e 2f71814 9ed4532 bf94d28 1f0bb64 2f71814 87710dc 1f0bb64 2f71814 72f7715 39a6980 1f0bb64 2f71814 bed770e 9ed4532 6a7a011 87710dc 9ed4532 bed770e 2f71814 6a7a011 bf94d28 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
import gradio as gr
import tempfile, shutil, os
import pandas as pd
from pipeline import run_pipeline # your existing pipeline.py
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", # <-- must be 'filepath' to work with your pipeline
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() # enables /api/predict endpoint for API calls
iface.launch(server_name="0.0.0.0", server_port=7860)
|