Spaces:
Running
Running
Create text-summarizer
#1
by
saira-projects
- opened
- text-summarizer +24 -0
text-summarizer
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from transformers import pipeline
|
| 3 |
+
|
| 4 |
+
# Title
|
| 5 |
+
st.title("📝 Text Summarizer")
|
| 6 |
+
st.write("Paste your text below and get a short summary!")
|
| 7 |
+
|
| 8 |
+
# Text input
|
| 9 |
+
user_input = st.text_area("Enter text here:", height=200)
|
| 10 |
+
|
| 11 |
+
# Load summarization pipeline
|
| 12 |
+
@st.cache_resource
|
| 13 |
+
def load_model():
|
| 14 |
+
return pipeline("summarization", model="facebook/bart-large-cnn")
|
| 15 |
+
|
| 16 |
+
summarizer = load_model()
|
| 17 |
+
|
| 18 |
+
# Summarize button
|
| 19 |
+
if st.button("Summarize"):
|
| 20 |
+
if user_input.strip() == "":
|
| 21 |
+
st.warning("Please enter some text first!")
|
| 22 |
+
else:
|
| 23 |
+
summary = summarizer(user_input, max_length=100, min_length=25, do_sample=False)
|
| 24 |
+
st.success(summary[0]['summary_text'])
|