Spaces:
Runtime error
Runtime error
import gradio as gr | |
from PyPDF2 import PdfReader | |
from transformers import pipeline | |
def summarize_pdf_content(files): | |
summarizer = pipeline("summarization", model="stevhliu/my_awesome_billsum_model") | |
summaries = [] | |
for file in files: | |
with open(file.name, "rb") as pdf_file: | |
pdf_reader = PdfReader(pdf_file) | |
text = "" | |
for page in pdf_reader.pages: | |
text += page.extract_text() + "\n" | |
summary = summarizer(text, max_length=50, min_length=10, do_sample=False)[0]['summary_text'] | |
summaries.append(summary) | |
return summaries | |
iface = gr.Interface( | |
fn=summarize_pdf_content, | |
inputs=gr.UploadButton("Click to Upload a PDF", file_types=["pdf"], file_count="multiple"), | |
outputs=gr.Textbox(label="Summarized Text"), | |
title="PDF Summarizer" | |
) | |
iface.launch() |