Sandaruth commited on
Commit
29e0cfd
·
verified ·
1 Parent(s): c0ec734

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -13
app.py CHANGED
@@ -1,7 +1,5 @@
1
  import streamlit as st
2
  from transformers import pipeline
3
-
4
-
5
  from huggingface_hub import login
6
  from dotenv import load_dotenv
7
  import os
@@ -34,15 +32,27 @@ input_text = st.text_area("Enter the long text you want to summarize", height=30
34
 
35
  # Button to generate the summary
36
  if st.button("Generate Summary"):
37
- # Load the selected model and summarizer pipeline
38
- summarizer = pipeline("summarization", model=models[model_choice])
39
-
40
- if input_text:
41
- # Generate the summary
42
- summary = summarizer(input_text, max_length=350, min_length=30, do_sample=False)
 
43
 
44
- # Display the summary
45
- st.subheader("Generated Summary")
46
- st.write(summary[0]['summary_text'])
47
- else:
48
- st.write("Please enter text to summarize!")
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  from transformers import pipeline
 
 
3
  from huggingface_hub import login
4
  from dotenv import load_dotenv
5
  import os
 
32
 
33
  # Button to generate the summary
34
  if st.button("Generate Summary"):
35
+ # Show a spinner while generating the summary
36
+ with st.spinner("Generating summary, please wait..."):
37
+ # Load the selected model and summarizer pipeline
38
+ summarizer = pipeline("summarization", model=models[model_choice])
39
+
40
+ # Log the model choice
41
+ st.write(f"Using model: **{model_choice}** for summarization.")
42
 
43
+ if input_text:
44
+ # Generate the summary
45
+ summary = summarizer(input_text, max_length=350, min_length=30, do_sample=False)
46
+
47
+ # Log the success message
48
+ st.success("Summary generated successfully!")
49
+
50
+ # Display the summary
51
+ st.subheader("Generated Summary")
52
+ st.write(summary[0]['summary_text'])
53
+ else:
54
+ st.warning("Please enter text to summarize!")
55
+
56
+ # Optionally, you can add a footer or additional instructions
57
+ st.markdown("---")
58
+ st.write("Provide a long text and select a model to see the summarization in action!")