sharath6900 commited on
Commit
c71b2e8
·
verified ·
1 Parent(s): ae644b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -6
app.py CHANGED
@@ -1,5 +1,7 @@
 
1
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
2
 
 
3
  tokenizer = AutoTokenizer.from_pretrained("suriya7/bart-finetuned-text-summarization")
4
  model = AutoModelForSeq2SeqLM.from_pretrained("suriya7/bart-finetuned-text-summarization")
5
 
@@ -9,9 +11,20 @@ def generate_summary(text):
9
  summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
10
  return summary
11
 
12
- text_to_summarize = """Now, there is no doubt that one of the most important aspects of any Pixel phone is its camera.
13
- And there might be good news for all camera lovers. Rumours have suggested that the Pixel 9 could come with a telephoto lens,
14
- improving its photography capabilities even further. Google will likely continue to focus on using AI to enhance its camera performance,
15
- in order to make sure that Pixel phones remain top contenders in the world of mobile photography."""
16
- summary = generate_summary(text_to_summarize)
17
- print(summary)
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
  from transformers import AutoTokenizer, AutoModelForSeq2SeqLM
3
 
4
+ # Load the tokenizer and model
5
  tokenizer = AutoTokenizer.from_pretrained("suriya7/bart-finetuned-text-summarization")
6
  model = AutoModelForSeq2SeqLM.from_pretrained("suriya7/bart-finetuned-text-summarization")
7
 
 
11
  summary = tokenizer.decode(summary_ids[0], skip_special_tokens=True)
12
  return summary
13
 
14
+ # Streamlit interface
15
+ st.title("Text Summarization App")
16
+
17
+ # User text input
18
+ user_input = st.text_area("Enter the text you want to summarize", height=200)
19
+
20
+ if st.button("Generate Summary"):
21
+ if user_input:
22
+ with st.spinner("Generating summary..."):
23
+ summary = generate_summary(user_input)
24
+ st.subheader("Summary:")
25
+ st.write(summary)
26
+ else:
27
+ st.warning("Please enter text to summarize.")
28
+
29
+ # Instructions for using the app
30
+ st.write("Enter your text in the box above and click 'Generate Summary' to get a summarized version of your text.")