File size: 517 Bytes
c1262c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
def summarize_pdf(pdf_path):
    pdf_file = open(pdf_path, 'rb')
    pdf_reader = PyPDF2.PdfReader(pdf_file)
    abstract_text = pdf_reader.pages[0].extract_text()
    summary = summarization(abstract_text, max_length=13, min_length=10)[0]['summary_text']
    pdf_file.close()
    return summary
    
iface = gr.Interface(
    fn=summarize_pdf,
    inputs= "file",
    outputs="text",
    live=True,
    title="PDF Summarizer",
    description="Upload a PDF with an abstract, and the model will generate a summary."
)