Safna commited on
Commit
e27c01d
1 Parent(s): 8f5fb41

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ from transformers import pipeline
3
+
4
+ model_name = "Safna/abstractive"
5
+
6
+ summarizer = pipeline("summarization", model= AutoModelForSeq2SeqLM.from_pretrained(model_name), tokenizer= AutoTokenizer.from_pretrained("sshleifer/distilbart-xsum-12-3"))
7
+
8
+
9
+ st.title("Text Summarization App")
10
+
11
+ input_text = st.text_area("Enter the text you want to summarize:")
12
+
13
+ if st.button("Generate Summary"):
14
+ if input_text:
15
+ with st.spinner("Generating summary..."):
16
+ summary = summarizer(input_text, max_length=64, min_length=10, length_penalty=2.0, num_beams=4, early_stopping=True)
17
+ st.subheader("Generated Summary:")
18
+ st.write(summary[0]["summary_text"])
19
+
20
+ # Instructions
21
+ st.sidebar.header("Instructions")
22
+ st.sidebar.markdown("1. Enter the text you want to summarize.")
23
+ st.sidebar.markdown("2. Click the 'Generate Summary' button.")