Spaces:
Runtime error
Runtime error
Update app.py
Browse files
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 |
-
#
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
|
|
43 |
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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!")
|