Spaces:
Runtime error
Runtime error
Create new file
Browse files
app.py
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
from transformers import pipeline
|
3 |
+
|
4 |
+
@st.cache(allow_output_mutation=True)
|
5 |
+
def load_summarizer():
|
6 |
+
summarizer = pipeline("summarization", model="google/bigbird-pegasus-large-bigpatent")
|
7 |
+
return summarizer
|
8 |
+
|
9 |
+
summarize = load_summarizer()
|
10 |
+
st.title("Patent Text Summarizer")
|
11 |
+
sentence = st.text_area('Please paste your Patent Text :', height=300)
|
12 |
+
button = st.button("Summarize")
|
13 |
+
|
14 |
+
#max = st.sidebar.slider('Select max', 50, 500, step=10, value=500)
|
15 |
+
#min = st.sidebar.slider('Select min', 10, 100, step=10, value=100)
|
16 |
+
#do_sample = st.sidebar.checkbox("Do sample", value=False)
|
17 |
+
with st.spinner("Generating Patent Summary.."):
|
18 |
+
if button and sentence:
|
19 |
+
#chunks = generate_chunks(sentence)
|
20 |
+
res = summarize(sentence,
|
21 |
+
max_length=500,
|
22 |
+
min_length=100,
|
23 |
+
truncation=True,
|
24 |
+
#do_sample=do_sample
|
25 |
+
)
|
26 |
+
text = ' '.join([summ['summary_text'] for summ in res])
|
27 |
+
# st.write(result[0]['summary_text'])
|
28 |
+
st.write(text)
|