t5-summarizer / app.py
MrGanesh's picture
Update app.py
9b3a84b
import streamlit as st
from transformers import pipeline
@st.cache(allow_output_mutation=True)
def load_summarizer():
summarizer = pipeline("summarization", model="pszemraj/long-t5-tglobal-base-16384-booksum-V11-big_patent-V2")
return summarizer
summarize = load_summarizer()
st.title("Patent Text Summarizer")
sentence = st.text_area('Please paste your Patent Text :', height=300)
button = st.button("Summarize")
#max = st.sidebar.slider('Select max', 50, 500, step=10, value=500)
#min = st.sidebar.slider('Select min', 10, 100, step=10, value=100)
#do_sample = st.sidebar.checkbox("Do sample", value=False)
with st.spinner("Generating Patent Summary.."):
if button and sentence:
#chunks = generate_chunks(sentence)
res = summarize(sentence,
max_length=500,
min_length=100,
truncation=True,
#do_sample=do_sample
)
text = ' '.join([summ['summary_text'] for summ in res])
# st.write(result[0]['summary_text'])
st.write(text)