File size: 1,106 Bytes
caa7fed
 
 
 
 
4931916
caa7fed
 
 
 
 
 
 
 
 
 
 
 
 
 
9b3a84b
3a8f344
caa7fed
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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)