zaka-zaka / app.py
1javid's picture
Update app.py
9171caa
raw
history blame contribute delete
531 Bytes
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"])