Spaces:
Runtime error
Runtime error
Prakash N
commited on
Commit
·
56e5734
1
Parent(s):
d9780b1
added summarizercode
Browse files
app.py
CHANGED
@@ -1,4 +1,11 @@
|
|
1 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
|
3 |
st.markdown(""" <style> .font {
|
4 |
font-size:50px ; font-family: "Helvetica"; color: #FF9633;}
|
@@ -24,16 +31,27 @@ st.markdown(""" #### LorSor helps you through a simple 3 stage process.
|
|
24 |
|
25 |
Send any feedback to [us](mailto:[email protected]) """)
|
26 |
|
27 |
-
|
28 |
col1, col2 = st.columns(2)
|
29 |
|
30 |
with col1:
|
31 |
col1.header("Step 1:")
|
32 |
-
|
33 |
st.button("Summarize this")
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
with col2:
|
36 |
col2.header("Step 2:")
|
37 |
-
summary = "Lorem Ipsum is a long and boring piece of old latin text. What it means i have no idea"
|
38 |
y = st.text_area("Here is the completed summary for you to edit", summary)
|
39 |
st.button("Submit edits")
|
|
|
1 |
import streamlit as st
|
2 |
+
from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
|
3 |
+
|
4 |
+
#downloading tokenizer and model
|
5 |
+
tokenizer = AutoTokenizer.from_pretrained("tuner007/pegasus_summarizer")
|
6 |
+
model = AutoModelForSeq2SeqLM.from_pretrained("tuner007/pegasus_summarizer")
|
7 |
+
|
8 |
+
|
9 |
|
10 |
st.markdown(""" <style> .font {
|
11 |
font-size:50px ; font-family: "Helvetica"; color: #FF9633;}
|
|
|
31 |
|
32 |
Send any feedback to [us](mailto:[email protected]) """)
|
33 |
|
34 |
+
st.markdown('#')
|
35 |
col1, col2 = st.columns(2)
|
36 |
|
37 |
with col1:
|
38 |
col1.header("Step 1:")
|
39 |
+
raw_text = st.text_area('Paste the full article text to summarize here...')
|
40 |
st.button("Summarize this")
|
41 |
|
42 |
+
def get_response(input_text):
|
43 |
+
batch = tokenizer([input_text],truncation=True,padding='longest',max_length=1024, return_tensors="pt").to('cpu')
|
44 |
+
gen_out = model.generate(**batch,max_length=128,num_beams=5, num_return_sequences=1, temperature=1.5)
|
45 |
+
output_text = tokenizer.batch_decode(gen_out, skip_special_tokens=True)
|
46 |
+
return output_text
|
47 |
+
|
48 |
+
if len(raw_text) < 10:
|
49 |
+
summary = "Lorem Ipsum is a long and boring piece of old latin text. What it means i have no idea"
|
50 |
+
else:
|
51 |
+
summary = get_response(raw_text)
|
52 |
+
|
53 |
+
|
54 |
with col2:
|
55 |
col2.header("Step 2:")
|
|
|
56 |
y = st.text_area("Here is the completed summary for you to edit", summary)
|
57 |
st.button("Submit edits")
|