File size: 531 Bytes
b8f8364
 
 
 
 
3ffa8eb
 
 
9171caa
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
import streamlit as st
from transformers import pipeline
from pathlib import Path
from llama_index import download_loader

st.title("PDF Summarizer")
uploaded_file = st.file_uploader("Upload a PDF file")
if uploaded_file is not None:
    loader = PDFReader()
    documents = loader.load_data(file=Path(uploaded_file.name))
    summarizer = pipeline("summarization", model="facebook/bart-large-cnn")
    summary = summarizer(str(documents[0]), max_length=130, min_length=30, do_sample=False)
    st.write(summary[0]["summary_text"])