Spaces:
Sleeping
Sleeping
Create text_summary.py
Browse files- text_summary.py +27 -0
text_summary.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Load the summarization pipeline
|
| 5 |
+
text_summary = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
|
| 6 |
+
|
| 7 |
+
def summarize_text(input_text):
|
| 8 |
+
output = text_summary(input_text)
|
| 9 |
+
return output[0]['summary_text']
|
| 10 |
+
|
| 11 |
+
def run():
|
| 12 |
+
st.title("📄 Text Summary Tool")
|
| 13 |
+
st.write("This tool helps you summarize long pieces of text efficiently using AI-powered NLP models.")
|
| 14 |
+
|
| 15 |
+
st.write("Enter a large text below to generate a summary.")
|
| 16 |
+
text = st.text_area("This tool helps you summarize long pieces of text efficiently using AI-powered NLP models.")
|
| 17 |
+
|
| 18 |
+
# text = st.text_area("Enter your text here:", "")
|
| 19 |
+
if st.button("🚀 Summarize", help="Click to generate summary"):
|
| 20 |
+
if text:
|
| 21 |
+
with st.spinner("Generating summary..."):
|
| 22 |
+
summary_result = summarize_text(text)
|
| 23 |
+
|
| 24 |
+
st.markdown("### 📝 Summarized Text:")
|
| 25 |
+
st.success(summary_result)
|
| 26 |
+
else:
|
| 27 |
+
st.warning("⚠️ Please enter some text to summarize.")
|