Spaces:
Runtime error
Runtime error
Prakash N
commited on
Commit
·
2dc1596
1
Parent(s):
30ab516
modified 1st summary button functionality
Browse files
app.py
CHANGED
|
@@ -35,24 +35,26 @@ st.markdown(""" #### LorSor helps you through a simple 3 stage process.
|
|
| 35 |
st.markdown('#')
|
| 36 |
col1, col2 = st.columns(2)
|
| 37 |
|
| 38 |
-
|
| 39 |
-
col1.header("Step 1:")
|
| 40 |
-
raw_text = st.text_area('Paste the full article text to summarize here...')
|
| 41 |
-
st.button("Summarize this")
|
| 42 |
-
|
| 43 |
def get_response(input_text):
|
| 44 |
batch = tokenizer([input_text],truncation=True,padding='longest',max_length=1024, return_tensors="pt").to('cpu')
|
| 45 |
gen_out = model.generate(**batch,max_length=128,num_beams=5, num_return_sequences=1, temperature=1.5)
|
| 46 |
output_text = tokenizer.batch_decode(gen_out, skip_special_tokens=True)
|
| 47 |
return output_text
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
with col2:
|
| 56 |
col2.header("Step 2:")
|
| 57 |
y = st.text_area("Here is the completed summary for you to edit", summary)
|
| 58 |
-
st.button("Submit edits")
|
|
|
|
|
|
| 35 |
st.markdown('#')
|
| 36 |
col1, col2 = st.columns(2)
|
| 37 |
|
| 38 |
+
@st.cache
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
def get_response(input_text):
|
| 40 |
batch = tokenizer([input_text],truncation=True,padding='longest',max_length=1024, return_tensors="pt").to('cpu')
|
| 41 |
gen_out = model.generate(**batch,max_length=128,num_beams=5, num_return_sequences=1, temperature=1.5)
|
| 42 |
output_text = tokenizer.batch_decode(gen_out, skip_special_tokens=True)
|
| 43 |
return output_text
|
| 44 |
|
| 45 |
+
with col1:
|
| 46 |
+
col1.header("Step 1:")
|
| 47 |
+
raw_text = st.text_area('Paste the full article text to summarize here...')
|
| 48 |
+
summary_button = st.button("Summarize this")
|
| 49 |
|
| 50 |
+
if summary_button:
|
| 51 |
+
if len(raw_text) < 10:
|
| 52 |
+
summary = "<< Add some text in ( Step 1 ) for me to summarize >>"
|
| 53 |
+
else:
|
| 54 |
+
summary = get_response(raw_text)
|
| 55 |
|
| 56 |
with col2:
|
| 57 |
col2.header("Step 2:")
|
| 58 |
y = st.text_area("Here is the completed summary for you to edit", summary)
|
| 59 |
+
st.button("Submit edits")
|
| 60 |
+
st.balloons()
|