Spaces:
No application file
No application file
Delete app2.py
Browse files
app2.py
DELETED
|
@@ -1,75 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
from textsummarizer.pipeline.prediction import PredictionPipeline
|
| 3 |
-
|
| 4 |
-
# Initialize the PredictionPipeline
|
| 5 |
-
obj = PredictionPipeline()
|
| 6 |
-
|
| 7 |
-
# Function to create a download link for text
|
| 8 |
-
def get_download_link(text, filename):
|
| 9 |
-
href = f'<a href="data:text/plain;charset=utf-8,{text}" download="{filename}">Download Summarized Text</a>'
|
| 10 |
-
return href
|
| 11 |
-
|
| 12 |
-
# Define the Streamlit app
|
| 13 |
-
def main():
|
| 14 |
-
# Add CSS to set the background color of the entire app
|
| 15 |
-
st.markdown(
|
| 16 |
-
"""
|
| 17 |
-
<style>
|
| 18 |
-
body {
|
| 19 |
-
background-color: #f0f2f6; /* Light grey */
|
| 20 |
-
}
|
| 21 |
-
</style>
|
| 22 |
-
""",
|
| 23 |
-
unsafe_allow_html=True
|
| 24 |
-
)
|
| 25 |
-
|
| 26 |
-
st.title("Text Summarization")
|
| 27 |
-
# Set background image
|
| 28 |
-
st.markdown(
|
| 29 |
-
"""
|
| 30 |
-
<style>
|
| 31 |
-
.reportview-container {
|
| 32 |
-
background: url("https://img.freepik.com/premium-photo/abstract-black-textured-background-with-scratches_130265-12474.jpg")
|
| 33 |
-
}
|
| 34 |
-
</style>
|
| 35 |
-
""",
|
| 36 |
-
unsafe_allow_html=True
|
| 37 |
-
)
|
| 38 |
-
|
| 39 |
-
# Sidebar for user input
|
| 40 |
-
st.sidebar.title("User Input")
|
| 41 |
-
st.sidebar.write("Enter the text you want to summarize in the text box below.")
|
| 42 |
-
text_input = st.sidebar.text_area("Input Text", height=400) # Increase input box size
|
| 43 |
-
|
| 44 |
-
# Separator
|
| 45 |
-
st.sidebar.markdown("---")
|
| 46 |
-
|
| 47 |
-
# Button to trigger summarization
|
| 48 |
-
if st.sidebar.button("Summarize"):
|
| 49 |
-
if text_input:
|
| 50 |
-
try:
|
| 51 |
-
# Perform summarization
|
| 52 |
-
summary = obj.predict(text_input)
|
| 53 |
-
st.subheader("Summary:")
|
| 54 |
-
st.write(summary)
|
| 55 |
-
|
| 56 |
-
# Download button for summarized conversation
|
| 57 |
-
st.markdown(get_download_link(summary, filename="summary.txt"), unsafe_allow_html=True)
|
| 58 |
-
|
| 59 |
-
except Exception as e:
|
| 60 |
-
st.error("An error occurred during summarization.")
|
| 61 |
-
st.error(e)
|
| 62 |
-
else:
|
| 63 |
-
st.warning("Please enter some text to summarize.")
|
| 64 |
-
|
| 65 |
-
# About section
|
| 66 |
-
st.sidebar.markdown("---")
|
| 67 |
-
st.sidebar.subheader("About")
|
| 68 |
-
st.sidebar.info(
|
| 69 |
-
"This app uses a text summarization model to generate summaries of input text."
|
| 70 |
-
)
|
| 71 |
-
st.sidebar.info("Developed by Subhaganesh.")
|
| 72 |
-
|
| 73 |
-
# Run the app
|
| 74 |
-
if __name__ == "__main__":
|
| 75 |
-
main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|