created app
Browse files
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the summarization model
|
| 5 |
+
summarizer = pipeline("summarization")
|
| 6 |
+
|
| 7 |
+
# Streamlit app layout
|
| 8 |
+
st.title("Text Summarization App")
|
| 9 |
+
st.write("Enter text below to get a summary.")
|
| 10 |
+
|
| 11 |
+
# Text input area for user to input text
|
| 12 |
+
input_text = st.text_area("Input Text", height=300)
|
| 13 |
+
|
| 14 |
+
# Summarize button
|
| 15 |
+
if st.button("Summarize"):
|
| 16 |
+
if input_text.strip():
|
| 17 |
+
with st.spinner("Summarizing..."):
|
| 18 |
+
# Generate the summary
|
| 19 |
+
summary = summarizer(input_text, max_length=130, min_length=30, do_sample=False)
|
| 20 |
+
st.success("Summary complete!")
|
| 21 |
+
st.write("**Summary:**")
|
| 22 |
+
st.write(summary[0]['summary_text'])
|
| 23 |
+
else:
|
| 24 |
+
st.warning("Please enter some text to summarize.")
|